@songsid/agend 2.4.0-beta.8 → 2.4.0-beta.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 (330) hide show
  1. package/dist/auth-api.js +3 -0
  2. package/dist/auth-api.js.map +1 -1
  3. package/dist/backend/cli-runtime-switch.js +1 -26
  4. package/dist/backend/cli-runtime-switch.js.map +1 -1
  5. package/dist/build-provenance.json +1 -1
  6. package/dist/connect/mcp.d.ts +9 -0
  7. package/dist/connect/mcp.js +10 -0
  8. package/dist/connect/mcp.js.map +1 -0
  9. package/dist/connect/stdio.d.ts +1 -1
  10. package/dist/connect/stdio.js +22 -28
  11. package/dist/connect/stdio.js.map +1 -1
  12. package/dist/fleet-manager.d.ts +1 -1
  13. package/dist/fleet-manager.js +11 -16
  14. package/dist/fleet-manager.js.map +1 -1
  15. package/dist/general-knowledge/skills/hub/SKILL.md +78 -4
  16. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +10 -2
  17. package/dist/hub/admin-dashboard.js +17 -1
  18. package/dist/hub/admin-dashboard.js.map +1 -1
  19. package/dist/hub/audit/index.d.ts +2 -0
  20. package/dist/hub/audit/index.js +8 -0
  21. package/dist/hub/audit/index.js.map +1 -1
  22. package/dist/hub/buttons.js +3 -1
  23. package/dist/hub/buttons.js.map +1 -1
  24. package/dist/hub/catalog.d.ts +1 -0
  25. package/dist/hub/catalog.js +6 -4
  26. package/dist/hub/catalog.js.map +1 -1
  27. package/dist/hub/client.d.ts +3 -0
  28. package/dist/hub/client.js +14 -2
  29. package/dist/hub/client.js.map +1 -1
  30. package/dist/hub/compose/member.js +28 -11
  31. package/dist/hub/compose/member.js.map +1 -1
  32. package/dist/hub/compose/server.d.ts +5 -0
  33. package/dist/hub/compose/server.js +91 -10
  34. package/dist/hub/compose/server.js.map +1 -1
  35. package/dist/hub/group-policy/admin-api.d.ts +1 -0
  36. package/dist/hub/group-policy/admin-api.js +1 -1
  37. package/dist/hub/group-policy/admin-api.js.map +1 -1
  38. package/dist/hub/group-policy/admin-dto.d.ts +2 -1
  39. package/dist/hub/group-policy/admin-inventory.d.ts +2 -0
  40. package/dist/hub/group-policy/admin-inventory.js +13 -4
  41. package/dist/hub/group-policy/admin-inventory.js.map +1 -1
  42. package/dist/hub/group-policy/authorization.d.ts +2 -0
  43. package/dist/hub/group-policy/authorization.js +7 -2
  44. package/dist/hub/group-policy/authorization.js.map +1 -1
  45. package/dist/hub/group-policy/resources.d.ts +2 -0
  46. package/dist/hub/group-policy/resources.js +12 -1
  47. package/dist/hub/group-policy/resources.js.map +1 -1
  48. package/dist/hub/http/compose.js +99 -22
  49. package/dist/hub/http/compose.js.map +1 -1
  50. package/dist/hub/http/core.js +27 -3
  51. package/dist/hub/http/core.js.map +1 -1
  52. package/dist/hub/http/deps.d.ts +11 -0
  53. package/dist/hub/http/schema.js +6 -0
  54. package/dist/hub/http/schema.js.map +1 -1
  55. package/dist/hub/mcp/auth.d.ts +3 -0
  56. package/dist/hub/mcp/auth.js +11 -1
  57. package/dist/hub/mcp/auth.js.map +1 -1
  58. package/dist/hub/mcp/catalog.d.ts +44 -0
  59. package/dist/hub/mcp/catalog.js +31 -0
  60. package/dist/hub/mcp/catalog.js.map +1 -0
  61. package/dist/hub/mcp/door-schema.d.ts +7 -0
  62. package/dist/hub/mcp/door-schema.js +20 -0
  63. package/dist/hub/mcp/door-schema.js.map +1 -0
  64. package/dist/hub/mcp/http.d.ts +25 -0
  65. package/dist/hub/mcp/http.js +259 -0
  66. package/dist/hub/mcp/http.js.map +1 -0
  67. package/dist/hub/mcp/policy.d.ts +65 -0
  68. package/dist/hub/mcp/policy.js +153 -0
  69. package/dist/hub/mcp/policy.js.map +1 -0
  70. package/dist/hub/mcp/server.d.ts +3 -0
  71. package/dist/hub/mcp/server.js +32 -0
  72. package/dist/hub/mcp/server.js.map +1 -0
  73. package/dist/hub/mcp/tools.d.ts +31 -0
  74. package/dist/hub/mcp/tools.js +176 -0
  75. package/dist/hub/mcp/tools.js.map +1 -0
  76. package/dist/hub/member/room-ask.d.ts +4 -4
  77. package/dist/hub/member/room-ask.js +12 -0
  78. package/dist/hub/member/room-ask.js.map +1 -1
  79. package/dist/hub/member/room-mention-feedback.d.ts +44 -0
  80. package/dist/hub/member/room-mention-feedback.js +121 -0
  81. package/dist/hub/member/room-mention-feedback.js.map +1 -0
  82. package/dist/hub/member/room-notification.d.ts +9 -0
  83. package/dist/hub/member/room-notification.js +2 -0
  84. package/dist/hub/member/room-notification.js.map +1 -0
  85. package/dist/hub/member/room-post-answers.d.ts +1 -7
  86. package/dist/hub/member/room-post-answers.js.map +1 -1
  87. package/dist/hub/member/room-post.d.ts +3 -0
  88. package/dist/hub/member/room-post.js +9 -1
  89. package/dist/hub/member/room-post.js.map +1 -1
  90. package/dist/hub/pairing.d.ts +15 -1
  91. package/dist/hub/pairing.js +33 -2
  92. package/dist/hub/pairing.js.map +1 -1
  93. package/dist/hub/personal/owner-host.d.ts +76 -0
  94. package/dist/hub/personal/owner-host.js +137 -40
  95. package/dist/hub/personal/owner-host.js.map +1 -1
  96. package/dist/hub/personal/refusals.d.ts +11 -0
  97. package/dist/hub/personal/refusals.js +33 -0
  98. package/dist/hub/personal/refusals.js.map +1 -0
  99. package/dist/hub/personal/runtime-host.d.ts +26 -0
  100. package/dist/hub/personal/runtime-host.js +51 -0
  101. package/dist/hub/personal/runtime-host.js.map +1 -0
  102. package/dist/hub/personal/schema.d.ts +2 -0
  103. package/dist/hub/personal/schema.js +7 -1
  104. package/dist/hub/personal/schema.js.map +1 -1
  105. package/dist/hub/personal/turns.d.ts +39 -0
  106. package/dist/hub/personal/turns.js +221 -0
  107. package/dist/hub/personal/turns.js.map +1 -0
  108. package/dist/hub/personal/types.d.ts +1 -1
  109. package/dist/hub/policy.d.ts +1 -1
  110. package/dist/hub/protocol.d.ts +43 -0
  111. package/dist/hub/protocol.js +16 -4
  112. package/dist/hub/protocol.js.map +1 -1
  113. package/dist/hub/roles/admin-control.js +69 -16
  114. package/dist/hub/roles/admin-control.js.map +1 -1
  115. package/dist/hub/roles/admin-types.d.ts +24 -1
  116. package/dist/hub/roles/allowed-list-control.d.ts +34 -0
  117. package/dist/hub/roles/allowed-list-control.js +179 -0
  118. package/dist/hub/roles/allowed-list-control.js.map +1 -0
  119. package/dist/hub/roles/allowed-list.d.ts +8 -0
  120. package/dist/hub/roles/allowed-list.js +49 -0
  121. package/dist/hub/roles/allowed-list.js.map +1 -0
  122. package/dist/hub/roles/audit-details.d.ts +144 -0
  123. package/dist/hub/roles/audit-details.js +26 -0
  124. package/dist/hub/roles/audit-details.js.map +1 -0
  125. package/dist/hub/roles/authority.d.ts +12 -0
  126. package/dist/hub/roles/authority.js +39 -3
  127. package/dist/hub/roles/authority.js.map +1 -1
  128. package/dist/hub/roles/change.d.ts +3 -1
  129. package/dist/hub/roles/change.js +4 -3
  130. package/dist/hub/roles/change.js.map +1 -1
  131. package/dist/hub/roles/clock.d.ts +3 -0
  132. package/dist/hub/roles/clock.js +1 -1
  133. package/dist/hub/roles/clock.js.map +1 -1
  134. package/dist/hub/roles/cutover-inventory.d.ts +2 -0
  135. package/dist/hub/roles/cutover-inventory.js +8 -1
  136. package/dist/hub/roles/cutover-inventory.js.map +1 -1
  137. package/dist/hub/roles/cutover.d.ts +2 -2
  138. package/dist/hub/roles/cutover.js +3 -4
  139. package/dist/hub/roles/cutover.js.map +1 -1
  140. package/dist/hub/roles/delegation.d.ts +4 -1
  141. package/dist/hub/roles/delegation.js +3 -2
  142. package/dist/hub/roles/delegation.js.map +1 -1
  143. package/dist/hub/roles/expiry-effects.d.ts +8 -0
  144. package/dist/hub/roles/expiry-effects.js +50 -0
  145. package/dist/hub/roles/expiry-effects.js.map +1 -0
  146. package/dist/hub/roles/migrations.d.ts +7 -0
  147. package/dist/hub/roles/migrations.js +44 -0
  148. package/dist/hub/roles/migrations.js.map +1 -0
  149. package/dist/hub/roles/model.d.ts +2 -0
  150. package/dist/hub/roles/model.js +2 -1
  151. package/dist/hub/roles/model.js.map +1 -1
  152. package/dist/hub/roles/overview.d.ts +8 -0
  153. package/dist/hub/roles/overview.js +15 -0
  154. package/dist/hub/roles/overview.js.map +1 -0
  155. package/dist/hub/roles/resource-effects.d.ts +3 -2
  156. package/dist/hub/roles/resource-effects.js +1 -1
  157. package/dist/hub/roles/resource-effects.js.map +1 -1
  158. package/dist/hub/roles/review.d.ts +16 -0
  159. package/dist/hub/roles/review.js +42 -0
  160. package/dist/hub/roles/review.js.map +1 -0
  161. package/dist/hub/roles/writer.d.ts +8 -2
  162. package/dist/hub/roles/writer.js +56 -16
  163. package/dist/hub/roles/writer.js.map +1 -1
  164. package/dist/hub/room-mention-feedback-model.d.ts +12 -0
  165. package/dist/hub/room-mention-feedback-model.js +12 -0
  166. package/dist/hub/room-mention-feedback-model.js.map +1 -0
  167. package/dist/hub/rooms/agents.d.ts +3 -1
  168. package/dist/hub/rooms/agents.js +94 -12
  169. package/dist/hub/rooms/agents.js.map +1 -1
  170. package/dist/hub/rooms/direct-view.d.ts +6 -2
  171. package/dist/hub/rooms/direct-view.js +3 -3
  172. package/dist/hub/rooms/direct-view.js.map +1 -1
  173. package/dist/hub/rooms/service.d.ts +27 -3
  174. package/dist/hub/rooms/service.js +74 -13
  175. package/dist/hub/rooms/service.js.map +1 -1
  176. package/dist/hub/rooms/types.d.ts +3 -1
  177. package/dist/hub/rooms.d.ts +11 -1
  178. package/dist/hub/rooms.js +76 -10
  179. package/dist/hub/rooms.js.map +1 -1
  180. package/dist/hub/runtime.js +1 -1
  181. package/dist/hub/runtime.js.map +1 -1
  182. package/dist/hub/server.d.ts +2 -0
  183. package/dist/hub/server.js +19 -3
  184. package/dist/hub/server.js.map +1 -1
  185. package/dist/hub/session-directory-transition.d.ts +2 -1
  186. package/dist/hub/session-directory-transition.js +10 -3
  187. package/dist/hub/session-directory-transition.js.map +1 -1
  188. package/dist/hub/sessions.d.ts +1 -1
  189. package/dist/hub/sessions.js +14 -10
  190. package/dist/hub/sessions.js.map +1 -1
  191. package/dist/hub/settings-commit.d.ts +32 -1
  192. package/dist/hub/settings-commit.js +11 -4
  193. package/dist/hub/settings-commit.js.map +1 -1
  194. package/dist/hub/settings-directory-ca.js +1 -1
  195. package/dist/hub/settings-directory-ca.js.map +1 -1
  196. package/dist/hub/settings-directory-control.js +7 -7
  197. package/dist/hub/settings-directory-control.js.map +1 -1
  198. package/dist/hub/settings-directory-http.d.ts +2 -0
  199. package/dist/hub/settings-directory-http.js +21 -6
  200. package/dist/hub/settings-directory-http.js.map +1 -1
  201. package/dist/hub/settings-directory-proof.d.ts +5 -1
  202. package/dist/hub/settings-directory-proof.js +27 -9
  203. package/dist/hub/settings-directory-proof.js.map +1 -1
  204. package/dist/hub/settings-directory-recovery.js +2 -1
  205. package/dist/hub/settings-directory-recovery.js.map +1 -1
  206. package/dist/hub/settings-directory-save.d.ts +2 -0
  207. package/dist/hub/settings-directory-save.js +9 -6
  208. package/dist/hub/settings-directory-save.js.map +1 -1
  209. package/dist/hub/types.d.ts +11 -0
  210. package/dist/locale.js +10 -10
  211. package/dist/locale.js.map +1 -1
  212. package/dist/login-controller.d.ts +19 -2
  213. package/dist/login-controller.js +26 -8
  214. package/dist/login-controller.js.map +1 -1
  215. package/dist/runtime-build-info.js +1 -1
  216. package/dist/runtime-build-info.js.map +1 -1
  217. package/dist/runtime-client.js +6 -6
  218. package/dist/runtime-client.js.map +1 -1
  219. package/dist/runtime-coordinator.js +8 -3
  220. package/dist/runtime-coordinator.js.map +1 -1
  221. package/dist/runtime-install.d.ts +3 -1
  222. package/dist/runtime-install.js +5 -3
  223. package/dist/runtime-install.js.map +1 -1
  224. package/dist/runtime-personal-answer-only-probe.d.ts +3 -0
  225. package/dist/runtime-personal-answer-only-probe.js +134 -0
  226. package/dist/runtime-personal-answer-only-probe.js.map +1 -0
  227. package/dist/runtime-personal-answer-only.d.ts +16 -0
  228. package/dist/runtime-personal-answer-only.js +54 -0
  229. package/dist/runtime-personal-answer-only.js.map +1 -0
  230. package/dist/runtime-personal-answer.d.ts +6 -2
  231. package/dist/runtime-personal-answer.js +10 -2
  232. package/dist/runtime-personal-answer.js.map +1 -1
  233. package/dist/runtime-personal-preflight.d.ts +4 -1
  234. package/dist/runtime-personal-preflight.js +50 -4
  235. package/dist/runtime-personal-preflight.js.map +1 -1
  236. package/dist/runtime-personal-profile.d.ts +4 -0
  237. package/dist/runtime-personal-profile.js +11 -0
  238. package/dist/runtime-personal-profile.js.map +1 -1
  239. package/dist/runtime-personal-protocol.d.ts +4 -1
  240. package/dist/runtime-personal-protocol.js +5 -1
  241. package/dist/runtime-personal-protocol.js.map +1 -1
  242. package/dist/runtime-personal-stage.d.ts +1 -0
  243. package/dist/runtime-personal-stage.js +7 -3
  244. package/dist/runtime-personal-stage.js.map +1 -1
  245. package/dist/runtime-protocol.d.ts +1 -1
  246. package/dist/setup-form.js +10 -0
  247. package/dist/setup-form.js.map +1 -1
  248. package/dist/tunnel/lease.d.ts +14 -0
  249. package/dist/tunnel/lease.js +23 -0
  250. package/dist/tunnel/lease.js.map +1 -1
  251. package/dist/ui/backend-signin.js +86 -20
  252. package/dist/ui/chat-activity-groups.js +41 -8
  253. package/dist/ui/chat-activity.js +3 -1
  254. package/dist/ui/chat-tour.js +1 -1
  255. package/dist/ui/fleet-canvas.js +10 -5
  256. package/dist/ui/fleet-office.js +73 -7
  257. package/dist/ui/hub-ai-apps-strings.js +6 -0
  258. package/dist/ui/hub-ai-apps.js +83 -0
  259. package/dist/ui/hub-client.js +19 -2
  260. package/dist/ui/hub-directory-editor-strings.js +2 -2
  261. package/dist/ui/hub-directory-editor.js +1 -0
  262. package/dist/ui/hub-group-policy.js +4 -3
  263. package/dist/ui/hub-group-strings.js +2 -2
  264. package/dist/ui/hub-personal-agent-strings.js +160 -0
  265. package/dist/ui/hub-personal-agent.js +94 -0
  266. package/dist/ui/hub-role-audit.js +39 -0
  267. package/dist/ui/hub-role-forms.js +99 -0
  268. package/dist/ui/hub-role-notices.js +11 -0
  269. package/dist/ui/hub-role-view.js +86 -0
  270. package/dist/ui/hub-roles-strings.js +428 -4
  271. package/dist/ui/hub-roles.js +76 -41
  272. package/dist/ui/hub-room-composer.js +3 -2
  273. package/dist/ui/hub-room-list.js +4 -3
  274. package/dist/ui/hub-room-members.js +4 -2
  275. package/dist/ui/hub-room-settings.js +6 -0
  276. package/dist/ui/hub-room-source-strings.js +17 -0
  277. package/dist/ui/hub-room-source.js +34 -0
  278. package/dist/ui/hub-room-thread.js +10 -4
  279. package/dist/ui/panel-chat.js +4 -4
  280. package/dist/ui/panel-fleet.js +3 -3
  281. package/dist/ui/panel-hub.js +39 -25
  282. package/dist/ui/runtime-commands.d.ts +2 -2
  283. package/dist/ui/runtime-commands.js +7 -4
  284. package/dist/ui/settings-build-version.js +2 -2
  285. package/dist/ui/shared/access-overview.css +1 -1
  286. package/dist/ui/shared/accounts-keepalive.css +1 -1
  287. package/dist/ui/shared/accounts.css +1 -1
  288. package/dist/ui/shared/agent-sheet.js +2 -2
  289. package/dist/ui/shared/app-prefs.js +5 -2
  290. package/dist/ui/shared/app-shell.js +1 -1
  291. package/dist/ui/shared/app-swipe.js +3 -1
  292. package/dist/ui/shared/app.css +124 -40
  293. package/dist/ui/shared/app.js +1 -1
  294. package/dist/ui/shared/chat-thread.js +5 -1
  295. package/dist/ui/shared/chat-work-bar.css +5 -5
  296. package/dist/ui/shared/connector-prompt.d.ts +1 -0
  297. package/dist/ui/shared/connector-prompt.js +10 -0
  298. package/dist/ui/shared/hub-ai-apps.css +12 -0
  299. package/dist/ui/shared/hub-chat.css +9 -2
  300. package/dist/ui/shared/hub-groups.css +1 -1
  301. package/dist/ui/shared/hub-owner.css +5 -5
  302. package/dist/ui/shared/hub-roles.css +98 -26
  303. package/dist/ui/shared/hub-rooms-u2.css +14 -0
  304. package/dist/ui/shared/hub.css +3 -3
  305. package/dist/ui/shared/instance-nav.js +24 -9
  306. package/dist/ui/shared/loading.css +1 -1
  307. package/dist/ui/shared/model-picker.css +2 -2
  308. package/dist/ui/shared/preview-panel-actions.js +1 -1
  309. package/dist/ui/shared/preview-panel.js +2 -2
  310. package/dist/ui/shared/signin.js +27 -12
  311. package/dist/ui/shared/task-board.css +2 -2
  312. package/dist/ui/shared/tokens.css +1 -1
  313. package/dist/ui/shared/ui-toast.js +4 -4
  314. package/dist/ui/shared/usage-dialog.js +43 -4
  315. package/dist/ui/signin.html +4 -2
  316. package/dist/ui/structured-signin.js +64 -12
  317. package/dist/ui/web-terminal/terminal.css +1 -1
  318. package/dist/web-backend-login.d.ts +5 -1
  319. package/dist/web-backend-login.js +8 -2
  320. package/dist/web-backend-login.js.map +1 -1
  321. package/dist/web-prefs.js +2 -0
  322. package/dist/web-prefs.js.map +1 -1
  323. package/dist/windows-cli-worker.d.ts +3 -0
  324. package/dist/windows-cli-worker.js +33 -4
  325. package/dist/windows-cli-worker.js.map +1 -1
  326. package/dist/windows-cli.d.ts +1 -0
  327. package/dist/windows-cli.js +8 -4
  328. package/dist/windows-cli.js.map +1 -1
  329. package/package.json +1 -1
  330. package/templates/runtime-install/install.ps1 +24 -4
@@ -1,48 +1,83 @@
1
- /** Role settings use one checked policy proposal; browser flags are presentation only. */
1
+ /** Role navigation/presentation. Every mutation still uses the server's single checked policy proposal. */
2
2
  import {html,useEffect,useRef,useState} from "/assets/app-html.js";
3
+ import {Dialog} from "/assets/ui-dialog.js";
3
4
  import {hr,linkRoleCss} from "./hub-roles-strings.js";
4
- const copy=value=>structuredClone(value),key=person=>`${person?.realm}/${person?.objectId}`;
5
- const management=["fleets.manage","join.manage","roles.assign","audit.view","hub.admin"];
6
- const approvals=["team.approve_join","team.approve_ask"];
7
- const name=role=>["admin","manager","member"].includes(role.kind)?hr(role.kind):role.name;
8
- const error=out=>["denied","self-target"].includes(out?.code)?hr("denied"):["expired","stale-preview","conflict"].includes(out?.code)?hr("stale"):out?.code==="invalid"?hr("invalid"):hr("failed");
9
-
10
- function Search({client,kind,onPick}){
11
- const [q,setQ]=useState(""),[rows,setRows]=useState([]),[busy,setBusy]=useState(false),[failure,setFailure]=useState(null),epoch=useRef(0);
12
- useEffect(()=>()=>{epoch.current++;},[client,kind]);
13
- const search=async()=>{if(q.trim().length<2||busy)return;const mine=++epoch.current;setBusy(true);setFailure(null);let out;try{out=await client.roleSearch(kind,q.trim());}catch{out={ok:false};}if(mine!==epoch.current)return;setBusy(false);if(out.ok)setRows(out.candidates||[]);else setFailure(error(out));};
14
- return html`<div class="hub-role-search"><label class="field"><span>${hr(kind)}</span><input value=${q} maxlength="64" placeholder=${hr("query")} onInput=${e=>{epoch.current++;setQ(e.target.value);setRows([]);setBusy(false);}} onKeyDown=${e=>{if(e.key==="Enter"){e.preventDefault();void search();}}}/></label><button type="button" class="btn" disabled=${busy||q.trim().length<2} onClick=${search}>${hr("search")}</button>${failure?html`<p role="alert" class="err">${failure}</p>`:null}<ul class="hub-role-list">${rows.map(row=>html`<li key=${key(row.key)}><span class="grow">${row.name}${row.login?html`<small class="note"> · ${row.login}</small>`:null}</span><button type="button" class="btn" onClick=${()=>{epoch.current++;onPick(row);setRows([]);setQ("");}}>${hr("choose")}</button></li>`)}</ul></div>`;
5
+ import {RoleWizard,AssignPanel,PermissionSections,Review} from "./hub-role-forms.js";
6
+ import {RoleAudit} from "./hub-role-audit.js";
7
+ import {personKey,personName,roleName,roleDescription,assignedSubjects,assignmentCount,subjectId,scopeName,roleError} from "./hub-role-view.js";
8
+ const copy=value=>structuredClone(value);
9
+ function Tabs({items,value,onChange,disabled=false,label}){
10
+ return html`<div class="hub-role-tabs" role="tablist" aria-label=${label}>${items.map(item=>html`<button key=${item.key} type="button" role="tab" tabindex=${item.key===value?0:-1} onKeyDown=${e=>{const at=items.findIndex(row=>row.key===value),keys={ArrowRight:(at+1)%items.length,ArrowLeft:(at+items.length-1)%items.length,Home:0,End:items.length-1};if(Object.hasOwn(keys,e.key)){e.preventDefault();const next=keys[e.key];onChange(items[next].key);(e.currentTarget||e.target).parentNode.querySelectorAll('[role="tab"]')[next]?.focus();}}} aria-selected=${item.key===value} class=${item.key===value?"is-active":""} disabled=${disabled} onClick=${()=>onChange(item.key)}>${item.label}</button>`)}</div>`;
15
11
  }
16
- function RoleEditor({view,role,onCheck,onCancel,busy}){
17
- const [quota,setQuota]=useState(String(role.defaultMaxFleets));const [draft,setDraft]=useState(()=>copy(role));const locked=role.kind==="admin"||!view.management.includes("hub.admin");
18
- const save=e=>{e.preventDefault();if(locked||!draft.name.trim()||quota===""||!Number.isInteger(Number(quota))||Number(quota)<0||Number(quota)>8)return;const checkedRole={...draft,defaultMaxFleets:Number(quota)};const next=copy(view.policy),at=next.roles.findIndex(r=>r.id===draft.id);if(at<0)next.roles.push(checkedRole);else next.roles[at]=checkedRole;onCheck(next);};
19
- return html`<form class="card hub-role-editor" onSubmit=${save}><h3>${name(role)}</h3><label class="field"><span>${hr("name")}</span><input required maxlength="100" value=${draft.name} disabled=${busy||locked} onInput=${e=>setDraft({...draft,name:e.target.value})}/></label><fieldset><legend>${hr("permissions")}</legend>${view.permissions.map(permission=>html`<label class="hub-role-check" key=${permission}><input type="checkbox" checked=${draft.permissions.includes(permission)} disabled=${busy||locked||permission==="hub.admin"||approvals.includes(permission)} onChange=${e=>setDraft({...draft,permissions:e.target.checked?[...draft.permissions,permission]:draft.permissions.filter(p=>p!==permission)})}/><span>${hr(permission)}${approvals.includes(permission)?html`<small class="note"> · ${hr("later")}</small>`:null}${permission==="hub.admin"?html`<small class="note"> · ${hr("locked")}</small>`:null}</span></label>`)}</fieldset><label class="field"><span>${hr("quota")}</span><input type="number" min="0" max="8" step="1" required value=${quota} disabled=${busy||locked} onInput=${e=>setQuota(e.target.value)}/></label><div class="hub-role-actions"><button type="submit" class="btn btn-primary" disabled=${busy||locked||!draft.name.trim()||quota===""||!Number.isInteger(Number(quota))||Number(quota)<0||Number(quota)>8}>${hr("preview")}</button>${role.kind==="custom"?html`<button type="button" class="btn btn-danger" disabled=${busy||locked} onClick=${()=>{const next=copy(view.policy);next.roles=next.roles.filter(r=>r.id!==role.id);next.assignments=next.assignments.filter(a=>a.roleId!==role.id);onCheck(next);}}>${hr("delete")}</button>`:null}<button type="button" class="btn" disabled=${busy} onClick=${onCancel}>${hr("cancel")}</button></div></form>`;
12
+ function RoleList({view,busy,canEdit,canAssign,onOpen,onAssign,onCreate}){
13
+ return html`<section class="card hub-role-list-page"><div class="hub-card-head"><h2>${hr("roles")}</h2>${canEdit?html`<button type="button" class="btn btn-primary" disabled=${busy} onClick=${onCreate}>${hr("newRole")}</button>`:null}</div>
14
+ <div class="hub-team-table-wrap"><table class="hub-team-table hub-role-list"><thead><tr><th>${hr("role")}</th><th>${hr("rolePurpose")}</th><th>${hr("assignedTo")}</th><th></th></tr></thead><tbody>${view.policy.roles.map(role=>html`<tr key=${role.id} onClick=${()=>{if(!busy)onOpen(role.id);}}>
15
+ <td><button type="button" class="hub-role-row-open" disabled=${busy} onClick=${e=>{e.stopPropagation();onOpen(role.id);}}>${roleName(role,view)}</button><span class="tag">${hr(role.kind==="custom"?"custom":role.kind==="carried-over"?"carried":"builtin")}</span></td>
16
+ <td class="hub-role-purpose">${roleDescription(role,view)}</td><td class="hub-role-assigned-count">${assignmentCount(view,role)}</td><td>${canAssign?html`<button type="button" class="btn btn-sm" disabled=${busy} onClick=${e=>{e.stopPropagation();onAssign(role.id);}}>${hr("assign")}</button>`:null}</td></tr>`)}</tbody></table></div></section>`;
20
17
  }
21
- const inputDate=at=>at?new Date(at-new Date(at).getTimezoneOffset()*60000).toISOString().slice(0,16):"";
22
- function AssignmentEditor({view,assignment=null,onCheck,onCancel,busy}){
23
- const original=assignment&&typeof assignment==="object"?assignment:null;
24
- const selected=original?.subject,initial=selected?(selected.kind==="person"?{kind:"person",key:selected.person,name:key(selected.person)}:{kind:"group",key:selected.group,name:selected.dn,dn:selected.dn}):null;
25
- const [roleId,setRoleId]=useState(original?.roleId||view.policy.roles[0]?.id||""),[kind,setKind]=useState(selected?.kind||"person"),[subject,setSubject]=useState(initial),[scope,setScope]=useState(original?.scope.kind==="group"?{key:original.scope.group,name:original.scope.dn,dn:original.scope.dn}:null),[whole,setWhole]=useState(original?.scope.kind==="hub"),[expiry,setExpiry]=useState(inputDate(original?.expiresAt)),[start,setStart]=useState(inputDate(original?.startsAt)),[limit,setLimit]=useState(original?.maxFleets==null?"":String(original.maxFleets));
26
- const role=view.policy.roles.find(r=>r.id===roleId),adminRole=role?.permissions.some(p=>management.includes(p)),teamRole=role?.permissions.some(p=>p.startsWith("team."));
27
- const startsAt=start?new Date(start).getTime():0,expiresAt=expiry?new Date(expiry).getTime():null;
28
- const valid=subject&&(!adminRole||subject.kind==="person")&&(!teamRole||adminRole||whole&&view.management.includes("hub.admin")||scope)&&Number.isFinite(startsAt)&&(expiresAt===null||Number.isFinite(expiresAt)&&expiresAt>startsAt)&&(limit===""||Number.isInteger(Number(limit))&&Number(limit)>=0&&Number(limit)<=8);
29
- const save=e=>{e.preventDefault();if(!valid||busy)return;const next=copy(view.policy);const replacement={id:original?.id||`assignment:${crypto.randomUUID()}`,roleId,subject:subject.kind==="person"?{kind:"person",person:subject.key}:{kind:"group",group:subject.key,dn:subject.dn},scope:!teamRole||adminRole||whole?{kind:"hub"}:{kind:"group",group:scope.key,dn:scope.dn},maxFleets:limit===""?null:Number(limit),startsAt,expiresAt,assignedBy:original?.assignedBy||view.actor,assignedAt:original?.assignedAt||0};if(original)next.assignments=next.assignments.map(row=>row.id===original.id?replacement:row);else next.assignments.push(replacement);onCheck(next);};
30
- return html`<form class="card hub-role-assignment" onSubmit=${save}><h3>${hr("assign")}</h3><label class="field"><span>${hr("role")}</span><select value=${roleId} disabled=${busy} onChange=${e=>setRoleId(e.target.value)}>${view.policy.roles.map(r=>html`<option key=${r.id} value=${r.id}>${name(r)}</option>`)}</select></label><label class="field"><span>${hr("subject")}</span><select value=${kind} disabled=${busy} onChange=${e=>{setKind(e.target.value);setSubject(null);}}><option value="person">${hr("person")}</option><option value="group" disabled=${adminRole}>${hr("group")}</option></select></label>${adminRole?html`<p class="note">${hr("personOnly")}</p>`:null}${kind==="group"?html`<p class="note">${hr("groupCost")}</p>`:null}<p>${subject?.name||hr("none")}</p><${Search} key=${kind} client=${view.client} kind=${kind} onPick=${setSubject}/>${teamRole&&!adminRole?html`<label class="field"><span>${hr("scope")}</span><select value=${whole?"hub":"group"} disabled=${busy} onChange=${e=>setWhole(e.target.value==="hub")}><option value="group">${hr("scopeGroup")}</option><option value="hub" disabled=${!view.management.includes("hub.admin")}>${hr("wholeHub")}</option></select></label>${!whole?html`<p>${scope?.name||hr("none")}</p><${Search} client=${view.client} kind="group" onPick=${setScope}/>`:null}`:null}<label class="field"><span>${hr("start")}</span><input type="datetime-local" value=${start} disabled=${busy} onInput=${e=>setStart(e.target.value)}/></label><label class="field"><span>${hr("expiry")}</span><input type="datetime-local" value=${expiry} disabled=${busy} onInput=${e=>setExpiry(e.target.value)}/></label>${role?.permissions.includes("pair_fleet")?html`<label class="field"><span>${hr("override")} · ${hr("quota")}: ${role.defaultMaxFleets}</span><input type="number" min="0" max="8" step="1" value=${limit} disabled=${busy} onInput=${e=>setLimit(e.target.value)}/></label>`:null}<div class="hub-role-actions"><button type="submit" class="btn btn-primary" disabled=${busy||!valid}>${hr("preview")}</button><button type="button" class="btn" disabled=${busy} onClick=${onCancel}>${hr("cancel")}</button></div></form>`;
18
+ function People({view,roleId=null,busy,onOpen,onAssign}){
19
+ const [filter,setFilter]=useState("all"),rows=assignedSubjects(view,roleId).filter(row=>filter==="all"||row.subject.kind===filter);
20
+ return html`<section class="card hub-role-people"><div class="hub-card-head"><h2>${hr("people")}</h2>${onAssign?html`<button type="button" class="btn btn-primary" disabled=${busy} onClick=${onAssign}>${hr("assignPeople")}</button>`:null}</div>
21
+ <label class="field hub-role-filter"><span>${hr("subject")}</span><select value=${filter} disabled=${busy} onChange=${e=>setFilter(e.target.value)}><option value="all">${hr("all")}</option><option value="person">${hr("people")}</option><option value="group">${hr("groups")}</option></select></label>
22
+ <ul class="hub-rows">${rows.map(row=>html`<li class="s-row hub-row" key=${row.id}><span class="hub-row-text"><button type="button" class="hub-role-row-open" disabled=${busy} onClick=${()=>onOpen(row.subject)}>${row.name}</button>
23
+ <span class="chips">${row.fixed?html`<span class="tag">${hr("admin")}</span>`:null}${[...new Set(row.assignments.map(a=>a.roleId))].map(id=>html`<span class="tag" key=${id}>${roleName(view.policy.roles.find(r=>r.id===id),view)}</span>`)}${row.subject.kind==="person"&&personKey(row.subject.person)===personKey(view.actor)?html`<span class="tag">${hr("you")}</span>`:null}</span>
24
+ <small class="note">${row.fixed?hr("firstAdminHelp"):[...new Set(row.assignments.map(a=>scopeName(a.scope)))].join(" · ")}</small></span></li>`)}</ul>${!rows.length?html`<p class="note">${hr("nobodyAssigned")}</p>`:null}</section>`;
25
+ }
26
+ function PersonRoles({view,subject,busy,onBack,onEdit,onRemove}){
27
+ const row=assignedSubjects(view).find(row=>row.id===subjectId(subject)),own=subject.kind==="person"&&personKey(subject.person)===personKey(view.actor),canAssign=view.management.includes("roles.assign");
28
+ return html`<section class="card hub-role-person"><button type="button" class="btn btn-sm" disabled=${busy} onClick=${onBack}>‹ ${hr("people")}</button><h2>${row?.name||hr("unknownPerson")}${own?html` <span class="tag">${hr("you")}</span>`:null}</h2>${own?html`<p class="s-info">${hr("selfHelp")}</p>`:null}
29
+ <ul class="hub-rows">${row?.fixed?html`<li class="s-row hub-row"><span class="hub-row-text"><strong>${hr("admin")}</strong><small class="note">${hr("firstAdminHelp")}</small></span></li>`:null}
30
+ ${row?.assignments.map(a=>html`<li class="s-row hub-row" key=${a.id}><span class="hub-row-text"><strong>${roleName(view.policy.roles.find(r=>r.id===a.roleId),view)}</strong><small class="note">${scopeName(a.scope)} · ${a.expiresAt?new Date(a.expiresAt).toLocaleString():hr("noEnd")}</small></span>
31
+ ${canAssign?html`<div class="s-actions"><button type="button" class="btn btn-sm" disabled=${busy||own} onClick=${()=>onEdit(a)}>${hr("edit")}</button><button type="button" class="btn btn-sm danger" disabled=${busy||own} onClick=${()=>onRemove(a)}>${hr("remove")}</button></div>`:null}</li>`)}</ul></section>`;
32
+ }
33
+ function RolePage({view,role,busy,canEdit,canAssign,onBack,onAssign,onEdit,onDelete,onPerson}){
34
+ const [tab,setTab]=useState("people"),editable=canEdit&&!["admin","carried-over"].includes(role.kind)&&!role.id.startsWith("root-self:");
35
+ const count=assignedSubjects(view,role.id).length;
36
+ return html`<section class="hub-role-detail"><button type="button" class="btn btn-sm" disabled=${busy} onClick=${onBack}>‹ ${hr("roles")}</button><div class="hub-card-head"><h2>${roleName(role,view)} <span class="tag">${hr(["custom","carried-over"].includes(role.kind)?role.kind==="custom"?"custom":"carried":"builtin")}</span></h2>
37
+ ${editable&&role.kind==="custom"?html`<details class="hub-role-menu"><summary>${hr("more")}</summary><button type="button" class="btn danger" disabled=${busy} onClick=${onDelete}>${hr("delete")}</button></details>`:null}</div><p>${roleDescription(role,view)}</p><p class="note">${hr("quota")}: ${role.defaultMaxFleets}</p>
38
+ <${Tabs} label=${roleName(role,view)} items=${[{key:"people",label:hr("people")+" · "+count},{key:"permissions",label:hr("permissions")+" · "+hr("permissionCount",role.permissions.length,12)}]} value=${tab} disabled=${busy} onChange=${setTab}/>
39
+ ${tab==="people"?html`<${People} key=${role.id} view=${view} roleId=${role.id} busy=${busy} onOpen=${onPerson} onAssign=${canAssign?onAssign:null}/>`:html`<section class="card"><div class="hub-card-head"><h3>${hr("permissions")}</h3>${editable?html`<button type="button" class="btn" disabled=${busy} onClick=${onEdit}>${hr("editPermissions")}</button>`:null}</div>
40
+ ${role.kind==="admin"?html`<p class="s-info">${hr("adminFixed")}</p>`:null}${role.kind==="carried-over"?html`<p class="note">${hr("inherited")}</p>`:null}<${PermissionSections} permissions=${role.permissions} readOnly=${true} administrator=${role.kind==="admin"}/></section>`}</section>`;
31
41
  }
32
42
  export function HubRoles({client}){
33
- const [styled,setStyled]=useState(null),[styleRetry,setStyleRetry]=useState(0);useEffect(()=>{let live=true;linkRoleCss().then(value=>{if(live)setStyled(value);});return()=>{live=false;};},[styleRetry]);
34
- const [view,setView]=useState(null),[failure,setFailure]=useState(null),[busy,setBusy]=useState(false),[editor,setEditor]=useState(null),[checked,setChecked]=useState(null),[saved,setSaved]=useState(false),[audit,setAudit]=useState(null),[auditError,setAuditError]=useState(null),[reload,setReload]=useState(0),[notices,setNotices]=useState([]);const epoch=useRef(0),writing=useRef(false);
35
- useEffect(()=>{let live=true;const mine=++epoch.current;setChecked(null);Promise.resolve().then(()=>client.roles()).then(out=>{if(!live||mine!==epoch.current)return;if(out.ok){setView(out.view);setFailure(null);if(out.view.management.includes("hub.admin")&&client.roleNotices)Promise.resolve(client.roleNotices()).then(n=>{if(live&&mine===epoch.current&&n.ok)setNotices(n.notices||[]);},()=>{});}else setFailure(error(out));},()=>{if(live&&mine===epoch.current)setFailure(hr("failed"));});Promise.resolve().then(()=>client.roleAudit()).then(out=>{if(!live||mine!==epoch.current)return;if(out.ok){setAudit(out);setAuditError(null);}else if(out.status!==403)setAuditError(hr("auditFailed"));},()=>{if(live&&mine===epoch.current)setAuditError(hr("auditFailed"));});const end=client.onSignedOut?.(()=>{epoch.current++;setView(null);setChecked(null);setEditor(null);setNotices([]);writing.current=false;setBusy(false);setFailure(hr("denied"));});return()=>{live=false;epoch.current++;end?.();};},[client,reload]);
36
- const preview=async(policy,rootSelf=false)=>{if(writing.current)return;writing.current=true;setBusy(true);setFailure(null);setSaved(false);setChecked(null);const mine=++epoch.current;let out;try{out=rootSelf?await client.roleRootPreview():await client.rolePreview(policy);}catch{out={ok:false};}if(mine!==epoch.current)return;writing.current=false;setBusy(false);if(out.ok)setChecked({policy,rootSelf,...out});else setFailure(error(out));};
37
- const apply=async()=>{if(!checked||writing.current)return;writing.current=true;setBusy(true);setFailure(null);const mine=++epoch.current;let out;try{out=checked.rootSelf?await client.roleRootApply(checked.previewDigest):await client.roleApply(checked.policy,checked.previewDigest);}catch{out={ok:false};}if(mine!==epoch.current)return;writing.current=false;setBusy(false);if(out.ok){setChecked(null);setEditor(null);setSaved(true);setReload(n=>n+1);}else{setChecked(null);setFailure(error(out));}};
38
- const more=async()=>{if(!audit?.nextCursor||busy)return;setBusy(true);const mine=epoch.current;let out;try{out=await client.roleAudit(audit.nextCursor);}catch{out={ok:false};}if(mine!==epoch.current)return;setBusy(false);if(out.ok)setAudit({...out,rows:[...audit.rows,...out.rows]});else setAuditError(hr("auditFailed"));};
39
- const acknowledge=async id=>{if(busy)return;setBusy(true);const mine=epoch.current;let out;try{out=await client.acknowledgeRoleNotice(id);}catch{out={ok:false};}if(mine!==epoch.current)return;setBusy(false);if(out.ok)setNotices(rows=>rows.filter(row=>row.id!==id));else setFailure(error(out));};
40
- const isRoot=view&&key(view.actor)===key(view.root),canEdit=view?.management.includes("hub.admin"),canAssign=view?.management.includes("roles.assign");
41
- if(!styled)return html`<section class="card"><p role="status">${hr(styled===false?"styleFailed":"styleLoading")}</p>${styled===false?html`<button type="button" class="btn" onClick=${()=>{setStyled(null);setStyleRetry(n=>n+1);}}>${hr("retry")}</button>`:null}</section>`;
42
- return html`<div class="hub-roles"><p class="s-page-lead hub-page-lead">${hr("lead")}</p>${failure?html`<p role="alert" class="err">${failure}</p><button type="button" class="btn" disabled=${busy} onClick=${()=>setReload(n=>n+1)}>${hr("retry")}</button>`:null}${saved?html`<p role="status">${hr("saved")}</p>`:null}${!view&&!failure?html`<p role="status">${hr("loading")}</p>`:null}<div class="s-section-layout">${notices.length?html`<section class="card"><h3>${hr("notices")}</h3><ul class="hub-role-list">${notices.map(n=>html`<li key=${n.id}><p class="grow">${hr(n.body?.kind==="roles-available"?"migrationNotice":"adminNotice")}</p><button type="button" class="btn" disabled=${busy} onClick=${()=>acknowledge(n.id)}>${hr("ack")}</button></li>`)}</ul></section>`:null}${view?.policy?html`<section class="card"><h3>${hr(view.policy.rolesActive?"on":"off")}</h3><p class="note">${hr("offHelp")}</p>${canEdit?html`<button type="button" class="btn" disabled=${busy} onClick=${()=>preview({...copy(view.policy),rolesActive:!view.policy.rolesActive})}>${hr(view.policy.rolesActive?"turnOff":"turnOn")}</button>`:null}<p><strong>${hr("firstAdmin")}</strong> · <code>${key(view.root)}</code></p><p class="note">${hr("firstAdminHelp")}</p>${isRoot&&!view.rootSelfUsed?html`<p class="note">${hr("rootHelp")}</p><button type="button" class="btn" disabled=${busy} onClick=${()=>preview(null,true)}>${hr("rootDefaults")}</button>`:null}</section>`:view?html`<p class="note">${hr("noPolicy")}</p>`:null}
43
- ${view?.policy?html`<section class="card"><div class="hub-role-head"><h3>${hr("roles")}</h3>${canEdit?html`<button type="button" class="btn" disabled=${busy} onClick=${()=>{setChecked(null);setEditor({role:{id:`custom:${crypto.randomUUID()}`,name:"",kind:"custom",permissions:[],defaultMaxFleets:1}});}}>${hr("newRole")}</button>`:null}</div><ul class="hub-role-list">${view.policy.roles.map(role=>html`<li key=${role.id}><span class="grow"><strong>${name(role)}</strong><small class="note hub-role-detail">${role.permissions.map(p=>hr(p)).join(" · ")}</small></span><button type="button" class="btn" disabled=${busy} onClick=${()=>{setChecked(null);setEditor({role});}}>${hr("edit")}</button></li>`)}</ul><p class="note">${hr("inherited")}</p></section>`:null}
44
- ${editor?.role&&view?html`<${RoleEditor} key=${editor.role.id} view=${view} role=${editor.role} busy=${busy} onCheck=${preview} onCancel=${()=>{setEditor(null);setChecked(null);}}/>`:editor?.assignment&&view?html`<${AssignmentEditor} key=${editor.assignment?.id||"new"} assignment=${editor.assignment} view=${{...view,client}} busy=${busy} onCheck=${preview} onCancel=${()=>{setEditor(null);setChecked(null);}}/>`:null}
45
- ${view?.policy?html`<section class="card"><div class="hub-role-head"><h3>${hr("assignments")}</h3>${canAssign?html`<button type="button" class="btn" disabled=${busy} onClick=${()=>{setChecked(null);setEditor({assignment:true});}}>${hr("assign")}</button>`:null}</div><p class="note">${hr("selfHelp")}</p><ul class="hub-role-list">${view.policy.assignments.map(a=>html`<li key=${a.id}><span class="grow"><strong>${name(view.policy.roles.find(r=>r.id===a.roleId))}</strong><small class="note hub-role-detail">${a.subject.kind==="person"?key(a.subject.person):a.subject.dn} · ${a.scope.kind==="hub"?hr("wholeHub"):a.scope.dn}${a.expiresAt?` · ${new Date(a.expiresAt).toLocaleString()}`:""}</small></span>${canAssign?html`<button type="button" class="btn" disabled=${busy||a.subject.kind==="person"&&key(a.subject.person)===key(view.actor)} onClick=${()=>{setChecked(null);setEditor({assignment:a});}}>${hr("edit")}</button><button type="button" class="btn" disabled=${busy||a.subject.kind==="person"&&key(a.subject.person)===key(view.actor)} onClick=${()=>{const next=copy(view.policy);next.assignments=next.assignments.filter(row=>row.id!==a.id);preview(next);}}>${hr("remove")}</button>`:null}</li>`)}</ul></section>`:null}
46
- ${checked?html`<section class="card hub-role-preview" role="region" aria-label=${hr("changes")}><h3>${hr("changes")}</h3><p>${hr("affected",checked.impact?.losingActions?.length||0)}</p><p>${hr("paused",checked.impact?.suspendedOnSave?.length||0)}</p><p>${hr("unknown",checked.impact?.held?.length||0)}</p><p class="note">${hr("noPreview")}</p><div class="hub-role-actions"><button type="button" class="btn btn-primary" disabled=${busy} onClick=${apply}>${hr(busy?"saving":"apply")}</button><button type="button" class="btn" disabled=${busy} onClick=${()=>setChecked(null)}>${hr("cancel")}</button></div></section>`:null}
47
- ${audit||auditError?html`<section class="card"><h3>${hr("audit")}</h3>${auditError?html`<p class="err" role="alert">${auditError}</p>`:null}<div class="hub-role-table-wrap"><table><thead><tr><th>${hr("when")}</th><th>${hr("who")}</th><th>${hr("action")}</th><th>${hr("result")}</th></tr></thead><tbody>${audit?.rows?.map(row=>html`<tr key=${row.id}><td data-label=${hr("when")}>${new Date(row.at).toLocaleString()}</td><td data-label=${hr("who")} title=${row.actor.id}>${row.actor.name}</td><td data-label=${hr("action")}>${row.action}${row.summary?.map(line=>html`<small class="note hub-role-detail">${line}</small>`)}</td><td data-label=${hr("result")}>${row.result}</td></tr>`)}</tbody></table></div>${!audit?.rows?.length?html`<p class="note">${hr("empty")}</p>`:null}${audit?.nextCursor?html`<button type="button" class="btn" disabled=${busy} onClick=${more}>${hr("more")}</button>`:null}</section>`:null}</div></div>`;
43
+ const [styled,setStyled]=useState(null),[styleRetry,setStyleRetry]=useState(0),[view,setView]=useState(null),[failure,setFailure]=useState(null),[busy,setBusy]=useState(false),[saved,setSaved]=useState(false),[reload,setReload]=useState(0),[tab,setTab]=useState("roles"),[page,setPage]=useState(null),[wizard,setWizard]=useState(null),[assign,setAssign]=useState(null),[settings,setSettings]=useState(false),[checked,setChecked]=useState(null);
44
+ const epoch=useRef(0),writing=useRef(false);
45
+ useEffect(()=>{let live=true;linkRoleCss().then(out=>{if(live)setStyled(out);});return()=>{live=false;};},[styleRetry]);
46
+ useEffect(()=>{let live=true;const mine=++epoch.current;setView(null);setChecked(null);setWizard(null);setAssign(null);setSettings(false);
47
+ Promise.resolve().then(()=>client.roles()).then(out=>{if(!live||mine!==epoch.current)return;if(out.ok){setView(out.view);setFailure(null);if(!out.view.policy)setTab(out.view.management.includes("audit.view")?"audit":"roles");}else setFailure(roleError(out));},()=>{if(live&&mine===epoch.current)setFailure(hr("failed"));});
48
+ const end=client.onSignedOut?.(()=>{epoch.current++;writing.current=false;setView(null);setChecked(null);setWizard(null);setAssign(null);setSettings(false);setBusy(false);setFailure(hr("denied"));});return()=>{live=false;epoch.current++;end?.();};
49
+ },[client,reload]);
50
+ const preview=async(policy,origin="page",rootSelf=false)=>{
51
+ if(writing.current)return;writing.current=true;setBusy(true);setFailure(null);setSaved(false);setChecked(null);const mine=++epoch.current;let out;try{out=rootSelf?await client.roleRootPreview():await client.rolePreview(policy);}catch{out={ok:false};}
52
+ if(mine!==epoch.current)return;writing.current=false;setBusy(false);if(out.ok)setChecked({policy,rootSelf,origin,...out});else setFailure(roleError(out,true));
53
+ };
54
+ const apply=async()=>{
55
+ if(!checked||writing.current)return;writing.current=true;setBusy(true);setFailure(null);const selected=checked,mine=++epoch.current;let out;try{out=selected.rootSelf?await client.roleRootApply(selected.previewDigest):await client.roleApply(selected.policy,selected.previewDigest);}catch{out={ok:false};}
56
+ if(mine!==epoch.current)return;writing.current=false;setBusy(false);setChecked(null);
57
+ if(out.ok){if(wizard)setPage({kind:"role",id:wizard.id});setWizard(null);setAssign(null);setSettings(false);setSaved(true);setReload(n=>n+1);}else setFailure(roleError(out,true));
58
+ };
59
+ const remember=row=>setView(previous=>({...previous,personLabels:[...(previous.personLabels||[]).filter(p=>p.id!==personKey(row.key)),{id:personKey(row.key),name:row.name}]}));
60
+ const close=()=>{if(busy)return;setChecked(null);setFailure(null);setWizard(null);setAssign(null);setSettings(false);};
61
+ const openAssign=(roleId,assignment=null)=>{setChecked(null);setFailure(null);setAssign({roleId,assignment});};
62
+ const refresh=()=>{setWizard(null);setAssign(null);setSettings(false);setChecked(null);setPage(null);setReload(n=>n+1);};
63
+ const remove=a=>{const next=copy(view.policy);next.assignments=next.assignments.filter(row=>row.id!==a.id);void preview(next);};
64
+ const root=view&&personKey(view.root)===personKey(view.actor),canEdit=!!view?.management.includes("hub.admin"),canAssign=!!view?.management.includes("roles.assign"),selectedRole=view?.policy?.roles.find(r=>r.id===page?.id);
65
+ if(styled!==true)return html`<section class="card"><p role="status">${hr(styled===false?"styleFailed":"styleLoading")}</p>${styled===false?html`<button type="button" class="btn" onClick=${()=>{setStyled(null);setStyleRetry(n=>n+1);}}>${hr("retry")}</button>`:null}</section>`;
66
+ return html`<div class="hub-roles"><p class="s-page-lead hub-page-lead">${hr("lead")}</p>
67
+ ${failure&&!assign&&!settings?html`<p class="err" role="alert">${failure}</p><button type="button" class="btn" disabled=${busy} onClick=${refresh}>${hr("reloadRoles")}</button>`:null}${saved?html`<p role="status">${hr("saved")}</p>`:null}${!view&&!failure?html`<p role="status">${hr("loading")}</p>`:null}
68
+ ${view?html`<div class="hub-role-top"><${Tabs} label=${hr("title")} items=${[...(view.policy?[{key:"roles",label:hr("roles")},{key:"people",label:hr("people")}]:[]),...(view.management.includes("audit.view")?[{key:"audit",label:hr("audit")}]:[])]} value=${tab} disabled=${busy} onChange=${key=>{setTab(key);setPage(null);setWizard(null);setChecked(null);setFailure(null);}}/>
69
+ ${canEdit?html`<details class="hub-role-menu"><summary aria-label=${hr("rolesSettings")}>⋯</summary><button type="button" class="btn" disabled=${busy} onClick=${()=>{setSettings(true);setChecked(null);setFailure(null);}}>${hr("rolesSettings")}</button></details>`:null}</div>
70
+ ${checked?.origin==="page"?html`<section class="card"><h2>${hr("review")}</h2><${Review} view=${view} checked=${checked}/><div class="hub-role-actions"><button type="button" class="btn" disabled=${busy} onClick=${()=>setChecked(null)}>${hr("back")}</button><button type="button" class=${`btn ${checked.policy?.roles.length<view.policy.roles.length?"danger":"btn-primary"}`} disabled=${busy} onClick=${apply}>${hr(busy?"saving":checked.policy?.roles.length<view.policy.roles.length?"delete":"apply")}</button></div></section>`:
71
+ wizard?html`<${RoleWizard} key=${wizard.id} view=${view} role=${wizard} checked=${checked?.origin==="wizard"?checked:null} busy=${busy} onCheck=${policy=>preview(policy,"wizard")} onApply=${apply} onBack=${()=>setChecked(null)} onCancel=${close}/>`:
72
+ tab==="audit"?html`<${RoleAudit} key=${reload} client=${client}/>`:
73
+ page?.kind==="person"?html`<${PersonRoles} view=${view} subject=${page.subject} busy=${busy} onBack=${()=>setPage(null)} onEdit=${a=>openAssign(a.roleId,a)} onRemove=${remove}/>`:
74
+ selectedRole?html`<${RolePage} key=${selectedRole.id} view=${view} role=${selectedRole} busy=${busy} canEdit=${canEdit} canAssign=${canAssign} onBack=${()=>setPage(null)} onPerson=${subject=>setPage({kind:"person",subject})} onAssign=${()=>openAssign(selectedRole.id)} onEdit=${()=>{setChecked(null);setWizard(selectedRole);}} onDelete=${()=>{const next=copy(view.policy);next.roles=next.roles.filter(r=>r.id!==selectedRole.id);next.assignments=next.assignments.filter(a=>a.roleId!==selectedRole.id);preview(next);}}/>`:
75
+ tab==="people"?html`<${People} view=${view} busy=${busy} onOpen=${subject=>setPage({kind:"person",subject})} onAssign=${canAssign?()=>openAssign(null):null}/>`:
76
+ view.policy?html`<${RoleList} view=${view} busy=${busy} canEdit=${canEdit} canAssign=${canAssign} onOpen=${id=>setPage({kind:"role",id})} onAssign=${openAssign} onCreate=${()=>{setFailure(null);setWizard({id:"custom:"+crypto.randomUUID(),kind:"custom",name:"",description:"",permissions:[],defaultMaxFleets:0});}}/>`:html`<p class="note">${hr("noPolicy")}</p>`}
77
+ ${root&&!view.rootSelfUsed&&!wizard&&!checked&&tab==="roles"&&!page?html`<aside class="s-info hub-role-root-notice"><p>${hr("rootHelp")}</p><button type="button" class="btn btn-sm" disabled=${busy} onClick=${()=>preview(null,"page",true)}>${hr("rootDefaults")}</button></aside>`:null}
78
+ ${assign?html`<${AssignPanel} view=${view} client=${client} roleId=${assign.roleId} assignment=${assign.assignment} checked=${checked?.origin==="assign"?checked:null} busy=${busy} failure=${failure} onReload=${refresh} onCheck=${policy=>preview(policy,"assign")} onApply=${apply} onBack=${()=>setChecked(null)} onClose=${close} onRemember=${remember}/>`:null}
79
+ ${settings?html`<${Dialog} title=${checked?hr("review"):hr("rolesSettings")} busy=${busy} onClose=${close} wide=${true} cls="hub-role-panel" actions=${checked?html`<button type="button" class="btn" disabled=${busy} onClick=${()=>setChecked(null)}>${hr("back")}</button><button type="button" class="btn btn-primary" disabled=${busy} onClick=${apply}>${hr("apply")}</button>`:null}>
80
+ ${failure?html`<p class="err" role="alert">${failure}</p><button type="button" class="btn" disabled=${busy} onClick=${refresh}>${hr("reloadRoles")}</button>`:null}${checked?html`<${Review} view=${view} checked=${checked}/>`:html`<div class="hub-role-status"><p><span class=${`tag ${view.policy.rolesActive?"ok":"warn"}`}>${hr(view.policy.rolesActive?"on":"off")}</span></p><p>${hr("offHelp")}</p>${view.policy.state==="never-enabled"?html`<p class="s-info">${hr("selfLegacy")}</p>`:view.policy.state==="suspended"?html`<p class="s-info">${hr("selfPaused")}</p>`:null}<button type="button" class="btn" disabled=${busy} onClick=${()=>{const next=copy(view.policy);next.rolesActive=!next.rolesActive;preview(next,"settings");}}>${hr(view.policy.rolesActive?"turnOff":"turnOn")}</button>
81
+ <h3>${hr("firstAdmin")}</h3><p>${personName(view,view.root)}</p><p class="note">${hr("firstAdminHelp")}</p><a class="btn" href="/ui/hub/admin?view=allowed-list">${hr("openAllowedList")}</a></div>`}</${Dialog}>`:null}`:null}
82
+ </div>`;
48
83
  }
@@ -1,3 +1,4 @@
1
+ import {hp} from "./hub-personal-agent-strings.js";
1
2
  // M-3092 PR 2 (Hub rooms, track U): a room's composer — the Fleet chat's own ComposerInput, its palette (`cmd-palette`)
2
3
  // and its reply bar (`reply-bar`), with what a room adds (docs/design/hub-rooms-ux.md §4):
3
4
  // - typing `@` opens a menu: 「@所有 Agent」 (when this room lets me), 「@房間助理」 (when the room has one), each agent
@@ -40,7 +41,7 @@ export function mentionOptions(detail, query = "") {
40
41
  out.push({ kind: "all", key: "all", label: hroom("mentionAll"), hint: hroom("mentionAllHint", String(agents.length)) });
41
42
  if ((detail?.members || []).some((m) => m.kind === "assistant") && hit(hroom("mentionAssistant")))
42
43
  out.push({ kind: "assistant", key: "assistant", label: hroom("mentionAssistant"), hint: hroom("mentionAssistantHint") });
43
- for (const a of agents) if (hit(a.name, a.owner?.name)) out.push({ kind: "agent", key: a.id, label: `@${a.name}`, hint: a.owner?.name || "", dot: presenceDot(a.presence, a.presenceReason) });
44
+ for (const a of agents) if (hit(a.name, a.owner?.name)) out.push({ kind: "agent", key: a.id, label: `@${a.name}`, ...(a.answerOnly?{answerOnly:true}:{}), hint: a.answerOnly ? hp("answerOnlyAsker") : a.owner?.name || "", dot: presenceDot(a.presence, a.presenceReason) });
44
45
  for (const p of (detail?.members || []).filter((m) => m.kind === "person" && m.id !== detail?.me?.id)) if (hit(p.name)) out.push({ kind: "person", key: p.id, label: `@${p.name}`, hint: "" });
45
46
  return out;
46
47
  }
@@ -116,7 +117,7 @@ export function RoomComposer({ store, detail, reply = null, onReply = () => {},
116
117
  ${palette ? html`<ul data-trust="palette" class="cmd-palette" id=${paletteId} role="listbox" aria-label=${hroom("mentionAll")}>
117
118
  ${palette.map((o) => html`<li key=${o.key} id=${optId(o)} role="option" aria-selected=${o === chosen ? "true" : "false"} class=${o === chosen ? "on" : ""}
118
119
  onMouseDown=${(e) => { e.preventDefault(); complete(o); }}>
119
- <span class="cmd-name">${o.dot ? html`<span class=${`dot ${o.dot}`} aria-hidden="true"></span> ` : null}${o.label}</span><span class="cmd-desc">${o.hint}</span></li>`)}
120
+ <span class="cmd-name">${o.dot ? html`<span class=${`dot ${o.dot}`} aria-hidden="true"></span> ` : null}${o.label}</span><span class=${`cmd-desc${o.answerOnly?" hub-answer-only-note":""}`}>${o.hint}</span></li>`)}
120
121
  </ul>` : null}
121
122
  ${group && value.includes(hroom("mentionAll")) ? html`<p class="note hub-room-allbar" role="status">${allBar(detail)}</p>` : null}
122
123
  ${reply ? html`<div class="reply-bar" data-trust="composer" role="status"><span class="reply-text">${reply.sender ? `${reply.sender} · ` : ""}${String(reply.text || "").slice(0, 80)}</span>
@@ -1,3 +1,4 @@
1
+ import {hp} from "./hub-personal-agent-strings.js";
1
2
  // M-3092 (Hub rooms, track U): the Hub's conversation list, drawn as the Fleet chat draws its roster — the same row
2
3
  // (`li.v-li > a.inst.v-inst`: avatar with its status dot, the name line and the second line), the same section head
3
4
  // (`inst-head > side-label`, its count) and the same count badge (`nav-count`). docs/design/hub-rooms-ux.md §2:
@@ -29,7 +30,7 @@ export function listRoomOf(item) {
29
30
  if (!item || typeof item !== "object" || typeof item.id !== "string") return null;
30
31
  return { id: item.id, kind: "direct", name: String(item.exposureName || ""), people: 1, agents: 1, online: null, unread: 0,
31
32
  lastAt: Number.isFinite(item.lastAt) ? item.lastAt : 0, lastText: "", lastAuthor: "",
32
- agent: { exposureId: String(item.exposureId || ""), owner: { name: String(item.ownerName || "") }, presence: null }, limited: true, legacy: item };
33
+ agent: { ...(item.answerOnly?{answerOnly:true}:{}), exposureId: String(item.exposureId || ""), owner: { name: String(item.ownerName || "") }, presence: null }, limited: true, legacy: item };
33
34
  }
34
35
  /** The rooms list from whichever client this page has: roomList() when it can, else rooms() mapped by listRoomOf(). */
35
36
  export function readRoomList(client) {
@@ -72,7 +73,7 @@ export function rowView(r) {
72
73
  const closed = limited && r.legacy?.state === "closed", waiting = limited && !closed && r.legacy?.waiting === true;
73
74
  const line2 = group ? countsLine(r.people, r.agents)
74
75
  : closed ? t("hubChat.tagClosed") : waiting ? t("hubChat.waiting")
75
- : r.assistant ? tr("providedByHub") : String(r.agent?.owner?.name || "");
76
+ : r.assistant ? tr("providedByHub") : r.agent?.answerOnly ? hp("answerOnlyAsker") : String(r.agent?.owner?.name || "");
76
77
  return {
77
78
  title: r.assistant ? tr("hubAssistant") : String(r.name || ""), line2,
78
79
  avatar: { square: group, text: firstCharacter(r.assistant ? tr("hubAssistant") : String(r.name || "?")) || "?" },
@@ -131,7 +132,7 @@ export function HubRoomRows({ rooms, q = "", current = null, href, onGo, star =
131
132
  <span class=${`av${v.avatar.square ? " av-square" : ""}`}><span class="av-text" aria-hidden="true">${v.avatar.text}</span>${v.dot
132
133
  ? html`<span class=${`av-dot dot ${v.dot}`} aria-hidden="true"></span>` : null}</span>
133
134
  <span class="inst-text"><span class="inst-line"><span class="inst-name" title=${v.title}>${v.title}</span><span class="v-meta">${listTime(r.lastAt)}</span></span>
134
- <span class="inst-line inst-line2"><span class="inst-alt" title=${v.line2 || undefined}>${v.archived ? `${tr("archived")} · ${v.line2}` : v.line2}</span>
135
+ <span class="inst-line inst-line2"><span class=${`inst-alt${r.agent?.answerOnly?" hub-answer-only-note":""}`} title=${v.line2 || undefined}>${v.archived ? `${tr("archived")} · ${v.line2}` : v.line2}</span>
135
136
  ${v.mentioned ? html`<span class="hub-room-at" title=${tr("mentionedYou")}>@</span>` : null}
136
137
  ${v.unread ? html`<span class="nav-count" title=${tr("unreadN", String(v.unread))}>${v.unread > 99 ? "99+" : v.unread}</span>` : null}</span></span>
137
138
  </a>${items.length ? html`<${Menu} cls=${`inst-workspace inst-row-menu agent-menu${starred ? " is-favorite" : ""}`} fit=${true} topLayer=${true}
@@ -9,6 +9,7 @@ import { hm } from "./hub-room-members-strings.js";
9
9
  import { hroom } from "./hub-room-strings.js";
10
10
  import { collapse, headerCounts, presenceDot, presenceView, sortAgents } from "./hub-room-presence.js";
11
11
  import { hn, linkRoomsU2Css } from "./hub-room-new-strings.js";
12
+ import { roomSource, RoomSourceMark } from "./hub-room-source.js";
12
13
 
13
14
  linkRoomsU2Css();
14
15
 
@@ -75,7 +76,7 @@ export function RoomMembersPanel({ client = hubClient(), roomId, detail, onMenti
75
76
  // An agent's second line names whose it is beside its state (「處理中 · 林小華的 Agent」), always shown, not only on hover.
76
77
  const row = (m, extra = null) => {
77
78
  const v = memberStatus(m), owner = (m.kind === "agent" || m.kind === "later") && m.owner?.name ? (v.update ? hm("askOwner", m.owner.name) : ownerAgent(m.owner.name)) : "";
78
- return html`<span class="hub-member-name">${m.name}${extra}</span><span class="hub-member-state"><span class=${`dot ${v.dot}`} aria-hidden="true"></span><span>${v.text}</span>${owner ? html`<span class="hub-member-owner">· ${owner}</span>` : null}</span>`;
79
+ return html`<span class="hub-member-name"><${RoomSourceMark} source=${roomSource(m)} decorative=${true} />${m.name}${extra}</span><span class="hub-member-state"><span class=${`dot ${v.dot}`} aria-hidden="true"></span><span>${v.text}</span>${owner ? html`<span class="hub-member-owner">· ${owner}</span>` : null}</span>`;
79
80
  };
80
81
  return html`<aside class="hub-room-members">
81
82
  <section><h4>${heads.member}</h4>
@@ -84,9 +85,10 @@ export function RoomMembersPanel({ client = hubClient(), roomId, detail, onMenti
84
85
  ${agents.length ? null : html`<section class="hub-room-no-agents"><h4>${hm("agents")}</h4><p class="note">${hm("noAgents")}</p></section>`}
85
86
  ${agents.length ? html`<section><h4>${heads.agent}</h4>
86
87
  <ul>${shown.map(m => html`<li class="hub-member hub-member-agent" key=${m.id}>
87
- <button type="button" class="hub-member-open" title=${m.owner?.name ? hm("ownerOf", m.owner.name) : ""} aria-expanded=${open === m.id} onClick=${() => { setFailed(false); setOpen(open === m.id ? null : m.id); }}>${row(m)}</button>
88
+ <button type="button" class="hub-member-open" title=${roomSource(m)?.label || ""} aria-label=${`${m.name}. ${memberStatus(m).text}. ${roomSource(m)?.label || ""}`} aria-expanded=${open === m.id} onClick=${() => { setFailed(false); setOpen(open === m.id ? null : m.id); }}>${row(m)}</button>
88
89
  ${open === m.id ? html`<div class="hub-member-card" role="group" aria-label=${m.name}>
89
90
  <strong>${m.name}</strong>${m.owner?.name ? html`<small class="note">${hm("ownerOf", m.owner.name)}</small>` : null}
91
+ <small class="note hub-source-explanation">${roomSource(m)?.label}</small>
90
92
  <small class="note">${memberStatus(m).text}</small>
91
93
  <div class="field-row">
92
94
  <button type="button" class="btn" onClick=${() => { setOpen(null); onMention?.(m); }}>${hroom("mentionHere")}</button>
@@ -14,6 +14,7 @@ import { confirmDialog } from "/assets/ui-confirm.js";
14
14
  import { hubClient } from "./hub-client.js";
15
15
  import { hroom } from "./hub-room-strings.js";
16
16
  import { hs } from "./hub-room-settings-strings.js";
17
+ import {ha} from "./hub-ai-apps-strings.js";
17
18
  import { RoomPicker } from "./hub-room-new.js";
18
19
  import { hn, linkRoomsU2Css } from "./hub-room-new-strings.js";
19
20
 
@@ -42,10 +43,13 @@ export function RoomSettings({ client = hubClient(), roomId, detail, onClose, on
42
43
  const invited = Array.isArray(detail?.invited) ? detail.invited : [];
43
44
  const [name, setName] = useState(room.name ?? ""), [busy, setBusy] = useState(false), [error, setError] = useState("");
44
45
  const [allMention, setAllMention] = useState(settings.allMention !== false), [history, setHistory] = useState(settings.historyForNew === "all" ? "all" : "since-join");
46
+ const [aiApps,setAiApps]=useState(settings.aiApps!==false);
47
+ const [aiAppsScope]=useState(()=>client.aiAppsScope?.());
45
48
  const [offered, setOffered] = useState(assistant === true), [addPeople, setAddPeople] = useState([]), [addAgents, setAddAgents] = useState([]), [peopleNote, setPeopleNote] = useState("");
46
49
  const live = useRef(true);
47
50
  useEffect(() => () => { live.current = false; }, []);
48
51
  useEffect(() => { setName(room.name ?? ""); setAllMention(settings.allMention !== false); setHistory(settings.historyForNew === "all" ? "all" : "since-join"); }, [detail]);
52
+ useEffect(()=>setAiApps(settings.aiApps!==false),[detail]);
49
53
  useEffect(() => {
50
54
  if (typeof assistant === "boolean") { setOffered(assistant); return; }
51
55
  void client.roomList().then(r => { if (live.current) setOffered(r?.ok === true && r.me?.assistant === true); });
@@ -108,6 +112,8 @@ export function RoomSettings({ client = hubClient(), roomId, detail, onClose, on
108
112
  </form>
109
113
  <label class="check"><input id="hubRoomAllMention" class="s-ui-toggle" type="checkbox" role="switch" checked=${allMention} disabled=${busy}
110
114
  onChange=${(e) => { const v = e.target.checked; setAllMention(v); void act(() => client.updateRoom(roomId, { allMention: v }), () => setAllMention(!v)); }} /><span>${hroom("membersCanAll")}</span></label>
115
+ ${typeof settings.aiApps==="boolean"&&typeof client.setRoomAiApps==="function"?html`<label class="check"><input id="hubRoomAiApps" class="s-ui-toggle" type="checkbox" role="switch" checked=${aiApps} disabled=${busy}
116
+ onChange=${e=>{const value=e.target.checked;setAiApps(value);void act(()=>client.setRoomAiApps(aiAppsScope,roomId,value),()=>setAiApps(!value));}}/><span>${ha("roomSwitch")}</span></label>`:null}
111
117
  <fieldset class="field"><legend>${hroom("newMembersSee")}</legend>
112
118
  ${[["since-join", hroom("historyAfter")], ["all", hroom("historyAll")]].map(([value, label]) => html`<label class="check" key=${value}><input type="radio" name="hubRoomHistory" value=${value} checked=${history === value} disabled=${busy}
113
119
  onChange=${() => { const old = history; setHistory(value); void act(() => client.updateRoom(roomId, { historyForNew: value }), () => setHistory(old)); }} /><span>${label}</span></label>`)}
@@ -0,0 +1,17 @@
1
+ import { register, t } from "/assets/app-i18n.js";
2
+
3
+ register("hubRoomSource", {
4
+ en: {
5
+ agend: "AgEnD agent",
6
+ fleet: "An agent in {0}'s Fleet",
7
+ personal: "{0}'s personal agent",
8
+ app: 'Posted by {0} through an AI app. The app gave the name "{1}" itself.',
9
+ },
10
+ "zh-TW": {
11
+ agend: "AgEnD Agent",
12
+ fleet: "{0} 的 Fleet 裡的 Agent",
13
+ personal: "{0} 的個人 Agent",
14
+ app: "由 {0} 透過 AI App 發出。「{1}」是 App 自己提供的名稱。",
15
+ },
16
+ });
17
+ export const hsource = (key, ...args) => t(`hubRoomSource.${key}`, ...args);
@@ -0,0 +1,34 @@
1
+ // Display only: an app's registered name never establishes a vendor identity or room membership.
2
+ import { html, render } from "/assets/app-html.js";
3
+ import { Icon } from "/assets/ui-icons.js";
4
+ import { toast } from "/assets/ui-toast.js";
5
+ import { hsource } from "./hub-room-source-strings.js";
6
+
7
+ export function roomSource(author) {
8
+ if (!author) return null;
9
+ if (author.via?.kind === "app") return { kind: "app", label: hsource("app", String(author.name || ""), String(author.via.name || "")) };
10
+ const agent = author.kind === "agent" || author.kind === "later";
11
+ if (!agent && author.via?.kind !== "agent") return null;
12
+ const owner = agent ? author.owner?.name : author.name;
13
+ const label = owner && author.agentKind ? hsource(author.agentKind === "personal" ? "personal" : "fleet", String(owner)) : hsource("agend");
14
+ return { kind: "agend", label };
15
+ }
16
+
17
+ export function RoomSourceMark({ source, decorative = false }) {
18
+ if (!source) return null;
19
+ return html`<span class="hub-source-mark" data-room-source=${source.kind} role=${decorative ? undefined : "img"}
20
+ aria-hidden=${decorative ? "true" : undefined} aria-label=${decorative ? undefined : source.label} title=${source.label}>
21
+ ${source.kind === "agend" ? html`<img src="/assets/agend-mark.svg" width="16" height="16" alt="" aria-hidden="true" />` : html`<${Icon} name="view" size=${16} />`}
22
+ </span>`;
23
+ }
24
+
25
+ /** Stateless island inside the shared thread's sender node. No raw markup comes from the message. */
26
+ export function mountSourceAuthor(sender, message) {
27
+ const source = message?.sourceBadge;
28
+ if (!sender || !source) return;
29
+ sender.textContent = "";
30
+ render(html`<button type="button" class="hub-source-trigger" title=${source.label}
31
+ aria-label=${`${message.sender}. ${source.label}`} onClick=${() => toast(source.label, true, { detail: true })}>
32
+ <${RoomSourceMark} source=${source} decorative=${true} /><span>${message.sender}</span>
33
+ </button>`, sender);
34
+ }
@@ -1,3 +1,4 @@
1
+ import {hp} from "./hub-personal-agent-strings.js";
1
2
  // M-3092 PR 2 (Hub rooms, track U): one room of a Hub with rooms, on the Fleet chat's own thread (/assets/chat-thread.js
2
3
  // through panel-hub.js's HubThread). docs/design/hub-rooms-ux.md §3 says only where a room differs from the Fleet chat:
3
4
  // - every message says who wrote it — a person by name (mine: on the right, no name), an agent as 「name · owner 的 Agent」,
@@ -20,12 +21,14 @@ import { register, t } from "/assets/app-i18n.js";
20
21
  import "./hub-strings.js";
21
22
  import { firstCharacter } from "/assets/instance-nav.js";
22
23
  import { hroom } from "./hub-room-strings.js";
24
+ import {ha} from "./hub-ai-apps-strings.js";
23
25
  import { RoomComposer } from "./hub-room-composer.js";
24
26
  import { TextSizeButton } from "/assets/header-tools.js";
25
27
  import { HubNotifyToggle } from "./hub-room-notify.js";
26
28
  import { createHubButtonActions } from "./hub-button-actions.js";
27
29
  import { linkRoomsU2Css } from "./hub-room-new-strings.js";
28
30
  import { workingLine } from "./hub-room-working.js";
31
+ import { roomSource, mountSourceAuthor } from "./hub-room-source.js";
29
32
  import { countsLine } from "./hub-room-list.js";
30
33
  import { PendingFiles, hf, hubFileAttachment, pageCarriesFiles, roomTakesFiles, uploadChosen } from "./hub-attachments.js";
31
34
  import { LightboxHost, openLightbox } from "/assets/image-lightbox.js";
@@ -62,6 +65,7 @@ export function authorLine(author, mine = false, direct = false) {
62
65
  */
63
66
  const SYSTEM = { "room-created": "createdSys", "member-joined": "sysJoined", "admin-joined": "sysAdminJoined", "poll-closed": "sysPollClosed" };
64
67
  export function systemText(m) {
68
+ if(m?.system?.kind==="app-rate-limited")return ha("rateLimited",m.system.name||"");
65
69
  if (m?.system?.kind === "agent-mention-stopped") return agentStopText(m.system) ?? String(m.text || "");
66
70
  const key = m && m.system && SYSTEM[m.system.kind];
67
71
  return key && typeof m.system.name === "string" ? hroom(key, m.system.name) : String((m && m.text) || "");
@@ -158,8 +162,9 @@ export function toThreadMessages(messages, { meId, ids, direct = false, expanded
158
162
  // The quote chip keeps a stable key even when that original is not in this page (scroll-up / findQuoted loads it).
159
163
  const quotedId = m.replyTo || m.answerTo || "";
160
164
  const quoted = quotedId ? byId.get(quotedId) : null;
161
- const state = askState(askOf(m, messages));
165
+ const state = askState(askOf(m, messages)), sourceBadge = roomSource(author);
162
166
  out.push({ boot: BOOT, id, role: kind === "person" && !author.via ? "user" : "agent", sender: authorLine(author, mine, direct), ts: iso(m.at), text: String(m.text || ""), mine,
167
+ ...(sourceBadge ? { sourceBadge } : {}),
163
168
  ...(kind === "person" && !mine && !author.via ? { person: true } : {}), // Lumen (spec §3): someone else's words, a bubble on the left
164
169
  roomMessage: m.id, ...(mine && state?.delivery ? { delivery: state.delivery } : {}),
165
170
  // M-3125: a post's files, as the 1:1 chat maps them (images inline through the Hub's own route; HTML gets its preview card).
@@ -434,6 +439,7 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
434
439
  const labels = () => [hroom("mentionAll"), hroom("mentionAssistant"), ...(store.detail()?.members || []).filter((m) => m.kind !== "assistant").map((m) => `@${m.name}`)];
435
440
  const extra = {
436
441
  isUser: (x) => x.mine === true, canReply: () => !store.closed(),
442
+ senderBadge: mountSourceAuthor,
437
443
  mentionLabels: labels,
438
444
  // A line's one action: 「展開其餘 N 則」, or 「請房間助理整理」 (spec §10: the same as sending 「@房間助理 整理上面的回答」).
439
445
  statusAction: (arg) => { if (String(arg).startsWith("summarise:")) { if (!store.closed()) void store.send(hroom("summarisePrompt"), { mentions: ["assistant"] }); } else store.expand(arg); },
@@ -451,7 +457,7 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
451
457
  openImage: (links, img) => openLightbox(links, img, annotateRef.current(img)),
452
458
  };
453
459
  const line2 = group ? `${countsLine(room.people, room.agents)}${hasAssistant ? ` · ${hroom("roomAssistant")}` : ""}`
454
- : room.assistant ? hroom("providedByHub") : String(room.agent?.owner?.name || "");
460
+ : room.assistant ? hroom("providedByHub") : room.agent?.answerOnly ? hp("answerOnlyAsker") : String(room.agent?.owner?.name || "");
455
461
  const showRail = wide && rail && Panel && group && detail;
456
462
  // The Fleet chat's working bar (Lumen): 「Notes 正在處理」, or 「2 個 Agent 正在處理」 — the answer row only when it arrives.
457
463
  // Who: this room's answers being worked on; the words: workingLine() (#3857), the one place that says it.
@@ -463,12 +469,12 @@ export function HubRoomPage({ roomId, listed = null, Thread, client, meId = "",
463
469
  return html`<div class=${`hub-chat hub-room-page${showRail ? " with-rail" : ""}`} data-room=${roomId}>
464
470
  <${LightboxHost} />
465
471
  <section class="hub-chat-main">
466
- <header class="hub-chat-head" data-trust="panel-content">
472
+ <header class=${`hub-chat-head${room.agent?.answerOnly?" hub-answer-only-head":""}`} data-trust="panel-content">
467
473
  ${/* Lumen (spec §2): on a phone the header starts with the Fleet chat's back to the list. */ ""}
468
474
  <a class="icon-btn hub-back only-narrow" href="/ui/hub" aria-label=${t("hub.back")} title=${t("hub.back")}
469
475
  onClick=${(e) => { if (e.metaKey || e.ctrlKey) return; e.preventDefault(); goList(); }}><${Icon} name="back" /></a>
470
476
  <span class=${`av${group ? " av-square" : ""}`} aria-hidden="true"><span class="av-text">${firstCharacter(title || "?") || "?"}</span></span>
471
- <span class="hub-chat-title"><strong>${title}</strong><span class="s">${line2}</span></span>
477
+ <span class="hub-chat-title"><strong>${title}</strong><span class=${`s${room.agent?.answerOnly?" hub-answer-only-note":""}`}>${line2}</span></span>
472
478
  <span class="hub-head-tools"><${TextSizeButton} /><${HubNotifyToggle} /></span>
473
479
  ${group && Panel ? html`<button type="button" class="icon-btn hub-room-rail-toggle" aria-pressed=${(wide ? rail : sheet) ? "true" : "false"} title=${hroom("members")} aria-label=${hroom("members")}
474
480
  onClick=${() => (wide ? setRail(!rail) : setSheet(true))}><${Icon} name="team" size=${18} /></button>` : null}
@@ -689,7 +689,7 @@ export function threadsToLetGo(kept, current, { keep, maxNodes, favorites, prote
689
689
  }
690
690
  return out;
691
691
  }
692
- const narrowScreen = () => typeof matchMedia === "function" && matchMedia("(max-width: 899px)").matches;
692
+ const narrowScreen = () => typeof matchMedia === "function" && matchMedia("(max-width: 899px), (pointer: coarse) and (max-height: 500px) and (max-width: 1023px)").matches;
693
693
  /**
694
694
  * M-3167: the composer's own model picker and context ring, below this width. The header's chips give way to them
695
695
  * there (chat-work-bar.css, the same width), so the model is always in one place and never under the agent's tabs.
@@ -944,7 +944,7 @@ function Dock({ name, inst, lease, exec, awaiting, workingLabel, bindings, ids,
944
944
  const s = store.state;
945
945
  // M-3166 (Argon 0): a phone's one line above the box — model · effort · context, or what the agent is doing — instead of
946
946
  // the working bar; the line under the box goes with it (its Not verified is this line's right end).
947
- const metaLine = useMedia("(max-width: 899px)") && !guestPage();
947
+ const metaLine = useMedia("(max-width: 899px), (pointer: coarse) and (max-height: 500px) and (max-width: 1023px)") && !guestPage();
948
948
  return html`<div data-trust="composer" class="dock"><div class="dock-col">
949
949
  <${Prompts} name=${name} />
950
950
  <${SubagentProgress} name=${name} />
@@ -997,7 +997,7 @@ function modelDescription(o, name) {
997
997
  * so in the menu and keeps the list (M-2731); a refused switch (no list with it) is the card's.
998
998
  */
999
999
  function ModelMenu({ name, c, lease }) {
1000
- const narrow = useMedia("(max-width: 899px)");
1000
+ const narrow = useMedia("(max-width: 899px), (pointer: coarse) and (max-height: 500px) and (max-width: 1023px)");
1001
1001
  const close = () => store.dismissCommand(name);
1002
1002
  const alive = () => lease.current();
1003
1003
  const run = (args, action) => store.runCommand(name, "model", args, { alive, ...(action ? { action } : {}) });
@@ -1252,7 +1252,7 @@ function Composer({ name, inst, label = name, lease, busy, bindings, ids = {}, f
1252
1252
  // with nothing typed, Send is Stop (typed: Send again, and Stop is the status line's).
1253
1253
  // M-3167: both read live, so a window resized across them redraws (read once, a phone's ring and picker stayed on a
1254
1254
  // desk, unstyled). Between the phone's width and a wide desk the composer has the ring and a short model chip too.
1255
- const narrow = useMedia("(max-width: 899px)"), toolsHere = useMedia(COMPOSER_TOOLS_Q);
1255
+ const narrow = useMedia("(max-width: 899px), (pointer: coarse) and (max-height: 500px) and (max-width: 1023px)"), toolsHere = useMedia(COMPOSER_TOOLS_Q);
1256
1256
  const phone = narrow && !guestPage();
1257
1257
  const stopNow = phone && busy && !content;
1258
1258
  // A file waiting: what goes is a message with its file, never a command (no palette, no command line). #2855: a guest's
@@ -145,7 +145,7 @@ function useLoad(lease, path, version) {
145
145
  * memory warning), all six tabs and the header's tools. Otherwise the tabs are the row under the header, as before —
146
146
  * never clipped, never squeezed. The natural widths are the same in either place, so the answer does not flip-flop.
147
147
  */
148
- const NARROW = "(max-width: 899px)";
148
+ const NARROW = "(max-width: 899px), (pointer: coarse) and (max-height: 500px) and (max-width: 1023px)";
149
149
  export function tabsFit(m) { return m.title + m.tabs + m.tools + m.gaps <= m.room + 0.5; }
150
150
  export function measureTabsFit(root) {
151
151
  const head = root?.querySelector(".panel-head");
@@ -170,11 +170,11 @@ export function measureTabsFit(root) {
170
170
  }
171
171
  /** M-3166: whether this is a phone's width (under 900 px), kept current as the window is resized. */
172
172
  function usePhoneWidth() {
173
- const read = () => typeof matchMedia === "function" && matchMedia("(max-width: 899px)").matches;
173
+ const read = () => typeof matchMedia === "function" && matchMedia("(max-width: 899px), (pointer: coarse) and (max-height: 500px) and (max-width: 1023px)").matches;
174
174
  const [on, setOn] = useState(read);
175
175
  useEffect(() => {
176
176
  if (typeof matchMedia !== "function") return undefined;
177
- const mq = matchMedia("(max-width: 899px)"), changed = () => setOn(mq.matches);
177
+ const mq = matchMedia("(max-width: 899px), (pointer: coarse) and (max-height: 500px) and (max-width: 1023px)"), changed = () => setOn(mq.matches);
178
178
  changed(); mq.addEventListener?.("change", changed);
179
179
  return () => mq.removeEventListener?.("change", changed);
180
180
  }, []);