@songsid/agend 2.4.0-beta.10 → 2.4.0-beta.12

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 (298) hide show
  1. package/dist/accounts-view.d.ts +29 -0
  2. package/dist/accounts-view.js +2 -14
  3. package/dist/accounts-view.js.map +1 -1
  4. package/dist/agent-endpoint.d.ts +1 -0
  5. package/dist/agent-endpoint.js +4 -2
  6. package/dist/agent-endpoint.js.map +1 -1
  7. package/dist/auth-api.d.ts +2 -0
  8. package/dist/auth-api.js +29 -2
  9. package/dist/auth-api.js.map +1 -1
  10. package/dist/backend/claude-code.js +35 -9
  11. package/dist/backend/claude-code.js.map +1 -1
  12. package/dist/backend/codex-precaution.d.ts +7 -0
  13. package/dist/backend/codex-precaution.js +102 -0
  14. package/dist/backend/codex-precaution.js.map +1 -0
  15. package/dist/backend/codex.d.ts +1 -0
  16. package/dist/backend/codex.js +18 -0
  17. package/dist/backend/codex.js.map +1 -1
  18. package/dist/backend/grok.js +21 -6
  19. package/dist/backend/grok.js.map +1 -1
  20. package/dist/backend/types.d.ts +9 -1
  21. package/dist/backend/types.js.map +1 -1
  22. package/dist/build-provenance.json +1 -1
  23. package/dist/channel/mcp-server.js +1 -1
  24. package/dist/channel/mcp-server.js.map +1 -1
  25. package/dist/channel/mcp-tools.js +3 -1
  26. package/dist/channel/mcp-tools.js.map +1 -1
  27. package/dist/claude-install-kind.d.ts +19 -0
  28. package/dist/claude-install-kind.js +54 -0
  29. package/dist/claude-install-kind.js.map +1 -0
  30. package/dist/cli-audited.js +3 -3
  31. package/dist/cli-audited.js.map +1 -1
  32. package/dist/daemon.d.ts +5 -0
  33. package/dist/daemon.js +22 -4
  34. package/dist/daemon.js.map +1 -1
  35. package/dist/event-log.d.ts +12 -0
  36. package/dist/event-log.js +40 -0
  37. package/dist/event-log.js.map +1 -1
  38. package/dist/fleet-manager.d.ts +122 -2
  39. package/dist/fleet-manager.js +482 -27
  40. package/dist/fleet-manager.js.map +1 -1
  41. package/dist/general-knowledge/skills/hub/SKILL.md +38 -6
  42. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +16 -1
  43. package/dist/hub/admin-dashboard.js +3 -3
  44. package/dist/hub/admin-dashboard.js.map +1 -1
  45. package/dist/hub/agent-catalog-model.d.ts +276 -0
  46. package/dist/hub/agent-catalog-model.js +49 -0
  47. package/dist/hub/agent-catalog-model.js.map +1 -0
  48. package/dist/hub/agent-catalog.d.ts +137 -0
  49. package/dist/hub/agent-catalog.js +118 -0
  50. package/dist/hub/agent-catalog.js.map +1 -0
  51. package/dist/hub/agent-intro-model.d.ts +38 -0
  52. package/dist/hub/agent-intro-model.js +14 -0
  53. package/dist/hub/agent-intro-model.js.map +1 -0
  54. package/dist/hub/agent-intro-tool.d.ts +35 -0
  55. package/dist/hub/agent-intro-tool.js +83 -0
  56. package/dist/hub/agent-intro-tool.js.map +1 -0
  57. package/dist/hub/agent-intro.d.ts +31 -0
  58. package/dist/hub/agent-intro.js +51 -0
  59. package/dist/hub/agent-intro.js.map +1 -0
  60. package/dist/hub/catalog.d.ts +4 -2
  61. package/dist/hub/catalog.js +19 -3
  62. package/dist/hub/catalog.js.map +1 -1
  63. package/dist/hub/client.d.ts +3 -0
  64. package/dist/hub/client.js +47 -1
  65. package/dist/hub/client.js.map +1 -1
  66. package/dist/hub/compose/member.d.ts +19 -5
  67. package/dist/hub/compose/member.js +94 -13
  68. package/dist/hub/compose/member.js.map +1 -1
  69. package/dist/hub/compose/server.d.ts +5 -0
  70. package/dist/hub/compose/server.js +6 -1
  71. package/dist/hub/compose/server.js.map +1 -1
  72. package/dist/hub/execution/service.d.ts +1 -1
  73. package/dist/hub/execution/service.js +1 -0
  74. package/dist/hub/execution/service.js.map +1 -1
  75. package/dist/hub/http/compose.d.ts +3 -0
  76. package/dist/hub/http/compose.js +122 -15
  77. package/dist/hub/http/compose.js.map +1 -1
  78. package/dist/hub/http/schema.js +15 -0
  79. package/dist/hub/http/schema.js.map +1 -1
  80. package/dist/hub/mcp/tools.js +2 -1
  81. package/dist/hub/mcp/tools.js.map +1 -1
  82. package/dist/hub/member/agent-catalog.d.ts +28 -0
  83. package/dist/hub/member/agent-catalog.js +80 -0
  84. package/dist/hub/member/agent-catalog.js.map +1 -0
  85. package/dist/hub/member/agent-intro.d.ts +28 -0
  86. package/dist/hub/member/agent-intro.js +66 -0
  87. package/dist/hub/member/agent-intro.js.map +1 -0
  88. package/dist/hub/member/exposure-api.d.ts +3 -3
  89. package/dist/hub/member/exposure-api.js +4 -4
  90. package/dist/hub/member/exposure-api.js.map +1 -1
  91. package/dist/hub/member/exposures.d.ts +12 -4
  92. package/dist/hub/member/exposures.js +27 -13
  93. package/dist/hub/member/exposures.js.map +1 -1
  94. package/dist/hub/member/room-ask.d.ts +14 -1
  95. package/dist/hub/member/room-ask.js +76 -10
  96. package/dist/hub/member/room-ask.js.map +1 -1
  97. package/dist/hub/member/room-context-budget.d.ts +5 -0
  98. package/dist/hub/member/room-context-budget.js +34 -0
  99. package/dist/hub/member/room-context-budget.js.map +1 -0
  100. package/dist/hub/member/room-notification.d.ts +1 -1
  101. package/dist/hub/member/room-post.d.ts +6 -3
  102. package/dist/hub/member/room-post.js +9 -3
  103. package/dist/hub/member/room-post.js.map +1 -1
  104. package/dist/hub/member/sharing-journal.d.ts +252 -0
  105. package/dist/hub/member/sharing-journal.js +212 -0
  106. package/dist/hub/member/sharing-journal.js.map +1 -0
  107. package/dist/hub/member/sharing-link.d.ts +25 -0
  108. package/dist/hub/member/sharing-link.js +68 -0
  109. package/dist/hub/member/sharing-link.js.map +1 -0
  110. package/dist/hub/member/sharing-result.d.ts +6 -0
  111. package/dist/hub/member/sharing-result.js +46 -0
  112. package/dist/hub/member/sharing-result.js.map +1 -0
  113. package/dist/hub/member/sharing.d.ts +37 -0
  114. package/dist/hub/member/sharing.js +181 -0
  115. package/dist/hub/member/sharing.js.map +1 -0
  116. package/dist/hub/personal/owner-host.d.ts +6 -0
  117. package/dist/hub/personal/owner-host.js +4 -2
  118. package/dist/hub/personal/owner-host.js.map +1 -1
  119. package/dist/hub/protocol.d.ts +398 -4
  120. package/dist/hub/protocol.js +13 -5
  121. package/dist/hub/protocol.js.map +1 -1
  122. package/dist/hub/room-answer-status-model.d.ts +3 -0
  123. package/dist/hub/room-answer-status-model.js +4 -0
  124. package/dist/hub/room-answer-status-model.js.map +1 -0
  125. package/dist/hub/room-brief-model.d.ts +30 -0
  126. package/dist/hub/room-brief-model.js +37 -0
  127. package/dist/hub/room-brief-model.js.map +1 -0
  128. package/dist/hub/room-context-model.d.ts +2 -0
  129. package/dist/hub/room-context-model.js +2 -2
  130. package/dist/hub/room-context-model.js.map +1 -1
  131. package/dist/hub/room-members-model.d.ts +63 -0
  132. package/dist/hub/room-members-model.js +7 -0
  133. package/dist/hub/room-members-model.js.map +1 -0
  134. package/dist/hub/rooms/agents.d.ts +1 -0
  135. package/dist/hub/rooms/agents.js +62 -11
  136. package/dist/hub/rooms/agents.js.map +1 -1
  137. package/dist/hub/rooms/brief.d.ts +18 -0
  138. package/dist/hub/rooms/brief.js +39 -0
  139. package/dist/hub/rooms/brief.js.map +1 -0
  140. package/dist/hub/rooms/direct-view.d.ts +5 -1
  141. package/dist/hub/rooms/direct-view.js +2 -2
  142. package/dist/hub/rooms/direct-view.js.map +1 -1
  143. package/dist/hub/rooms/members-page.d.ts +33 -0
  144. package/dist/hub/rooms/members-page.js +37 -0
  145. package/dist/hub/rooms/members-page.js.map +1 -0
  146. package/dist/hub/rooms/purpose.d.ts +7 -0
  147. package/dist/hub/rooms/purpose.js +14 -0
  148. package/dist/hub/rooms/purpose.js.map +1 -0
  149. package/dist/hub/rooms/service.d.ts +43 -0
  150. package/dist/hub/rooms/service.js +80 -22
  151. package/dist/hub/rooms/service.js.map +1 -1
  152. package/dist/hub/rooms/types.d.ts +6 -1
  153. package/dist/hub/rooms.d.ts +1 -0
  154. package/dist/hub/rooms.js +9 -4
  155. package/dist/hub/rooms.js.map +1 -1
  156. package/dist/hub/runtime.d.ts +1 -1
  157. package/dist/hub/server.js +49 -1
  158. package/dist/hub/server.js.map +1 -1
  159. package/dist/hub/sharing-previous-access.d.ts +22 -0
  160. package/dist/hub/sharing-previous-access.js +93 -0
  161. package/dist/hub/sharing-previous-access.js.map +1 -0
  162. package/dist/hub/sharing-requests.d.ts +171 -0
  163. package/dist/hub/sharing-requests.js +311 -0
  164. package/dist/hub/sharing-requests.js.map +1 -0
  165. package/dist/hub/sharing-retention.d.ts +47 -0
  166. package/dist/hub/sharing-retention.js +83 -0
  167. package/dist/hub/sharing-retention.js.map +1 -0
  168. package/dist/hub/sharing-withdrawal.d.ts +14 -0
  169. package/dist/hub/sharing-withdrawal.js +28 -0
  170. package/dist/hub/sharing-withdrawal.js.map +1 -0
  171. package/dist/hub/types.d.ts +13 -5
  172. package/dist/hub-page-sharing-settings.d.ts +6 -0
  173. package/dist/hub-page-sharing-settings.js +19 -0
  174. package/dist/hub-page-sharing-settings.js.map +1 -0
  175. package/dist/hub-room-reply-warning.d.ts +2 -0
  176. package/dist/hub-room-reply-warning.js +16 -0
  177. package/dist/hub-room-reply-warning.js.map +1 -0
  178. package/dist/hub-sharing-notice.d.ts +43 -0
  179. package/dist/hub-sharing-notice.js +34 -0
  180. package/dist/hub-sharing-notice.js.map +1 -0
  181. package/dist/instance-lifecycle.d.ts +15 -0
  182. package/dist/instance-lifecycle.js +36 -1
  183. package/dist/instance-lifecycle.js.map +1 -1
  184. package/dist/locale.js +78 -0
  185. package/dist/locale.js.map +1 -1
  186. package/dist/login-controller.d.ts +26 -0
  187. package/dist/login-controller.js +72 -2
  188. package/dist/login-controller.js.map +1 -1
  189. package/dist/login-flows.js +1 -1
  190. package/dist/login-flows.js.map +1 -1
  191. package/dist/native-mcp.js +1 -1
  192. package/dist/native-mcp.js.map +1 -1
  193. package/dist/needs-you-hub.js +1 -1
  194. package/dist/needs-you-hub.js.map +1 -1
  195. package/dist/needs-you.d.ts +8 -1
  196. package/dist/needs-you.js +6 -0
  197. package/dist/needs-you.js.map +1 -1
  198. package/dist/office-share-page.js +1 -1
  199. package/dist/office-share-page.js.map +1 -1
  200. package/dist/outbound-handlers.d.ts +2 -1
  201. package/dist/outbound-handlers.js +17 -4
  202. package/dist/outbound-handlers.js.map +1 -1
  203. package/dist/outbound-schemas.d.ts +10 -0
  204. package/dist/outbound-schemas.js +3 -1
  205. package/dist/outbound-schemas.js.map +1 -1
  206. package/dist/public-web-gateway.js +9 -3
  207. package/dist/public-web-gateway.js.map +1 -1
  208. package/dist/remote-card-answer.d.ts +1 -1
  209. package/dist/remote-card-answer.js +8 -1
  210. package/dist/remote-card-answer.js.map +1 -1
  211. package/dist/remote-card-prompt.js +1 -1
  212. package/dist/remote-card-prompt.js.map +1 -1
  213. package/dist/restart-progress.d.ts +6 -0
  214. package/dist/restart-progress.js +5 -0
  215. package/dist/restart-progress.js.map +1 -1
  216. package/dist/settings-api.d.ts +1 -0
  217. package/dist/settings-api.js +84 -10
  218. package/dist/settings-api.js.map +1 -1
  219. package/dist/settings-baseline.d.ts +3 -0
  220. package/dist/settings-baseline.js +2 -2
  221. package/dist/settings-baseline.js.map +1 -1
  222. package/dist/settings-change.js +1 -0
  223. package/dist/settings-change.js.map +1 -1
  224. package/dist/settings-effect.d.ts +3 -0
  225. package/dist/settings-effect.js +33 -2
  226. package/dist/settings-effect.js.map +1 -1
  227. package/dist/tool-permissions.js +3 -3
  228. package/dist/tool-permissions.js.map +1 -1
  229. package/dist/ui/chat-quote.js +3 -261
  230. package/dist/ui/fleet-office-card.js +8 -4
  231. package/dist/ui/fleet-office-pack.d.ts +1 -0
  232. package/dist/ui/fleet-office-pack.js +6 -2
  233. package/dist/ui/fleet-office-play.js +84 -0
  234. package/dist/ui/fleet-office-store.js +23 -0
  235. package/dist/ui/fleet-office-zones.js +5 -1
  236. package/dist/ui/fleet-office.js +78 -8
  237. package/dist/ui/host-install.js +77 -3
  238. package/dist/ui/hub-agent-intro.js +35 -0
  239. package/dist/ui/hub-attachments.js +81 -3
  240. package/dist/ui/hub-chat-strings.js +4 -4
  241. package/dist/ui/hub-client.js +16 -1
  242. package/dist/ui/hub-grant-picker.js +25 -11
  243. package/dist/ui/hub-group-strings.js +3 -3
  244. package/dist/ui/hub-intro-notice.js +16 -0
  245. package/dist/ui/hub-my-agents-model.js +42 -0
  246. package/dist/ui/hub-my-agents-strings.js +18 -0
  247. package/dist/ui/hub-my-agents.js +144 -0
  248. package/dist/ui/hub-owner-strings.js +5 -5
  249. package/dist/ui/hub-personal-agent.js +5 -4
  250. package/dist/ui/hub-room-composer.js +37 -6
  251. package/dist/ui/hub-room-list.js +4 -3
  252. package/dist/ui/hub-room-members.js +5 -2
  253. package/dist/ui/hub-room-new.js +8 -5
  254. package/dist/ui/hub-room-purpose.js +19 -0
  255. package/dist/ui/hub-room-search.js +1 -1
  256. package/dist/ui/hub-room-settings.js +9 -0
  257. package/dist/ui/hub-room-strings.js +6 -4
  258. package/dist/ui/hub-room-thread.js +70 -17
  259. package/dist/ui/hub-strings.js +5 -5
  260. package/dist/ui/hub-welcome.js +6 -6
  261. package/dist/ui/notice-hub-sharing.js +81 -0
  262. package/dist/ui/panel-chat.js +19 -5
  263. package/dist/ui/panel-hub.js +77 -29
  264. package/dist/ui/panel-notices.js +2 -1
  265. package/dist/ui/settings-hub-connection.js +2 -2
  266. package/dist/ui/settings-hub-page-sharing.js +52 -0
  267. package/dist/ui/settings-hub.js +4 -2
  268. package/dist/ui/settings-registry.js +1 -0
  269. package/dist/ui/shared/app-i18n.js +2 -2
  270. package/dist/ui/shared/app-shell.js +14 -2
  271. package/dist/ui/shared/app-store.js +6 -2
  272. package/dist/ui/shared/app.js +3 -1
  273. package/dist/ui/shared/chat-msg-actions.js +3 -1
  274. package/dist/ui/shared/chat-quote.js +261 -0
  275. package/dist/ui/shared/hub-chat.css +31 -0
  276. package/dist/ui/shared/hub-my-agents.css +35 -0
  277. package/dist/ui/shared/hub-rooms-u2.css +5 -0
  278. package/dist/ui/shared/module-warm.d.ts +3 -0
  279. package/dist/ui/shared/module-warm.js +39 -0
  280. package/dist/web-api.d.ts +21 -5
  281. package/dist/web-api.js +138 -7
  282. package/dist/web-api.js.map +1 -1
  283. package/dist/web-asset-version.d.ts +65 -0
  284. package/dist/web-asset-version.js +259 -0
  285. package/dist/web-asset-version.js.map +1 -0
  286. package/dist/web-host-guard.js +3 -1
  287. package/dist/web-host-guard.js.map +1 -1
  288. package/dist/web-host-install.d.ts +30 -3
  289. package/dist/web-host-install.js +50 -4
  290. package/dist/web-host-install.js.map +1 -1
  291. package/dist/web-notices.d.ts +17 -0
  292. package/dist/web-notices.js +47 -6
  293. package/dist/web-notices.js.map +1 -1
  294. package/dist/web-terminal.d.ts +5 -0
  295. package/dist/web-terminal.js +11 -0
  296. package/dist/web-terminal.js.map +1 -1
  297. package/launcher/agend-install.cjs +48 -7
  298. package/package.json +1 -1
package/dist/web-api.js CHANGED
@@ -40,7 +40,9 @@ import { MAX_COMMAND_ARGS } from "./web-commands.js";
40
40
  import { ROUTE_WORKER_CSP, ROUTE_WORKER_PATH, sendPanelHtml } from "./web-host-guard.js";
41
41
  import { libavoidFile } from "./web-libavoid.js";
42
42
  import { shellRoute } from "./web-shell-routes.js";
43
- import { createReadStream, createWriteStream, readFileSync } from "node:fs";
43
+ import { createReadStream, createWriteStream, existsSync, readFileSync } from "node:fs";
44
+ import { servedAssets } from "./auth-api.js";
45
+ import { assetIntact, assetsUnchanged, assetVersion, assetVersionMark, answerStaleAsset, buildModuleGraph, staticClosure, versionShell, IMMUTABLE_PRIVATE } from "./web-asset-version.js";
44
46
  import { join, dirname } from "node:path";
45
47
  import { fileURLToPath } from "node:url";
46
48
  import { createHash, createHmac, randomUUID } from "node:crypto";
@@ -1704,7 +1706,8 @@ function handleBackendLogin(req, res, url, ctx, path, method) {
1704
1706
  * after it). `GET` reads the current install; `POST` `{ backend }` starts one — the browser names a CLI, the server looks up the registry's command, nothing it sends
1705
1707
  * is ever run; `POST …/cancel` `{}` stops the running one. Every answer is no-store.
1706
1708
  */
1707
- const HOST_INSTALL_STATUS = { not_allowed: 403, unsupported: 400, already: 409, not_installed: 409, up_to_date: 409, version_unreadable: 409, busy: 409, shutting_down: 503, failed: 500 };
1709
+ const HOST_INSTALL_STATUS = { not_allowed: 403, unsupported: 400, already: 409, not_installed: 409, up_to_date: 409, version_unreadable: 409, cli_self_updating: 409,
1710
+ not_npm: 409, still_npm: 409, no_npm_copy: 409, busy: 409, shutting_down: 503, failed: 500 };
1708
1711
  function handleHostInstall(req, res, url, ctx, path, method) {
1709
1712
  res.setHeader("Cache-Control", "private, no-store");
1710
1713
  res.setHeader("X-Content-Type-Options", "nosniff");
@@ -1801,7 +1804,9 @@ function handleHostInstall(req, res, url, ctx, path, method) {
1801
1804
  }
1802
1805
  }
1803
1806
  // AGEND-136: `POST /ui/host-update { backend }` is the same request for an update: the server picks the command and the audited release; the page sends only the CLI's id.
1804
- const result = await installs.begin(now, parsed.data.backend, settingsRequestExecution(req), path === "/ui/host-update" ? "update" : "install");
1807
+ // M-3307: `/ui/host-native-switch` and `/ui/host-npm-remove` are the switch to Claude's native install and the npm copy's removal (web-host-install.ts modes).
1808
+ const mode = path === "/ui/host-update" ? "update" : path === "/ui/host-native-switch" ? "native" : path === "/ui/host-npm-remove" ? "remove-npm" : "install";
1809
+ const result = await installs.begin(now, parsed.data.backend, settingsRequestExecution(req), mode);
1805
1810
  if ("error" in result)
1806
1811
  json(res, HOST_INSTALL_STATUS[result.error] ?? 409, { error: result.error, ...(result.message ? { message: result.message } : {}) });
1807
1812
  else
@@ -2674,9 +2679,27 @@ export function handleWebRequest(req, res, url, ctx) {
2674
2679
  json(res, 400, { error: "Invalid file name" });
2675
2680
  return true;
2676
2681
  }
2682
+ // M-3314: /ui/js/v-<V>/… (rewritten to this path before the gate): this process's <V> is kept for good, privately; an
2683
+ // older tab's gets the stale-tab answer — once the gate above let the session through, as the plain path.
2684
+ const mark = assetVersionMark(req);
2685
+ if (mark && !mark.current) {
2686
+ if (!existsSync(join(__dirname, "ui", fileName))) {
2687
+ json(res, 404, { error: "File not found" });
2688
+ return true;
2689
+ }
2690
+ answerStaleAsset(res, path);
2691
+ return true;
2692
+ }
2677
2693
  try {
2678
2694
  const js = readFileSync(join(__dirname, "ui", fileName), "utf-8");
2695
+ // A file rewritten under this running process is not what <V> named (an update or a rollback before its restart).
2696
+ if (mark && !assetIntact(fileName, js)) {
2697
+ answerStaleAsset(res, path);
2698
+ return true;
2699
+ }
2679
2700
  res.setHeader("Content-Type", "application/javascript; charset=utf-8");
2701
+ if (mark)
2702
+ res.setHeader("Cache-Control", IMMUTABLE_PRIVATE);
2680
2703
  // #2182: the route worker's own, narrower-reaching policy (ROUTE_WORKER_CSP); every other file keeps the page's.
2681
2704
  if (path === ROUTE_WORKER_PATH)
2682
2705
  res.setHeader("Content-Security-Policy", ROUTE_WORKER_CSP);
@@ -3443,6 +3466,51 @@ export function handleWebRequest(req, res, url, ctx) {
3443
3466
  handleSendMessage(req, res, ctx);
3444
3467
  return true;
3445
3468
  }
3469
+ // M-3293 (#4119): "Tell" — an Office pat or feed, for the agent's next real message (never a turn, never a wake). The
3470
+ // Office is an admin's (decision 7933bf90: over the public link too), as the archive's reads: a guest (no Office) or a
3471
+ // read-only session is refused; a registered instance; a person (a session revoked meanwhile: 401).
3472
+ if (method === "POST" && path === "/ui/office-tell") {
3473
+ const admission = adminAdmissionOf(req, url, ctx);
3474
+ if (!admission || guestRequestOf(req)) {
3475
+ req.resume();
3476
+ json(res, 403, { error: "admin_only" });
3477
+ return true;
3478
+ }
3479
+ (async () => {
3480
+ let raw;
3481
+ try {
3482
+ raw = await parseBody(req);
3483
+ }
3484
+ catch {
3485
+ json(res, 400, { error: "Invalid JSON" });
3486
+ return;
3487
+ }
3488
+ if (!permitWebContinuation(req, res, ctx))
3489
+ return;
3490
+ // Fable #4130: still that admin once the body is in (a session demoted meanwhile queues nothing), as the other admin POSTs.
3491
+ if (adminAdmissionOf(req, url, ctx) !== admission || guestRequestOf(req)) {
3492
+ json(res, 403, { error: "admin_only" });
3493
+ return;
3494
+ }
3495
+ const b = raw;
3496
+ const instance = typeof b?.instance === "string" ? b.instance : "", kind = b?.kind;
3497
+ if (!instance || instance.length > 128 || !safeInstanceSegment(instance) || (kind !== "pat" && kind !== "feed")) {
3498
+ json(res, 400, { error: "instance and kind (pat or feed) required" });
3499
+ return;
3500
+ }
3501
+ if (!registeredChatInstance(ctx, instance) && !ctx.instanceIpcClients.has(instance)) {
3502
+ json(res, 404, { error: `Instance not found: ${instance}` });
3503
+ return;
3504
+ }
3505
+ const person = webPersonOf(req, new URL(req.url ?? "/", "http://localhost"), ctx);
3506
+ if (!person) {
3507
+ json(res, 401, { error: WEB_TOKEN_INVALID_MESSAGE });
3508
+ return;
3509
+ }
3510
+ json(res, 200, { queued: ctx.officeTell?.(instance, person.name, kind) ?? false });
3511
+ })();
3512
+ return true;
3513
+ }
3446
3514
  // ── Files (C2): upload one file for an instance; fetch a file by the id the fleet issued for it ──
3447
3515
  if (method === "POST" && path === "/ui/upload") {
3448
3516
  handleUpload(req, res, url, ctx);
@@ -3938,7 +4006,16 @@ export function handleWebRequest(req, res, url, ctx) {
3938
4006
  json(res, 400, { error: "instance, nonce and action required" });
3939
4007
  return;
3940
4008
  }
3941
- const r = text === undefined ? await click(instance, nonce, action) : await click(instance, nonce, action, text);
4009
+ const needsHuman = ctx.webPromptNeedsHuman?.(nonce) === true;
4010
+ if (needsHuman) {
4011
+ const verdict = evaluateWebRequest(req, url, ctx.webToken ?? null, ctx.webSessions, { touch: false });
4012
+ if (verdict.kind !== "allow" || verdict.via !== "session" || verdict.session.tier !== "admin") {
4013
+ json(res, 403, { error: "This decision needs a signed-in administrator" });
4014
+ return;
4015
+ }
4016
+ }
4017
+ const r = needsHuman ? await click(instance, nonce, action, text, true)
4018
+ : text === undefined ? await click(instance, nonce, action) : await click(instance, nonce, action, text);
3942
4019
  // 409: answered elsewhere first, expired, or never open — the page drops the buttons on `gone`.
3943
4020
  json(res, r.status, r.status === 200 ? { answered: true } : { error: r.error ?? "Refused", ...(r.status === 409 ? { gone: true } : {}) });
3944
4021
  })().catch(err => {
@@ -4191,7 +4268,7 @@ export function handleWebRequest(req, res, url, ctx) {
4191
4268
  return handleBrowserBackendSignIns(req, res, url, ctx);
4192
4269
  if (path === "/ui/backend-login" || path.startsWith("/ui/backend-login/"))
4193
4270
  return handleBackendLogin(req, res, url, ctx, path, method);
4194
- if (path === "/ui/host-install" || path === "/ui/host-install/cancel" || path === "/ui/host-update")
4271
+ if (path === "/ui/host-install" || path === "/ui/host-install/cancel" || HOST_CLI_PATHS.has(path))
4195
4272
  return handleHostInstall(req, res, url, ctx, path, method);
4196
4273
  // #3292: before the accounts prefix — its Add pattern (`POST /ui/accounts/<backend>`) would read "keep-alive" as a backend.
4197
4274
  if (path === "/ui/accounts/keep-alive")
@@ -5768,6 +5845,7 @@ function handleSendMessage(req, res, ctx) {
5768
5845
  // A claimed clientId is settled however this ends: with the messageId once accepted, else forgotten.
5769
5846
  let claim;
5770
5847
  let acceptedId = null;
5848
+ let tellPasted; // #4145: the pasted-token line, after this message's own (whatever the send's end)
5771
5849
  try {
5772
5850
  const raw = JSON.parse(body);
5773
5851
  const parsed = SendMessageSchema.safeParse(raw);
@@ -5776,7 +5854,17 @@ function handleSendMessage(req, res, ctx) {
5776
5854
  json(res, 400, { error: `${issue.path.join(".") || "body"}: ${issue.message}` });
5777
5855
  return;
5778
5856
  }
5779
- const { instance, message: typed, attachments = [], replyTo, clientId } = parsed.data;
5857
+ const { instance, message: sent, attachments = [], replyTo, clientId } = parsed.data;
5858
+ // #4145: this fleet's sign-in access token pasted here is hidden before it goes anywhere (the agent, the chat's
5859
+ // history, the topic's copy, the activity log), and taken back at once — a new one goes privately.
5860
+ const pasted = ctx.screenLoginToken?.(sent) ?? null;
5861
+ const typed = pasted?.text ?? sent;
5862
+ const pastedNotice = pasted?.live ? (ctx.loginTokenPasted?.() ?? Promise.resolve(null)).catch(() => null) : null;
5863
+ if (pastedNotice)
5864
+ tellPasted = () => void pastedNotice.then(notice => {
5865
+ if (notice)
5866
+ ctx.emitSseEvent("message", { instance, role: "status", sender: "AgEnD", text: notice, ts: new Date().toISOString(), messageId: newWebMessageId() });
5867
+ });
5780
5868
  const native = isWindowsInstance(ctx.fleetConfig?.instances[instance]);
5781
5869
  if (native && !nativeCliAuthorization(req, new URL(req.url ?? "/", "http://localhost"), ctx)) {
5782
5870
  json(res, 403, { error: "Windows runtime requires an administrator on the local dashboard" });
@@ -6020,6 +6108,7 @@ function handleSendMessage(req, res, ctx) {
6020
6108
  }
6021
6109
  finally {
6022
6110
  claim?.settle(acceptedId);
6111
+ tellPasted?.();
6023
6112
  }
6024
6113
  });
6025
6114
  }
@@ -6512,6 +6601,40 @@ export function serveHubWorkspaceShell(res, hub) {
6512
6601
  * The app shell page. `opts.hubWorkspace`: the page is a Hub's own workspace (slice 1's Hub listener only — the fleet's
6513
6602
  * listener never passes it), so it is drawn as the Hub shell.
6514
6603
  */
6604
+ let moduleGraphMemo = null;
6605
+ /** M-3314: the served modules' static imports, read once per process (its files do not change under it). */
6606
+ export function appModuleGraph() { return moduleGraphMemo ??= buildModuleGraph(join(__dirname, "ui"), servedAssets()); }
6607
+ /** M-3314: the module each panel's route loads (app.js's own dynamic imports). */
6608
+ export const PANEL_MODULES = {
6609
+ chat: "/ui/js/panel-chat.js", fleet: "/ui/js/panel-fleet.js", settings: "/ui/js/panel-settings.js", needs: "/ui/js/panel-needs.js",
6610
+ details: "/ui/js/panel-details.js", log: "/ui/js/panel-log.js", notices: "/ui/js/panel-notices.js", "windows-agent": "/ui/js/panel-windows-agent.js",
6611
+ view: "/assets/panel-view.js",
6612
+ };
6613
+ /**
6614
+ * M-3314: what this load of the shell imports, statically or as app.js boots it, so it can be asked for in one wave:
6615
+ * app.js; for a signed-in page the chat (always booted) and the panel of the route; for an admin's page also what
6616
+ * app.js loads for every admin (backend sign-in, agent proposals) and, with the chat workspace, its modules. Nothing a
6617
+ * page of that kind would not load anyway — a guest's or a reader's page preloads only what it imports itself.
6618
+ */
6619
+ export function shellPreload(mode, guest, path, workspace) {
6620
+ const graph = appModuleGraph();
6621
+ const entries = ["/assets/app.js"];
6622
+ const route = shellRoute("GET", path);
6623
+ const panel = route?.kind === "shell" ? route.route.panel : null;
6624
+ if (panel === "view")
6625
+ entries.push(PANEL_MODULES.view);
6626
+ if (mode === "full") {
6627
+ entries.push(PANEL_MODULES.chat);
6628
+ if (!guest) {
6629
+ if (panel && panel !== "chat" && panel !== "view" && PANEL_MODULES[panel])
6630
+ entries.push(PANEL_MODULES[panel]);
6631
+ entries.push("/ui/js/backend-signin.js", "/ui/js/agent-proposals.js");
6632
+ if (workspace)
6633
+ entries.push("/ui/js/chat-workspace.js", PANEL_MODULES.details, PANEL_MODULES.log, PANEL_MODULES.view);
6634
+ }
6635
+ }
6636
+ return staticClosure(graph, entries);
6637
+ }
6515
6638
  export function serveAppShell(req, res, ctx, mode, opts = {}) {
6516
6639
  // A Hub workspace is drawn from nothing of this fleet's: no fleet cookie, session, preference or preview is read.
6517
6640
  if (opts.hubWorkspace) {
@@ -6538,7 +6661,15 @@ export function serveAppShell(req, res, ctx, mode, opts = {}) {
6538
6661
  const fileViewer = own ? evaluateWebRequest(req, new URL(req.url ?? "/", "http://localhost"), ctx.webToken ?? null, ctx.webSessions, { touch: false }) : null;
6539
6662
  const fileFrame = own && fileViewer?.kind === "allow" && fileViewer.via === "session" && fileViewer.session.tier === "admin" ? `${own}/ui/reply-preview` : null;
6540
6663
  const frameSrc = [previewFrames, fileFrame].filter(Boolean).join(" ");
6541
- sendPanelHtml(res, withAppIconLinks(html).replace('<html lang="en">', shellHtmlTag(ctx, mode, viewer)).replace("<body>", shellBodyTag(req, ctx, mode, viewer)), 200, {}, { ...(frameSrc ? { frameSrc } : {}), mediaSrc });
6664
+ const bodyTag = shellBodyTag(req, ctx, mode, viewer);
6665
+ const page = withAppIconLinks(html).replace('<html lang="en">', shellHtmlTag(ctx, mode, viewer)).replace("<body>", bodyTag);
6666
+ // M-3314: the shell's files under this version, and the modules this load will import preloaded at once.
6667
+ const guest = mode === "full" && !!viewer?.guest;
6668
+ const preload = shellPreload(mode, guest, new URL(req.url ?? "/", "http://localhost").pathname, bodyTag.includes('data-chat-workspace="1"'));
6669
+ // Only while the files are still the ones <V> names: between an update's install and its restart the shell is the
6670
+ // plain one (no-store files, as before this change), never one that names <V> over files it does not describe.
6671
+ const shell = assetsUnchanged() ? versionShell(page, assetVersion(), preload, mode === "full" && !guest ? appModuleGraph() : undefined) : page;
6672
+ sendPanelHtml(res, shell, 200, {}, { ...(frameSrc ? { frameSrc } : {}), mediaSrc });
6542
6673
  }
6543
6674
  catch {
6544
6675
  json(res, 500, { error: "app.html not found" });