@songsid/agend 2.4.0-beta.1 → 2.4.0-beta.11

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 (934) hide show
  1. package/dist/agent-cli-instructions.md +4 -1
  2. package/dist/agent-cli.js +14 -2
  3. package/dist/agent-cli.js.map +1 -1
  4. package/dist/agent-endpoint.d.ts +3 -1
  5. package/dist/agent-endpoint.js +15 -3
  6. package/dist/agent-endpoint.js.map +1 -1
  7. package/dist/agent-token-header.d.ts +1 -1
  8. package/dist/agent-token-header.js +1 -1
  9. package/dist/app-message-origin.d.ts +2 -0
  10. package/dist/app-message-origin.js +3 -0
  11. package/dist/app-message-origin.js.map +1 -0
  12. package/dist/auth-api.d.ts +8 -0
  13. package/dist/auth-api.js +40 -1
  14. package/dist/auth-api.js.map +1 -1
  15. package/dist/authority/authority-state.d.ts +7 -0
  16. package/dist/authority/authority-state.js +17 -2
  17. package/dist/authority/authority-state.js.map +1 -1
  18. package/dist/authority/web-authority.d.ts +11 -1
  19. package/dist/authority/web-authority.js +11 -1
  20. package/dist/authority/web-authority.js.map +1 -1
  21. package/dist/backend/agy-model-switch.d.ts +22 -0
  22. package/dist/backend/agy-model-switch.js +62 -0
  23. package/dist/backend/agy-model-switch.js.map +1 -0
  24. package/dist/backend/antigravity.d.ts +9 -2
  25. package/dist/backend/antigravity.js +84 -9
  26. package/dist/backend/antigravity.js.map +1 -1
  27. package/dist/backend/claude-code.js +55 -14
  28. package/dist/backend/claude-code.js.map +1 -1
  29. package/dist/backend/cli-env-probe.js +1 -1
  30. package/dist/backend/cli-env-probe.js.map +1 -1
  31. package/dist/backend/cli-runtime-switch.d.ts +90 -0
  32. package/dist/backend/cli-runtime-switch.js +273 -0
  33. package/dist/backend/cli-runtime-switch.js.map +1 -0
  34. package/dist/backend/codex-footer-hints.d.ts +1 -0
  35. package/dist/backend/codex-footer-hints.js +15 -0
  36. package/dist/backend/codex-footer-hints.js.map +1 -1
  37. package/dist/backend/codex-model-switch.d.ts +41 -0
  38. package/dist/backend/codex-model-switch.js +170 -0
  39. package/dist/backend/codex-model-switch.js.map +1 -0
  40. package/dist/backend/codex-precaution.d.ts +7 -0
  41. package/dist/backend/codex-precaution.js +102 -0
  42. package/dist/backend/codex-precaution.js.map +1 -0
  43. package/dist/backend/codex.d.ts +7 -4
  44. package/dist/backend/codex.js +44 -9
  45. package/dist/backend/codex.js.map +1 -1
  46. package/dist/backend/credential-profile.js +1 -1
  47. package/dist/backend/credential-profile.js.map +1 -1
  48. package/dist/backend/grok-model-switch.d.ts +16 -0
  49. package/dist/backend/grok-model-switch.js +45 -0
  50. package/dist/backend/grok-model-switch.js.map +1 -0
  51. package/dist/backend/grok.js +22 -7
  52. package/dist/backend/grok.js.map +1 -1
  53. package/dist/backend/kiro.js +4 -4
  54. package/dist/backend/kiro.js.map +1 -1
  55. package/dist/backend/muse.d.ts +2 -0
  56. package/dist/backend/muse.js +7 -3
  57. package/dist/backend/muse.js.map +1 -1
  58. package/dist/backend/native-pane.js +1 -1
  59. package/dist/backend/native-pane.js.map +1 -1
  60. package/dist/backend/types.d.ts +11 -1
  61. package/dist/backend/types.js.map +1 -1
  62. package/dist/backend-availability.d.ts +22 -0
  63. package/dist/backend-availability.js +71 -2
  64. package/dist/backend-availability.js.map +1 -1
  65. package/dist/backend-signin-guide.js +1 -1
  66. package/dist/backend-signin-guide.js.map +1 -1
  67. package/dist/build-provenance.json +1 -1
  68. package/dist/channel/adapters/discord.d.ts +10 -0
  69. package/dist/channel/adapters/discord.js +35 -0
  70. package/dist/channel/adapters/discord.js.map +1 -1
  71. package/dist/channel/adapters/telegram.d.ts +2 -0
  72. package/dist/channel/adapters/telegram.js +3 -0
  73. package/dist/channel/adapters/telegram.js.map +1 -1
  74. package/dist/channel/mcp-server.js +10 -1
  75. package/dist/channel/mcp-server.js.map +1 -1
  76. package/dist/channel/mcp-tools.js +9 -1
  77. package/dist/channel/mcp-tools.js.map +1 -1
  78. package/dist/channel/tool-router.js +9 -2
  79. package/dist/channel/tool-router.js.map +1 -1
  80. package/dist/channel/types.d.ts +10 -0
  81. package/dist/classic-channel-manager.d.ts +1 -1
  82. package/dist/classic-channel-manager.js +1 -1
  83. package/dist/cli-audited.js +16 -15
  84. package/dist/cli-audited.js.map +1 -1
  85. package/dist/cli-capability.d.ts +3 -0
  86. package/dist/cli-capability.js.map +1 -1
  87. package/dist/cli-registry-check.js +1 -1
  88. package/dist/cli-registry-check.js.map +1 -1
  89. package/dist/cli-registry.d.ts +1 -0
  90. package/dist/cli-spec-antigravity.d.ts +1 -0
  91. package/dist/cli-spec-antigravity.js +3 -1
  92. package/dist/cli-spec-antigravity.js.map +1 -1
  93. package/dist/cli.js +8 -0
  94. package/dist/cli.js.map +1 -1
  95. package/dist/config-validator.js +18 -1
  96. package/dist/config-validator.js.map +1 -1
  97. package/dist/connect/control.d.ts +20 -0
  98. package/dist/connect/control.js +236 -0
  99. package/dist/connect/control.js.map +1 -0
  100. package/dist/connect/install.d.ts +13 -0
  101. package/dist/connect/install.js +12 -0
  102. package/dist/connect/install.js.map +1 -0
  103. package/dist/connect/mcp.d.ts +9 -0
  104. package/dist/connect/mcp.js +10 -0
  105. package/dist/connect/mcp.js.map +1 -0
  106. package/dist/connect/protocol.d.ts +38 -0
  107. package/dist/connect/protocol.js +36 -0
  108. package/dist/connect/protocol.js.map +1 -0
  109. package/dist/connect/service.d.ts +19 -0
  110. package/dist/connect/service.js +79 -0
  111. package/dist/connect/service.js.map +1 -0
  112. package/dist/connect/stdio-entry.d.ts +1 -0
  113. package/dist/connect/stdio-entry.js +6 -0
  114. package/dist/connect/stdio-entry.js.map +1 -0
  115. package/dist/connect/stdio.d.ts +5 -0
  116. package/dist/connect/stdio.js +33 -0
  117. package/dist/connect/stdio.js.map +1 -0
  118. package/dist/daemon.d.ts +64 -2
  119. package/dist/daemon.js +399 -33
  120. package/dist/daemon.js.map +1 -1
  121. package/dist/delivery-consumed-watch.d.ts +2 -0
  122. package/dist/delivery-consumed-watch.js +4 -1
  123. package/dist/delivery-consumed-watch.js.map +1 -1
  124. package/dist/dispatcher-liveness.d.ts +51 -1
  125. package/dist/dispatcher-liveness.js +92 -2
  126. package/dist/dispatcher-liveness.js.map +1 -1
  127. package/dist/event-log.d.ts +13 -1
  128. package/dist/event-log.js +41 -1
  129. package/dist/event-log.js.map +1 -1
  130. package/dist/fleet-manager.d.ts +239 -7
  131. package/dist/fleet-manager.js +1387 -103
  132. package/dist/fleet-manager.js.map +1 -1
  133. package/dist/fleet-windows-runtime.js +4 -2
  134. package/dist/fleet-windows-runtime.js.map +1 -1
  135. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +11 -1
  136. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +10 -0
  137. package/dist/general-knowledge/skills/fleet-health/SKILL.md +18 -0
  138. package/dist/general-knowledge/skills/hub/SKILL.md +302 -29
  139. package/dist/general-knowledge/skills/model-discovery/SKILL.md +4 -0
  140. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +127 -26
  141. package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +2 -0
  142. package/dist/hub/admin-dashboard.d.ts +85 -0
  143. package/dist/hub/admin-dashboard.js +177 -0
  144. package/dist/hub/admin-dashboard.js.map +1 -0
  145. package/dist/hub/agent-catalog-model.d.ts +276 -0
  146. package/dist/hub/agent-catalog-model.js +49 -0
  147. package/dist/hub/agent-catalog-model.js.map +1 -0
  148. package/dist/hub/agent-catalog.d.ts +137 -0
  149. package/dist/hub/agent-catalog.js +118 -0
  150. package/dist/hub/agent-catalog.js.map +1 -0
  151. package/dist/hub/agent-intro.d.ts +31 -0
  152. package/dist/hub/agent-intro.js +51 -0
  153. package/dist/hub/agent-intro.js.map +1 -0
  154. package/dist/hub/attachments/store.d.ts +2 -0
  155. package/dist/hub/attachments/store.js +6 -0
  156. package/dist/hub/attachments/store.js.map +1 -1
  157. package/dist/hub/audit/index.d.ts +2 -0
  158. package/dist/hub/audit/index.js +8 -0
  159. package/dist/hub/audit/index.js.map +1 -1
  160. package/dist/hub/buttons.js +3 -1
  161. package/dist/hub/buttons.js.map +1 -1
  162. package/dist/hub/catalog.d.ts +11 -6
  163. package/dist/hub/catalog.js +38 -13
  164. package/dist/hub/catalog.js.map +1 -1
  165. package/dist/hub/client.d.ts +15 -0
  166. package/dist/hub/client.js +106 -12
  167. package/dist/hub/client.js.map +1 -1
  168. package/dist/hub/compose/member.d.ts +28 -0
  169. package/dist/hub/compose/member.js +300 -27
  170. package/dist/hub/compose/member.js.map +1 -1
  171. package/dist/hub/compose/server.d.ts +17 -0
  172. package/dist/hub/compose/server.js +108 -14
  173. package/dist/hub/compose/server.js.map +1 -1
  174. package/dist/hub/display-name.d.ts +10 -0
  175. package/dist/hub/display-name.js +35 -0
  176. package/dist/hub/display-name.js.map +1 -0
  177. package/dist/hub/execution/service.d.ts +2 -1
  178. package/dist/hub/execution/service.js +2 -1
  179. package/dist/hub/execution/service.js.map +1 -1
  180. package/dist/hub/fleet-info.d.ts +12 -0
  181. package/dist/hub/fleet-info.js +14 -0
  182. package/dist/hub/fleet-info.js.map +1 -0
  183. package/dist/hub/fleet-update-model.d.ts +100 -0
  184. package/dist/hub/fleet-update-model.js +15 -0
  185. package/dist/hub/fleet-update-model.js.map +1 -0
  186. package/dist/hub/fleet-updates.d.ts +46 -0
  187. package/dist/hub/fleet-updates.js +282 -0
  188. package/dist/hub/fleet-updates.js.map +1 -0
  189. package/dist/hub/fleet-versions.d.ts +28 -0
  190. package/dist/hub/fleet-versions.js +80 -0
  191. package/dist/hub/fleet-versions.js.map +1 -0
  192. package/dist/hub/group-policy/admin-api.d.ts +1 -0
  193. package/dist/hub/group-policy/admin-api.js +10 -1
  194. package/dist/hub/group-policy/admin-api.js.map +1 -1
  195. package/dist/hub/group-policy/admin-control.d.ts +1 -0
  196. package/dist/hub/group-policy/admin-control.js +13 -4
  197. package/dist/hub/group-policy/admin-control.js.map +1 -1
  198. package/dist/hub/group-policy/admin-dto.d.ts +39 -1
  199. package/dist/hub/group-policy/admin-dto.js.map +1 -1
  200. package/dist/hub/group-policy/admin-facts.d.ts +4 -2
  201. package/dist/hub/group-policy/admin-facts.js +17 -2
  202. package/dist/hub/group-policy/admin-facts.js.map +1 -1
  203. package/dist/hub/group-policy/admin-impact.d.ts +36 -6
  204. package/dist/hub/group-policy/admin-impact.js +21 -7
  205. package/dist/hub/group-policy/admin-impact.js.map +1 -1
  206. package/dist/hub/group-policy/admin-inventory.d.ts +2 -0
  207. package/dist/hub/group-policy/admin-inventory.js +13 -4
  208. package/dist/hub/group-policy/admin-inventory.js.map +1 -1
  209. package/dist/hub/group-policy/admin-search.d.ts +2 -1
  210. package/dist/hub/group-policy/admin-search.js +56 -7
  211. package/dist/hub/group-policy/admin-search.js.map +1 -1
  212. package/dist/hub/group-policy/authorization.d.ts +2 -0
  213. package/dist/hub/group-policy/authorization.js +7 -2
  214. package/dist/hub/group-policy/authorization.js.map +1 -1
  215. package/dist/hub/group-policy/impact-inventory.d.ts +4 -1
  216. package/dist/hub/group-policy/impact-inventory.js +23 -2
  217. package/dist/hub/group-policy/impact-inventory.js.map +1 -1
  218. package/dist/hub/group-policy/model.d.ts +52 -1
  219. package/dist/hub/group-policy/model.js +20 -7
  220. package/dist/hub/group-policy/model.js.map +1 -1
  221. package/dist/hub/group-policy/resources.d.ts +2 -0
  222. package/dist/hub/group-policy/resources.js +12 -1
  223. package/dist/hub/group-policy/resources.js.map +1 -1
  224. package/dist/hub/group-policy/store.js +22 -3
  225. package/dist/hub/group-policy/store.js.map +1 -1
  226. package/dist/hub/group-policy/team-subjects.d.ts +16 -0
  227. package/dist/hub/group-policy/team-subjects.js +32 -0
  228. package/dist/hub/group-policy/team-subjects.js.map +1 -0
  229. package/dist/hub/http/compose.d.ts +4 -0
  230. package/dist/hub/http/compose.js +477 -40
  231. package/dist/hub/http/compose.js.map +1 -1
  232. package/dist/hub/http/core.js +27 -0
  233. package/dist/hub/http/core.js.map +1 -1
  234. package/dist/hub/http/deps.d.ts +13 -0
  235. package/dist/hub/http/schema.js +30 -1
  236. package/dist/hub/http/schema.js.map +1 -1
  237. package/dist/hub/join/client.js +75 -42
  238. package/dist/hub/join/client.js.map +1 -1
  239. package/dist/hub/join/service.d.ts +1 -1
  240. package/dist/hub/join/service.js.map +1 -1
  241. package/dist/hub/mcp/auth-schema.d.ts +7 -0
  242. package/dist/hub/mcp/auth-schema.js +31 -0
  243. package/dist/hub/mcp/auth-schema.js.map +1 -0
  244. package/dist/hub/mcp/auth.d.ts +89 -0
  245. package/dist/hub/mcp/auth.js +374 -0
  246. package/dist/hub/mcp/auth.js.map +1 -0
  247. package/dist/hub/mcp/catalog.d.ts +44 -0
  248. package/dist/hub/mcp/catalog.js +31 -0
  249. package/dist/hub/mcp/catalog.js.map +1 -0
  250. package/dist/hub/mcp/door-schema.d.ts +7 -0
  251. package/dist/hub/mcp/door-schema.js +20 -0
  252. package/dist/hub/mcp/door-schema.js.map +1 -0
  253. package/dist/hub/mcp/http.d.ts +25 -0
  254. package/dist/hub/mcp/http.js +259 -0
  255. package/dist/hub/mcp/http.js.map +1 -0
  256. package/dist/hub/mcp/policy.d.ts +65 -0
  257. package/dist/hub/mcp/policy.js +153 -0
  258. package/dist/hub/mcp/policy.js.map +1 -0
  259. package/dist/hub/mcp/server.d.ts +3 -0
  260. package/dist/hub/mcp/server.js +32 -0
  261. package/dist/hub/mcp/server.js.map +1 -0
  262. package/dist/hub/mcp/tools.d.ts +31 -0
  263. package/dist/hub/mcp/tools.js +177 -0
  264. package/dist/hub/mcp/tools.js.map +1 -0
  265. package/dist/hub/member/agent-catalog.d.ts +28 -0
  266. package/dist/hub/member/agent-catalog.js +80 -0
  267. package/dist/hub/member/agent-catalog.js.map +1 -0
  268. package/dist/hub/member/display-name.d.ts +9 -0
  269. package/dist/hub/member/display-name.js +71 -0
  270. package/dist/hub/member/display-name.js.map +1 -0
  271. package/dist/hub/member/exposure-api.d.ts +9 -3
  272. package/dist/hub/member/exposure-api.js +16 -9
  273. package/dist/hub/member/exposure-api.js.map +1 -1
  274. package/dist/hub/member/exposures.d.ts +16 -4
  275. package/dist/hub/member/exposures.js +47 -13
  276. package/dist/hub/member/exposures.js.map +1 -1
  277. package/dist/hub/member/pairing-api.js +3 -2
  278. package/dist/hub/member/pairing-api.js.map +1 -1
  279. package/dist/hub/member/recommendations.d.ts +37 -0
  280. package/dist/hub/member/recommendations.js +129 -0
  281. package/dist/hub/member/recommendations.js.map +1 -0
  282. package/dist/hub/member/room-ask.d.ts +68 -5
  283. package/dist/hub/member/room-ask.js +273 -25
  284. package/dist/hub/member/room-ask.js.map +1 -1
  285. package/dist/hub/member/room-context-budget.d.ts +5 -0
  286. package/dist/hub/member/room-context-budget.js +34 -0
  287. package/dist/hub/member/room-context-budget.js.map +1 -0
  288. package/dist/hub/member/room-mention-feedback.d.ts +44 -0
  289. package/dist/hub/member/room-mention-feedback.js +121 -0
  290. package/dist/hub/member/room-mention-feedback.js.map +1 -0
  291. package/dist/hub/member/room-notification.d.ts +9 -0
  292. package/dist/hub/member/room-notification.js +2 -0
  293. package/dist/hub/member/room-notification.js.map +1 -0
  294. package/dist/hub/member/room-post-answers.d.ts +46 -0
  295. package/dist/hub/member/room-post-answers.js +152 -0
  296. package/dist/hub/member/room-post-answers.js.map +1 -0
  297. package/dist/hub/member/room-post-receipt.d.ts +21 -0
  298. package/dist/hub/member/room-post-receipt.js +49 -0
  299. package/dist/hub/member/room-post-receipt.js.map +1 -0
  300. package/dist/hub/member/room-post.d.ts +103 -0
  301. package/dist/hub/member/room-post.js +231 -0
  302. package/dist/hub/member/room-post.js.map +1 -0
  303. package/dist/hub/member/sharing-journal.d.ts +252 -0
  304. package/dist/hub/member/sharing-journal.js +212 -0
  305. package/dist/hub/member/sharing-journal.js.map +1 -0
  306. package/dist/hub/member/sharing-link.d.ts +25 -0
  307. package/dist/hub/member/sharing-link.js +68 -0
  308. package/dist/hub/member/sharing-link.js.map +1 -0
  309. package/dist/hub/member/sharing-result.d.ts +6 -0
  310. package/dist/hub/member/sharing-result.js +46 -0
  311. package/dist/hub/member/sharing-result.js.map +1 -0
  312. package/dist/hub/member/sharing.d.ts +37 -0
  313. package/dist/hub/member/sharing.js +181 -0
  314. package/dist/hub/member/sharing.js.map +1 -0
  315. package/dist/hub/member/updates.d.ts +92 -0
  316. package/dist/hub/member/updates.js +316 -0
  317. package/dist/hub/member/updates.js.map +1 -0
  318. package/dist/hub/pairing.d.ts +15 -1
  319. package/dist/hub/pairing.js +33 -2
  320. package/dist/hub/pairing.js.map +1 -1
  321. package/dist/hub/person-prefs.d.ts +22 -0
  322. package/dist/hub/person-prefs.js +34 -0
  323. package/dist/hub/person-prefs.js.map +1 -0
  324. package/dist/hub/personal/owner-host.d.ts +146 -0
  325. package/dist/hub/personal/owner-host.js +289 -0
  326. package/dist/hub/personal/owner-host.js.map +1 -0
  327. package/dist/hub/personal/refusals.d.ts +11 -0
  328. package/dist/hub/personal/refusals.js +33 -0
  329. package/dist/hub/personal/refusals.js.map +1 -0
  330. package/dist/hub/personal/runtime-host.d.ts +26 -0
  331. package/dist/hub/personal/runtime-host.js +51 -0
  332. package/dist/hub/personal/runtime-host.js.map +1 -0
  333. package/dist/hub/personal/schema.d.ts +4 -0
  334. package/dist/hub/personal/schema.js +54 -0
  335. package/dist/hub/personal/schema.js.map +1 -0
  336. package/dist/hub/personal/turns.d.ts +39 -0
  337. package/dist/hub/personal/turns.js +221 -0
  338. package/dist/hub/personal/turns.js.map +1 -0
  339. package/dist/hub/personal/types.d.ts +42 -0
  340. package/dist/hub/personal/types.js +2 -0
  341. package/dist/hub/personal/types.js.map +1 -0
  342. package/dist/hub/policy.d.ts +1 -1
  343. package/dist/hub/policy.js +2 -0
  344. package/dist/hub/policy.js.map +1 -1
  345. package/dist/hub/protocol.d.ts +927 -1
  346. package/dist/hub/protocol.js +106 -14
  347. package/dist/hub/protocol.js.map +1 -1
  348. package/dist/hub/published-version.d.ts +3 -0
  349. package/dist/hub/published-version.js +35 -0
  350. package/dist/hub/published-version.js.map +1 -0
  351. package/dist/hub/quota.js +3 -1
  352. package/dist/hub/quota.js.map +1 -1
  353. package/dist/hub/recommendation-model.d.ts +36 -0
  354. package/dist/hub/recommendation-model.js +9 -0
  355. package/dist/hub/recommendation-model.js.map +1 -0
  356. package/dist/hub/recommendations.d.ts +58 -0
  357. package/dist/hub/recommendations.js +211 -0
  358. package/dist/hub/recommendations.js.map +1 -0
  359. package/dist/hub/representative.d.ts +5 -0
  360. package/dist/hub/representative.js +6 -1
  361. package/dist/hub/representative.js.map +1 -1
  362. package/dist/hub/roles/admin-control.d.ts +29 -0
  363. package/dist/hub/roles/admin-control.js +187 -0
  364. package/dist/hub/roles/admin-control.js.map +1 -0
  365. package/dist/hub/roles/admin-types.d.ts +72 -0
  366. package/dist/hub/roles/admin-types.js +2 -0
  367. package/dist/hub/roles/admin-types.js.map +1 -0
  368. package/dist/hub/roles/allowed-list-control.d.ts +34 -0
  369. package/dist/hub/roles/allowed-list-control.js +179 -0
  370. package/dist/hub/roles/allowed-list-control.js.map +1 -0
  371. package/dist/hub/roles/allowed-list.d.ts +8 -0
  372. package/dist/hub/roles/allowed-list.js +49 -0
  373. package/dist/hub/roles/allowed-list.js.map +1 -0
  374. package/dist/hub/roles/audit-details.d.ts +144 -0
  375. package/dist/hub/roles/audit-details.js +26 -0
  376. package/dist/hub/roles/audit-details.js.map +1 -0
  377. package/dist/hub/roles/authority.d.ts +12 -0
  378. package/dist/hub/roles/authority.js +39 -3
  379. package/dist/hub/roles/authority.js.map +1 -1
  380. package/dist/hub/roles/change.d.ts +3 -1
  381. package/dist/hub/roles/change.js +7 -2
  382. package/dist/hub/roles/change.js.map +1 -1
  383. package/dist/hub/roles/clock.d.ts +3 -0
  384. package/dist/hub/roles/clock.js +1 -1
  385. package/dist/hub/roles/clock.js.map +1 -1
  386. package/dist/hub/roles/convert.js +1 -1
  387. package/dist/hub/roles/convert.js.map +1 -1
  388. package/dist/hub/roles/cutover-inventory.d.ts +2 -0
  389. package/dist/hub/roles/cutover-inventory.js +8 -1
  390. package/dist/hub/roles/cutover-inventory.js.map +1 -1
  391. package/dist/hub/roles/cutover.d.ts +2 -2
  392. package/dist/hub/roles/cutover.js +3 -4
  393. package/dist/hub/roles/cutover.js.map +1 -1
  394. package/dist/hub/roles/delegation.d.ts +4 -1
  395. package/dist/hub/roles/delegation.js +7 -2
  396. package/dist/hub/roles/delegation.js.map +1 -1
  397. package/dist/hub/roles/evaluate.d.ts +2 -1
  398. package/dist/hub/roles/evaluate.js +14 -0
  399. package/dist/hub/roles/evaluate.js.map +1 -1
  400. package/dist/hub/roles/expiry-effects.d.ts +8 -0
  401. package/dist/hub/roles/expiry-effects.js +50 -0
  402. package/dist/hub/roles/expiry-effects.js.map +1 -0
  403. package/dist/hub/roles/migrations.d.ts +7 -0
  404. package/dist/hub/roles/migrations.js +44 -0
  405. package/dist/hub/roles/migrations.js.map +1 -0
  406. package/dist/hub/roles/model.d.ts +25 -0
  407. package/dist/hub/roles/model.js +9 -3
  408. package/dist/hub/roles/model.js.map +1 -1
  409. package/dist/hub/roles/overview.d.ts +8 -0
  410. package/dist/hub/roles/overview.js +15 -0
  411. package/dist/hub/roles/overview.js.map +1 -0
  412. package/dist/hub/roles/resource-effects.d.ts +17 -0
  413. package/dist/hub/roles/resource-effects.js +62 -0
  414. package/dist/hub/roles/resource-effects.js.map +1 -0
  415. package/dist/hub/roles/review.d.ts +16 -0
  416. package/dist/hub/roles/review.js +42 -0
  417. package/dist/hub/roles/review.js.map +1 -0
  418. package/dist/hub/roles/writer.d.ts +14 -3
  419. package/dist/hub/roles/writer.js +64 -16
  420. package/dist/hub/roles/writer.js.map +1 -1
  421. package/dist/hub/room-context-model.d.ts +43 -0
  422. package/dist/hub/room-context-model.js +12 -0
  423. package/dist/hub/room-context-model.js.map +1 -0
  424. package/dist/hub/room-mention-feedback-model.d.ts +12 -0
  425. package/dist/hub/room-mention-feedback-model.js +12 -0
  426. package/dist/hub/room-mention-feedback-model.js.map +1 -0
  427. package/dist/hub/rooms/agents.d.ts +45 -10
  428. package/dist/hub/rooms/agents.js +289 -31
  429. package/dist/hub/rooms/agents.js.map +1 -1
  430. package/dist/hub/rooms/assistant.d.ts +1 -6
  431. package/dist/hub/rooms/assistant.js +7 -2
  432. package/dist/hub/rooms/assistant.js.map +1 -1
  433. package/dist/hub/rooms/automation.d.ts +24 -0
  434. package/dist/hub/rooms/automation.js +66 -0
  435. package/dist/hub/rooms/automation.js.map +1 -0
  436. package/dist/hub/rooms/buttons.d.ts +85 -0
  437. package/dist/hub/rooms/buttons.js +62 -0
  438. package/dist/hub/rooms/buttons.js.map +1 -0
  439. package/dist/hub/rooms/context-cursor.d.ts +18 -0
  440. package/dist/hub/rooms/context-cursor.js +61 -0
  441. package/dist/hub/rooms/context-cursor.js.map +1 -0
  442. package/dist/hub/rooms/context.d.ts +1 -1
  443. package/dist/hub/rooms/context.js +4 -4
  444. package/dist/hub/rooms/context.js.map +1 -1
  445. package/dist/hub/rooms/direct-view.d.ts +10 -2
  446. package/dist/hub/rooms/direct-view.js +4 -4
  447. package/dist/hub/rooms/direct-view.js.map +1 -1
  448. package/dist/hub/rooms/mentions.d.ts +15 -0
  449. package/dist/hub/rooms/mentions.js +43 -0
  450. package/dist/hub/rooms/mentions.js.map +1 -0
  451. package/dist/hub/rooms/post-replies.d.ts +23 -0
  452. package/dist/hub/rooms/post-replies.js +114 -0
  453. package/dist/hub/rooms/post-replies.js.map +1 -0
  454. package/dist/hub/rooms/schema.d.ts +9 -0
  455. package/dist/hub/rooms/schema.js +43 -0
  456. package/dist/hub/rooms/schema.js.map +1 -1
  457. package/dist/hub/rooms/service.d.ts +195 -4
  458. package/dist/hub/rooms/service.js +812 -28
  459. package/dist/hub/rooms/service.js.map +1 -1
  460. package/dist/hub/rooms/types.d.ts +30 -3
  461. package/dist/hub/rooms.d.ts +13 -2
  462. package/dist/hub/rooms.js +97 -22
  463. package/dist/hub/rooms.js.map +1 -1
  464. package/dist/hub/runtime.d.ts +1 -1
  465. package/dist/hub/runtime.js +17 -4
  466. package/dist/hub/runtime.js.map +1 -1
  467. package/dist/hub/server.d.ts +8 -1
  468. package/dist/hub/server.js +115 -7
  469. package/dist/hub/server.js.map +1 -1
  470. package/dist/hub/session-directory-transition.d.ts +2 -1
  471. package/dist/hub/session-directory-transition.js +10 -3
  472. package/dist/hub/session-directory-transition.js.map +1 -1
  473. package/dist/hub/sessions.d.ts +1 -1
  474. package/dist/hub/sessions.js +26 -4
  475. package/dist/hub/sessions.js.map +1 -1
  476. package/dist/hub/settings-commit.d.ts +32 -1
  477. package/dist/hub/settings-commit.js +11 -4
  478. package/dist/hub/settings-commit.js.map +1 -1
  479. package/dist/hub/settings-directory-ca.js +1 -1
  480. package/dist/hub/settings-directory-ca.js.map +1 -1
  481. package/dist/hub/settings-directory-control.js +7 -7
  482. package/dist/hub/settings-directory-control.js.map +1 -1
  483. package/dist/hub/settings-directory-http.d.ts +2 -0
  484. package/dist/hub/settings-directory-http.js +21 -6
  485. package/dist/hub/settings-directory-http.js.map +1 -1
  486. package/dist/hub/settings-directory-proof.d.ts +5 -1
  487. package/dist/hub/settings-directory-proof.js +49 -10
  488. package/dist/hub/settings-directory-proof.js.map +1 -1
  489. package/dist/hub/settings-directory-recovery.js +2 -1
  490. package/dist/hub/settings-directory-recovery.js.map +1 -1
  491. package/dist/hub/settings-directory-save.d.ts +2 -0
  492. package/dist/hub/settings-directory-save.js +9 -6
  493. package/dist/hub/settings-directory-save.js.map +1 -1
  494. package/dist/hub/sharing-previous-access.d.ts +22 -0
  495. package/dist/hub/sharing-previous-access.js +93 -0
  496. package/dist/hub/sharing-previous-access.js.map +1 -0
  497. package/dist/hub/sharing-requests.d.ts +171 -0
  498. package/dist/hub/sharing-requests.js +311 -0
  499. package/dist/hub/sharing-requests.js.map +1 -0
  500. package/dist/hub/sharing-retention.d.ts +47 -0
  501. package/dist/hub/sharing-retention.js +83 -0
  502. package/dist/hub/sharing-retention.js.map +1 -0
  503. package/dist/hub/sharing-withdrawal.d.ts +14 -0
  504. package/dist/hub/sharing-withdrawal.js +28 -0
  505. package/dist/hub/sharing-withdrawal.js.map +1 -0
  506. package/dist/hub/sharing.js +2 -2
  507. package/dist/hub/sharing.js.map +1 -1
  508. package/dist/hub/socket.d.ts +1 -0
  509. package/dist/hub/socket.js +39 -2
  510. package/dist/hub/socket.js.map +1 -1
  511. package/dist/hub/teams/index.d.ts +8 -3
  512. package/dist/hub/teams/index.js +106 -31
  513. package/dist/hub/teams/index.js.map +1 -1
  514. package/dist/hub/teams/store.d.ts +5 -1
  515. package/dist/hub/teams/store.js +25 -2
  516. package/dist/hub/teams/store.js.map +1 -1
  517. package/dist/hub/teams/types.d.ts +19 -2
  518. package/dist/hub/types.d.ts +163 -5
  519. package/dist/hub-classic-private.d.ts +19 -0
  520. package/dist/hub-classic-private.js +64 -0
  521. package/dist/hub-classic-private.js.map +1 -0
  522. package/dist/hub-contact-windows.d.ts +11 -0
  523. package/dist/hub-contact-windows.js +56 -0
  524. package/dist/hub-contact-windows.js.map +1 -0
  525. package/dist/hub-page-sharing-settings.d.ts +6 -0
  526. package/dist/hub-page-sharing-settings.js +19 -0
  527. package/dist/hub-page-sharing-settings.js.map +1 -0
  528. package/dist/hub-pairing-summary.d.ts +1 -1
  529. package/dist/hub-room-conversation.d.ts +14 -0
  530. package/dist/hub-room-conversation.js +60 -0
  531. package/dist/hub-room-conversation.js.map +1 -0
  532. package/dist/hub-sharing-notice.d.ts +43 -0
  533. package/dist/hub-sharing-notice.js +34 -0
  534. package/dist/hub-sharing-notice.js.map +1 -0
  535. package/dist/hub-update-notice.d.ts +12 -0
  536. package/dist/hub-update-notice.js +35 -0
  537. package/dist/hub-update-notice.js.map +1 -0
  538. package/dist/human-delivery-receipts.js +8 -0
  539. package/dist/human-delivery-receipts.js.map +1 -1
  540. package/dist/instance-config-impact.js +3 -0
  541. package/dist/instance-config-impact.js.map +1 -1
  542. package/dist/instructions.js +3 -0
  543. package/dist/instructions.js.map +1 -1
  544. package/dist/locale.js +195 -24
  545. package/dist/locale.js.map +1 -1
  546. package/dist/login-controller.d.ts +19 -2
  547. package/dist/login-controller.js +26 -8
  548. package/dist/login-controller.js.map +1 -1
  549. package/dist/login-flows.js +1 -1
  550. package/dist/login-flows.js.map +1 -1
  551. package/dist/native-mcp.js +7 -5
  552. package/dist/native-mcp.js.map +1 -1
  553. package/dist/native-model-catalog.d.ts +15 -0
  554. package/dist/native-model-catalog.js +43 -3
  555. package/dist/native-model-catalog.js.map +1 -1
  556. package/dist/native-pane-lifecycle.js +3 -2
  557. package/dist/native-pane-lifecycle.js.map +1 -1
  558. package/dist/native-pane-tools.js +3 -0
  559. package/dist/native-pane-tools.js.map +1 -1
  560. package/dist/needs-you.js +1 -0
  561. package/dist/needs-you.js.map +1 -1
  562. package/dist/office-share-page.js +2 -2
  563. package/dist/office-share-page.js.map +1 -1
  564. package/dist/outbound-handlers.d.ts +14 -4
  565. package/dist/outbound-handlers.js +54 -1
  566. package/dist/outbound-handlers.js.map +1 -1
  567. package/dist/outbound-schemas.d.ts +17 -0
  568. package/dist/outbound-schemas.js +14 -0
  569. package/dist/outbound-schemas.js.map +1 -1
  570. package/dist/pane-port.d.ts +2 -0
  571. package/dist/public-web-gateway.js +155 -5
  572. package/dist/public-web-gateway.js.map +1 -1
  573. package/dist/queued-handoffs.d.ts +16 -4
  574. package/dist/queued-handoffs.js +18 -1
  575. package/dist/queued-handoffs.js.map +1 -1
  576. package/dist/quickstart-api.d.ts +0 -1
  577. package/dist/quickstart-api.js +8 -1
  578. package/dist/quickstart-api.js.map +1 -1
  579. package/dist/remote-card-answer.d.ts +1 -1
  580. package/dist/remote-card-answer.js +8 -1
  581. package/dist/remote-card-answer.js.map +1 -1
  582. package/dist/remote-card-prompt.js +1 -1
  583. package/dist/remote-card-prompt.js.map +1 -1
  584. package/dist/reply-dedup.js +3 -1
  585. package/dist/reply-dedup.js.map +1 -1
  586. package/dist/reply-preview-files.d.ts +38 -0
  587. package/dist/reply-preview-files.js +142 -0
  588. package/dist/reply-preview-files.js.map +1 -0
  589. package/dist/reply-preview-spec.d.ts +18 -0
  590. package/dist/reply-preview-spec.js +27 -0
  591. package/dist/reply-preview-spec.js.map +1 -0
  592. package/dist/runtime-api.js +10 -2
  593. package/dist/runtime-api.js.map +1 -1
  594. package/dist/runtime-build-info.js +1 -0
  595. package/dist/runtime-build-info.js.map +1 -1
  596. package/dist/runtime-cli-install.js +13 -10
  597. package/dist/runtime-cli-install.js.map +1 -1
  598. package/dist/runtime-cli.js +31 -5
  599. package/dist/runtime-cli.js.map +1 -1
  600. package/dist/runtime-client-store.d.ts +5 -0
  601. package/dist/runtime-client-store.js +28 -0
  602. package/dist/runtime-client-store.js.map +1 -1
  603. package/dist/runtime-client.d.ts +4 -0
  604. package/dist/runtime-client.js +33 -10
  605. package/dist/runtime-client.js.map +1 -1
  606. package/dist/runtime-coordinator.d.ts +4 -2
  607. package/dist/runtime-coordinator.js +33 -6
  608. package/dist/runtime-coordinator.js.map +1 -1
  609. package/dist/runtime-install.d.ts +6 -1
  610. package/dist/runtime-install.js +12 -4
  611. package/dist/runtime-install.js.map +1 -1
  612. package/dist/runtime-pane-native.js +3 -1
  613. package/dist/runtime-pane-native.js.map +1 -1
  614. package/dist/runtime-personal-answer-only-probe.d.ts +3 -0
  615. package/dist/runtime-personal-answer-only-probe.js +134 -0
  616. package/dist/runtime-personal-answer-only-probe.js.map +1 -0
  617. package/dist/runtime-personal-answer-only.d.ts +16 -0
  618. package/dist/runtime-personal-answer-only.js +54 -0
  619. package/dist/runtime-personal-answer-only.js.map +1 -0
  620. package/dist/runtime-personal-answer.d.ts +30 -0
  621. package/dist/runtime-personal-answer.js +124 -0
  622. package/dist/runtime-personal-answer.js.map +1 -0
  623. package/dist/runtime-personal-preflight.d.ts +8 -0
  624. package/dist/runtime-personal-preflight.js +103 -0
  625. package/dist/runtime-personal-preflight.js.map +1 -0
  626. package/dist/runtime-personal-profile.d.ts +40 -0
  627. package/dist/runtime-personal-profile.js +81 -0
  628. package/dist/runtime-personal-profile.js.map +1 -0
  629. package/dist/runtime-personal-protocol.d.ts +10 -0
  630. package/dist/runtime-personal-protocol.js +15 -0
  631. package/dist/runtime-personal-protocol.js.map +1 -0
  632. package/dist/runtime-personal-stage.d.ts +37 -0
  633. package/dist/runtime-personal-stage.js +167 -0
  634. package/dist/runtime-personal-stage.js.map +1 -0
  635. package/dist/runtime-protocol.d.ts +2 -0
  636. package/dist/settings-api.d.ts +16 -0
  637. package/dist/settings-api.js +294 -86
  638. package/dist/settings-api.js.map +1 -1
  639. package/dist/settings-baseline.d.ts +3 -0
  640. package/dist/settings-baseline.js +2 -2
  641. package/dist/settings-baseline.js.map +1 -1
  642. package/dist/settings-change.js +33 -5
  643. package/dist/settings-change.js.map +1 -1
  644. package/dist/settings-effect.d.ts +3 -0
  645. package/dist/settings-effect.js +29 -3
  646. package/dist/settings-effect.js.map +1 -1
  647. package/dist/settings-http-confirmation.js +18 -44
  648. package/dist/settings-http-confirmation.js.map +1 -1
  649. package/dist/setup-form.js +10 -0
  650. package/dist/setup-form.js.map +1 -1
  651. package/dist/setup-i18n.js +2 -2
  652. package/dist/setup-i18n.js.map +1 -1
  653. package/dist/subagent-records.js +53 -11
  654. package/dist/subagent-records.js.map +1 -1
  655. package/dist/subagent-service.js +3 -1
  656. package/dist/subagent-service.js.map +1 -1
  657. package/dist/tmux-manager.d.ts +2 -0
  658. package/dist/tmux-manager.js +2 -0
  659. package/dist/tmux-manager.js.map +1 -1
  660. package/dist/tool-permissions.js +3 -0
  661. package/dist/tool-permissions.js.map +1 -1
  662. package/dist/tool-progress.d.ts +9 -0
  663. package/dist/tool-progress.js +141 -32
  664. package/dist/tool-progress.js.map +1 -1
  665. package/dist/transcript-needles.d.ts +4 -2
  666. package/dist/transcript-needles.js +35 -4
  667. package/dist/transcript-needles.js.map +1 -1
  668. package/dist/tunnel/lease.d.ts +14 -0
  669. package/dist/tunnel/lease.js +23 -0
  670. package/dist/tunnel/lease.js.map +1 -1
  671. package/dist/turn-reply-guard.d.ts +2 -2
  672. package/dist/turn-reply-guard.js +3 -3
  673. package/dist/turn-reply-guard.js.map +1 -1
  674. package/dist/types.d.ts +12 -2
  675. package/dist/ui/backend-signin.js +91 -22
  676. package/dist/ui/chat-activity-groups.js +41 -8
  677. package/dist/ui/chat-activity.js +5 -3
  678. package/dist/ui/chat-mentions.js +13 -0
  679. package/dist/ui/chat-msg-actions.js +3 -222
  680. package/dist/ui/chat-pins.js +106 -0
  681. package/dist/ui/chat-popout-header.js +2 -2
  682. package/dist/ui/chat-store.js +143 -7
  683. package/dist/ui/chat-tour.js +1 -1
  684. package/dist/ui/chat-workspace.js +3 -3
  685. package/dist/ui/fleet-canvas.js +14 -5
  686. package/dist/ui/fleet-office-card.js +8 -4
  687. package/dist/ui/fleet-office-carousel.d.ts +14 -0
  688. package/dist/ui/fleet-office-carousel.js +95 -0
  689. package/dist/ui/fleet-office-editor.js +6 -1
  690. package/dist/ui/fleet-office-model.js +2 -1
  691. package/dist/ui/fleet-office-pack.d.ts +1 -0
  692. package/dist/ui/fleet-office-pack.js +6 -2
  693. package/dist/ui/fleet-office-play.js +84 -0
  694. package/dist/ui/fleet-office-skin.js +1 -1
  695. package/dist/ui/fleet-office-store.js +37 -2
  696. package/dist/ui/fleet-office-zones.js +55 -10
  697. package/dist/ui/fleet-office.js +281 -32
  698. package/dist/ui/fleet-tasks.js +1 -1
  699. package/dist/ui/host-install.js +5 -2
  700. package/dist/ui/hub-admin-overview.js +189 -0
  701. package/dist/ui/hub-admin-rooms.js +1 -1
  702. package/dist/ui/hub-agent-copy.js +6 -2
  703. package/dist/ui/hub-agent-intro.js +26 -0
  704. package/dist/ui/hub-ai-apps-strings.js +6 -0
  705. package/dist/ui/hub-ai-apps.js +83 -0
  706. package/dist/ui/hub-chat-strings.js +9 -2
  707. package/dist/ui/hub-client.js +87 -5
  708. package/dist/ui/hub-directory-editor-strings.js +2 -2
  709. package/dist/ui/hub-directory-editor.js +1 -0
  710. package/dist/ui/hub-fleet-versions.js +393 -0
  711. package/dist/ui/hub-grant-picker.js +26 -46
  712. package/dist/ui/hub-group-policy.js +26 -13
  713. package/dist/ui/hub-group-strings.js +26 -17
  714. package/dist/ui/hub-join-steps.js +27 -15
  715. package/dist/ui/hub-my-agents-model.js +42 -0
  716. package/dist/ui/hub-my-agents-strings.js +18 -0
  717. package/dist/ui/hub-my-agents.js +141 -0
  718. package/dist/ui/hub-owner-strings.js +7 -7
  719. package/dist/ui/hub-personal-agent-strings.js +246 -0
  720. package/dist/ui/hub-personal-agent.js +118 -0
  721. package/dist/ui/hub-policy-subjects.js +35 -0
  722. package/dist/ui/hub-quick-pairing.js +7 -2
  723. package/dist/ui/hub-role-audit.js +39 -0
  724. package/dist/ui/hub-role-forms.js +99 -0
  725. package/dist/ui/hub-role-notices.js +11 -0
  726. package/dist/ui/hub-role-view.js +86 -0
  727. package/dist/ui/hub-roles-strings.js +439 -0
  728. package/dist/ui/hub-roles.js +83 -0
  729. package/dist/ui/hub-room-agent-strings.js +28 -0
  730. package/dist/ui/hub-room-composer.js +45 -13
  731. package/dist/ui/hub-room-favorites.js +63 -5
  732. package/dist/ui/hub-room-list.js +5 -3
  733. package/dist/ui/hub-room-members-strings.js +2 -2
  734. package/dist/ui/hub-room-members.js +9 -5
  735. package/dist/ui/hub-room-new.js +1 -1
  736. package/dist/ui/hub-room-notify.js +161 -0
  737. package/dist/ui/hub-room-search.js +126 -0
  738. package/dist/ui/hub-room-settings.js +6 -0
  739. package/dist/ui/hub-room-source-strings.js +17 -0
  740. package/dist/ui/hub-room-source.js +34 -0
  741. package/dist/ui/hub-room-strings.js +49 -3
  742. package/dist/ui/hub-room-thread.js +269 -42
  743. package/dist/ui/hub-room-unread.js +2 -1
  744. package/dist/ui/hub-strings.js +13 -5
  745. package/dist/ui/hub-subject-picker.js +58 -0
  746. package/dist/ui/hub-switcher.js +2 -2
  747. package/dist/ui/hub-teams-strings.js +10 -6
  748. package/dist/ui/hub-teams.js +56 -28
  749. package/dist/ui/hub-this-hub.js +2 -2
  750. package/dist/ui/hub-welcome.js +122 -75
  751. package/dist/ui/image-annotate.js +2 -283
  752. package/dist/ui/image-lightbox.js +2 -176
  753. package/dist/ui/image-zoom.js +2 -242
  754. package/dist/ui/model-picker.js +4 -1
  755. package/dist/ui/notice-hub-sharing.js +81 -0
  756. package/dist/ui/notice-hub-update.js +94 -0
  757. package/dist/ui/office-share-dialog.js +2 -2
  758. package/dist/ui/panel-chat.js +327 -28
  759. package/dist/ui/panel-details.js +3 -1
  760. package/dist/ui/panel-fleet.js +28 -7
  761. package/dist/ui/panel-hub.js +303 -103
  762. package/dist/ui/panel-log.js +4 -4
  763. package/dist/ui/panel-notices.js +4 -1
  764. package/dist/ui/panel-settings.js +45 -34
  765. package/dist/ui/preview-panel.js +3 -1
  766. package/dist/ui/reply-file-preview.js +64 -0
  767. package/dist/ui/runtime-commands.d.ts +2 -2
  768. package/dist/ui/runtime-commands.js +7 -4
  769. package/dist/ui/settings-access-overview.js +3 -3
  770. package/dist/ui/settings-appearance.js +7 -10
  771. package/dist/ui/settings-archive-files.js +109 -0
  772. package/dist/ui/settings-build-version.js +2 -2
  773. package/dist/ui/settings-catalog.js +22 -0
  774. package/dist/ui/settings-connector-strings.js +23 -0
  775. package/dist/ui/settings-connector.js +39 -0
  776. package/dist/ui/settings-guests-entries.js +16 -0
  777. package/dist/ui/settings-guests.js +57 -15
  778. package/dist/ui/settings-hub-connection.js +6 -7
  779. package/dist/ui/settings-hub-membership.js +6 -7
  780. package/dist/ui/settings-hub-page-sharing.js +52 -0
  781. package/dist/ui/settings-hub-section.js +2 -4
  782. package/dist/ui/settings-hub-setup.js +2 -1
  783. package/dist/ui/settings-hub-updates.js +67 -0
  784. package/dist/ui/settings-hub.js +34 -6
  785. package/dist/ui/settings-layout.js +10 -12
  786. package/dist/ui/settings-registry.js +19 -3
  787. package/dist/ui/settings-shared-strings.js +2 -0
  788. package/dist/ui/settings-strings.js +13 -2
  789. package/dist/ui/settings-update.js +11 -5
  790. package/dist/ui/settings-web-authority.js +7 -5
  791. package/dist/ui/shared/access-overview.css +1 -1
  792. package/dist/ui/shared/accounts-keepalive.css +1 -1
  793. package/dist/ui/shared/accounts.css +1 -1
  794. package/dist/ui/shared/agent-sheet.js +116 -0
  795. package/dist/ui/shared/agent-widget.js +1 -2
  796. package/dist/ui/shared/app-i18n.js +4 -0
  797. package/dist/ui/shared/app-nav.js +9 -5
  798. package/dist/ui/shared/app-prefs.js +9 -3
  799. package/dist/ui/shared/app-route.js +4 -2
  800. package/dist/ui/shared/app-shell.js +184 -23
  801. package/dist/ui/shared/app-store.js +7 -3
  802. package/dist/ui/shared/app-stream.js +6 -2
  803. package/dist/ui/shared/app-swipe.js +3 -1
  804. package/dist/ui/shared/app-themes.js +3 -5
  805. package/dist/ui/shared/app-update.js +90 -8
  806. package/dist/ui/shared/app.css +469 -203
  807. package/dist/ui/shared/app.js +1 -1
  808. package/dist/ui/shared/chat-composer.js +29 -5
  809. package/dist/ui/shared/chat-msg-actions.js +231 -0
  810. package/dist/ui/shared/chat-strings.js +19 -4
  811. package/dist/ui/shared/chat-thread.js +120 -17
  812. package/dist/ui/shared/chat-work-bar.css +118 -0
  813. package/dist/ui/shared/connector-prompt.d.ts +3 -0
  814. package/dist/ui/shared/connector-prompt.js +20 -0
  815. package/dist/ui/shared/hub-ai-apps.css +12 -0
  816. package/dist/ui/shared/hub-chat.css +61 -4
  817. package/dist/ui/shared/hub-groups.css +19 -15
  818. package/dist/ui/shared/hub-my-agents.css +35 -0
  819. package/dist/ui/shared/hub-owner.css +118 -3
  820. package/dist/ui/shared/hub-roles.css +99 -0
  821. package/dist/ui/shared/hub-rooms-u2.css +34 -0
  822. package/dist/ui/shared/hub.css +23 -5
  823. package/dist/ui/shared/image-annotate.css +22 -3
  824. package/dist/ui/shared/image-annotate.js +415 -0
  825. package/dist/ui/shared/image-lightbox.js +218 -0
  826. package/dist/ui/shared/image-zoom.js +316 -0
  827. package/dist/ui/shared/instance-nav.js +120 -15
  828. package/dist/ui/shared/loading.css +1 -1
  829. package/dist/ui/shared/model-picker.css +32 -4
  830. package/dist/ui/shared/owner-css.js +1 -1
  831. package/dist/ui/shared/panel-view.js +7 -1
  832. package/dist/ui/shared/preview-panel-actions.js +1 -1
  833. package/dist/ui/shared/preview-panel.js +6 -2
  834. package/dist/ui/shared/reply-previews.css +4 -0
  835. package/dist/ui/shared/runtime-install.css +5 -0
  836. package/dist/ui/shared/settings-connector.css +7 -0
  837. package/dist/ui/shared/signin.js +27 -12
  838. package/dist/ui/shared/task-board.css +2 -2
  839. package/dist/ui/shared/theme.js +52 -0
  840. package/dist/ui/shared/tokens.css +27 -10
  841. package/dist/ui/shared/ui-icons.js +2 -0
  842. package/dist/ui/shared/ui-toast.js +4 -4
  843. package/dist/ui/shared/usage-dialog.js +113 -17
  844. package/dist/ui/shared/view-strings.js +26 -4
  845. package/dist/ui/shared/web-authorize.js +3 -3
  846. package/dist/ui/signin.html +4 -2
  847. package/dist/ui/structured-signin.js +64 -12
  848. package/dist/ui/web-terminal/terminal.css +1 -1
  849. package/dist/ui/workspace-panel.js +4 -3
  850. package/dist/update-dispatch.d.ts +8 -1
  851. package/dist/update-dispatch.js +16 -1
  852. package/dist/update-dispatch.js.map +1 -1
  853. package/dist/update-idle.d.ts +65 -0
  854. package/dist/update-idle.js +190 -0
  855. package/dist/update-idle.js.map +1 -0
  856. package/dist/update-launch.d.ts +1 -1
  857. package/dist/update-launch.js +9 -2
  858. package/dist/update-launch.js.map +1 -1
  859. package/dist/usage/i18n-keys.d.ts +1 -1
  860. package/dist/usage/i18n-keys.js +1 -1
  861. package/dist/usage/i18n-keys.js.map +1 -1
  862. package/dist/usage/profile-timeline.d.ts +2 -0
  863. package/dist/usage/profile-timeline.js +4 -0
  864. package/dist/usage/profile-timeline.js.map +1 -1
  865. package/dist/usage/providers.js +6 -6
  866. package/dist/usage/providers.js.map +1 -1
  867. package/dist/usage/quota-history.d.ts +1 -1
  868. package/dist/view-api.js +1 -1
  869. package/dist/view-api.js.map +1 -1
  870. package/dist/web-api.d.ts +13 -1
  871. package/dist/web-api.js +489 -189
  872. package/dist/web-api.js.map +1 -1
  873. package/dist/web-backend-login.d.ts +5 -1
  874. package/dist/web-backend-login.js +8 -2
  875. package/dist/web-backend-login.js.map +1 -1
  876. package/dist/web-chat-archive.d.ts +147 -0
  877. package/dist/web-chat-archive.js +530 -0
  878. package/dist/web-chat-archive.js.map +1 -0
  879. package/dist/web-chat-history.d.ts +76 -0
  880. package/dist/web-chat-history.js +145 -1
  881. package/dist/web-chat-history.js.map +1 -1
  882. package/dist/web-commands.d.ts +4 -3
  883. package/dist/web-commands.js +3 -2
  884. package/dist/web-commands.js.map +1 -1
  885. package/dist/web-guest-access.d.ts +3 -0
  886. package/dist/web-guest-access.js +6 -2
  887. package/dist/web-guest-access.js.map +1 -1
  888. package/dist/web-icons.js +3 -3
  889. package/dist/web-icons.js.map +1 -1
  890. package/dist/web-login.d.ts +7 -0
  891. package/dist/web-login.js +8 -1
  892. package/dist/web-login.js.map +1 -1
  893. package/dist/web-mentions.d.ts +2 -0
  894. package/dist/web-mentions.js +20 -0
  895. package/dist/web-mentions.js.map +1 -1
  896. package/dist/web-notices.d.ts +20 -0
  897. package/dist/web-notices.js +64 -8
  898. package/dist/web-notices.js.map +1 -1
  899. package/dist/web-office-store.d.ts +2 -0
  900. package/dist/web-office-store.js +15 -3
  901. package/dist/web-office-store.js.map +1 -1
  902. package/dist/web-pin-store.d.ts +58 -0
  903. package/dist/web-pin-store.js +170 -0
  904. package/dist/web-pin-store.js.map +1 -0
  905. package/dist/web-prefs.js +5 -1
  906. package/dist/web-prefs.js.map +1 -1
  907. package/dist/web-session-authorization.d.ts +24 -0
  908. package/dist/web-session-authorization.js +32 -0
  909. package/dist/web-session-authorization.js.map +1 -1
  910. package/dist/web-session.d.ts +6 -4
  911. package/dist/web-session.js +5 -3
  912. package/dist/web-session.js.map +1 -1
  913. package/dist/web-settings-patch.d.ts +24 -3
  914. package/dist/web-settings-patch.js +57 -1
  915. package/dist/web-settings-patch.js.map +1 -1
  916. package/dist/web-shell-routes.d.ts +1 -1
  917. package/dist/web-shell-routes.js +1 -1
  918. package/dist/web-shell-routes.js.map +1 -1
  919. package/dist/web-theme.js +2 -2
  920. package/dist/web-update.d.ts +15 -1
  921. package/dist/web-upload.d.ts +36 -0
  922. package/dist/web-upload.js +105 -5
  923. package/dist/web-upload.js.map +1 -1
  924. package/dist/windows-cli-api.d.ts +10 -7
  925. package/dist/windows-cli-api.js +13 -12
  926. package/dist/windows-cli-api.js.map +1 -1
  927. package/dist/windows-cli-worker.d.ts +10 -0
  928. package/dist/windows-cli-worker.js +109 -14
  929. package/dist/windows-cli-worker.js.map +1 -1
  930. package/dist/windows-cli.d.ts +10 -1
  931. package/dist/windows-cli.js +47 -13
  932. package/dist/windows-cli.js.map +1 -1
  933. package/package.json +1 -1
  934. package/templates/runtime-install/install.ps1 +24 -4
@@ -1,3 +1,6 @@
1
+ import { hubSharingNoticeText } from "./hub-sharing-notice.js";
2
+ import { hubPageSharingSettings } from "./hub-page-sharing-settings.js";
3
+ import { replyPreviews } from "./reply-preview-spec.js";
1
4
  import { settingsSummary, translatedSummary } from "./settings-summary.js";
2
5
  import { readInstalledBuild } from "./build-provenance.js";
3
6
  import { buildNativeFleetInstructions } from "./instructions.js";
@@ -63,6 +66,7 @@ import { measureSyncWork } from "./sync-work-attribution.js";
63
66
  import { RuntimeCpuProfiler, ProfileBusyError, profileDuration } from "./runtime-cpu-profile.js";
64
67
  import { ProfileControlServer } from "./profile-control.js";
65
68
  import { existsSync, readFileSync, mkdirSync, writeFileSync, unlinkSync, rmSync, readdirSync, renameSync, copyFileSync, chmodSync, statSync, realpathSync, lstatSync, constants as fsConstants, openSync, closeSync, fsyncSync } from "node:fs";
69
+ import { HubContactWindows } from "./hub-contact-windows.js";
66
70
  import { atomicWriteFileSync } from "./atomic-write.js";
67
71
  import { createHash, randomBytes, randomUUID } from "node:crypto";
68
72
  import { freemem, totalmem, homedir, hostname } from "node:os";
@@ -105,7 +109,7 @@ import { getEffectiveInstanceDefaults, loadFleetConfig, loadRawFleetConfig, load
105
109
  import { EventLog } from "./event-log.js";
106
110
  import { binaryProbe } from "./binary-probe.js";
107
111
  import { deletePlannedTopic, planInstanceTopicDelete, topicDestination, topicMustStay } from "./instance-topic-delete.js";
108
- import { AVAILABILITY_STALE_MS, BackendAvailabilityStore, versionAtLeast, hostAvailabilityProbes, findExecutableIn, resolveBackendBinary } from "./backend-availability.js";
112
+ import { AVAILABILITY_STALE_MS, BackendAvailabilityStore, structuredSignInReady, hostAvailabilityProbes, findExecutableIn, resolveBackendBinary } from "./backend-availability.js";
109
113
  import { classifySqliteOpenError } from "./sqlite-open-errors.js";
110
114
  import { OutboxOpenError } from "./outbox-open-error.js";
111
115
  import { AdapterWorld } from "./adapter-world.js";
@@ -134,7 +138,7 @@ import { routeToolCall } from "./channel/tool-router.js";
134
138
  import { Scheduler } from "./scheduler/index.js";
135
139
  import { boardActivity, boardCardLimit, boardToolAction } from "./task-board-tool.js";
136
140
  import { TaskBoardWaker, namesCard } from "./task-board-waker.js";
137
- import { DispatcherLiveness, LIVENESS_STARTUP_GRACE_MS, livenessSettings } from "./dispatcher-liveness.js";
141
+ import { DispatcherLiveness, LIVENESS_STARTUP_GRACE_MS, livenessSettings, questionNotices, turnQuestion } from "./dispatcher-liveness.js";
138
142
  import { TaskBoardError, waitsForPerson, wrapUpGap } from "./scheduler/task-board.js";
139
143
  import { escapeTelegramHtml, scheduleClock, scheduleRetryLabel } from "./scheduler/retry-label.js";
140
144
  import { DEFAULT_SCHEDULER_CONFIG } from "./scheduler/index.js";
@@ -228,7 +232,7 @@ import { RuntimeWindowsBridge } from "./runtime-windows-bridge.js";
228
232
  import { FleetWindowsRuntime } from "./fleet-windows-runtime.js";
229
233
  import { NativeMcpSessions } from "./native-mcp.js";
230
234
  import { nativeProviderMcpSupported } from "./windows-cli-providers.js";
231
- import { cachedNativeModelCatalog } from "./native-model-catalog.js";
235
+ import { cachedNativeModelCatalog, refreshNativeModelCatalogAfterSignIn } from "./native-model-catalog.js";
232
236
  import { shapeWebModelCatalog } from "./web-model-groups.js";
233
237
  import { isWindowsInstance, isNativePaneInstance, isNativeExecInstance, WINDOWS_CONFIG_REFUSED, nativeCredentialProfile } from "./native-instance-registry.js";
234
238
  import { createNativeWindowsInstance, updateNativeWindowsInstance } from "./native-instance-api.js";
@@ -238,12 +242,14 @@ import { viewHistory } from "./view-history.js";
238
242
  import { WebChatHistory, WEB_CHAT_TEXT_MAX, isWebMessageId, newWebMessageId, webChatFrom } from "./web-chat-history.js";
239
243
  import { WEB_ECHO_COPIES_MAX, WEB_MIRROR_TIMEOUT_MS, webReactionEmoji, webReactionProblem } from "./web-reactions.js";
240
244
  import { WebChatDiskStore, isSafeInstanceDirName } from "./web-chat-store.js";
245
+ import { WebChatArchive } from "./web-chat-archive.js";
241
246
  import { SeenUsers, resolveMentions } from "./web-mentions.js";
242
247
  import { OPERATOR, WebPrefsStore } from "./web-prefs.js";
243
248
  import { agendVersion } from "./agent-whats-new.js";
244
249
  import { OwnerCssStore } from "./web-owner-css-store.js";
245
250
  import { ThemeStore } from "./web-theme-store.js";
246
251
  import { OfficeStore, OfficeWriteLimiter } from "./web-office-store.js";
252
+ import { WebPinStore } from "./web-pin-store.js";
247
253
  import { OfficeSkinStore } from "./web-office-skins.js";
248
254
  import { OfficeActs } from "./web-office-acts.js";
249
255
  import { OFFICE_PACK_TOOLS, OfficePackTools } from "./web-office-pack-tools.js";
@@ -256,7 +262,7 @@ import { parsePoll } from "./reply-polls.js";
256
262
  import { isUploadRequest, limitRequestReceive, publicAttachment, sweepOrphanedUploads, UPLOAD_REQUEST_TIMEOUT_MS, uploadLimits, WebFileLedger } from "./web-upload.js";
257
263
  import { REPLY_FILES_MAX_BYTES, snapshotReplyFile, sweepReplySnapshots, webFilesDir } from "./web-reply-files.js";
258
264
  import { cardPicture, handleViewRequest, humanCards, identityColors, instanceTeams, isViewPath, personBannerFocus, personIdentityColour, profileIdentities, resolveInstanceIdentity, setPersonBannerFocus, setPersonIdentityColour } from "./view-api.js";
259
- import { autoIdentityColor } from "./web-identity-color.js";
265
+ import { autoIdentityColor, identityColorValue } from "./web-identity-color.js";
260
266
  import { AppearanceTools } from "./web-appearance-tools.js";
261
267
  import { cardVersion, resolveCard } from "./web-card.js";
262
268
  import { ModStore } from "./web-mod-store.js";
@@ -285,7 +291,8 @@ import { GUEST_COMMAND_RUNS, GUEST_PREF_WRITES, GUEST_SEARCHES, bindGuestRequest
285
291
  import { GUEST_ROOM_TICK_MS, GuestRoomMembership, guestGroupRooms } from "./web-guest-rooms.js";
286
292
  import { Delegations, TrafficLog, trafficItem } from "./fleet-traffic.js";
287
293
  import { installedChannel, updateNoticeKey } from "./update-check.js";
288
- import { resolveInstalledAgend } from "./update-dispatch.js";
294
+ import { resolveInstalledAgend, npmForRunningInstall } from "./update-dispatch.js";
295
+ import { HUB_UPDATE_NOTICE_FILE, HUB_UPDATE_REMIND_MS, hubNoticeDue, hubNoticeKey, readHubNoticeState, writeHubNoticeState } from "./hub-update-notice.js";
289
296
  import { resolveUpdateLaunch, openUpdateLog, updateLogPath, watchUpdateLaunch } from "./update-launch.js";
290
297
  import { isWebUpdateTarget, readLogTail, RUNNING_AGEND_VERSION, updateOffer, webProgressOf, webUpdateTarget } from "./web-update.js";
291
298
  import { admitProfileLogin, LoginController, LOGIN_TOKEN_RESEND_PREFIX, POST_LOGIN_RECOVERY_DEADLINE_MS } from "./login-controller.js";
@@ -307,6 +314,7 @@ import { handleAgentRequest, ToolNotPermittedError } from "./agent-endpoint.js";
307
314
  import { AgentCredentials, agentCredentialPolicy } from "./agent-credentials.js";
308
315
  import { writeSecretFile } from "./secret-file.js";
309
316
  import { ConfigHistory, ConfigSyntaxError, configIssueText } from "./config-history.js";
317
+ import { HubClassicPrivateTurns } from "./hub-classic-private.js";
310
318
  import { ClassicChannelManager, classicWebEchoOn, getClassicBackendChoices, inferClassicChannelType, isSelectableClassicBackend, readClassicLastActivityAt, readClassicRoomNames } from "./classic-channel-manager.js";
311
319
  import { assertExplicitInstanceRemoval } from "./instance-removal.js";
312
320
  import { KNOWN_BACKENDS, validateFleetConfig } from "./config-validator.js";
@@ -317,6 +325,9 @@ import { assertNoSessionOomStop, readSessionOomStop, captureSessionOomRetry, cle
317
325
  import { redactSecrets } from "./tool-progress.js";
318
326
  import { idleGateTimeoutLog } from "./idle-gate-log.js";
319
327
  import { DEFAULT_STUCK_TIMEOUT_MS, readLastInboundAt } from "./daemon.js";
328
+ import { CODEX_INLINE_MODEL_MIN, codexModelCommand } from "./backend/codex-model-switch.js";
329
+ import { CLI_RUNTIME_SWITCH } from "./backend/cli-runtime-switch.js";
330
+ import { readKiroLedger } from "./backend/kiro-engine-ledger.js";
320
331
  import { clearPausedMarker, readPausedAt, readPauseReason, writePausedMarker } from "./pause-marker.js";
321
332
  import { readBackgroundWorkEndedMarker } from "./background-work-ended.js";
322
333
  import { DEFAULT_WARM_OVERFLOW, WakeCoordinator } from "./wake-coordinator.js";
@@ -324,7 +335,7 @@ import { TargetQueueWorker } from "./target-queue-worker.js";
324
335
  import { resolveDeliveryWorkerMode } from "./types.js";
325
336
  import { isFleetStartCommandLine, readProcessCommandLine, releaseProcessFleetLock } from "./fleet-lock.js";
326
337
  import { isSetupComplete, markSetupComplete } from "./setup-marker.js";
327
- import { manualCleanupMessage, reapStaleTunnel } from "./tunnel/lease.js";
338
+ import { reapLeftoverTunnels } from "./tunnel/lease.js";
328
339
  import { buildToolPermissionsNotice } from "./tool-permissions-notice.js";
329
340
  import { NeedsYouHub } from "./needs-you-hub.js";
330
341
  import { SignInKeepAlive, isKeepAliveBackend } from "./signin-keepalive.js";
@@ -352,7 +363,7 @@ import { findSigninKnownEntry, addSigninKnownDevice } from "./web-signin-device.
352
363
  import { adminKey, HOST_ADMIN_KEY, isOutsideLinkOwner, OUTSIDE_LINK_OWNER, OUTSIDE_LINK_RETRY_MS, OUTSIDE_OWN_CLOSES, outsideDuration, outsideTimer, TOTP_SIGNIN_OVER_PUBLIC_LINK, TOTP_STEP_SECONDS, WEB_REMOTE_ACCESS_FILE, WebRemoteAccess } from "./web-remote-access.js";
353
364
  import { evaluateSettingsRole } from "./authority/settings-role.js";
354
365
  import { authorityNow, evaluateWebAuthority, HOST_OPERATOR, VERIFIED_SESSION_HOURS, webAuthorityPolicy } from "./authority/web-authority.js";
355
- import { AuthorityStateStore } from "./authority/authority-state.js";
366
+ import { AuthorityStateStore, namedLinkLastTurnedOff } from "./authority/authority-state.js";
356
367
  import { SessionAuthorizations } from "./authority/session-authorizations.js";
357
368
  import { SessionAuthorizationRequests } from "./web-session-authorization.js";
358
369
  import { GuestLoginCodes, WebLoginCodes, LOGIN_CODE_TTL_MS } from "./web-login.js";
@@ -612,6 +623,10 @@ const HANG_CALLBACK_PREFIX = "hang:";
612
623
  const CLEAR_CONFIRM_CALLBACK_PREFIX = "clear-confirm:";
613
624
  /** #2598 B2: a kiro classic → TUI move's Confirm in General. "kiro-migrate:" (13) + 32 hex + ":confirm" (8) = 53 bytes. */
614
625
  const KIRO_MIGRATE_CALLBACK_PREFIX = "kiro-migrate:";
626
+ /** M-3140: Update now on a Hub-recommended-version notice in General ("hub-update:" + 32 hex + ":update" = 50 bytes). */
627
+ const HUB_UPDATE_CALLBACK_PREFIX = "hub-update:";
628
+ const HUB_SHARING_CALLBACK_PREFIX = "hub-share:";
629
+ const HUB_FLEET_UPDATE_CALLBACK_PREFIX = "hub-fleet-update:";
615
630
  const KIRO_RECONCILE_CALLBACK_PREFIX = "kiro-reconcile:";
616
631
  /** #2692: a fleet admin's Approve / Reject on an agent's pending skin-pack change, in General. */
617
632
  const OFFICE_PACK_CALLBACK_PREFIX = "office-pack:";
@@ -685,6 +700,13 @@ const NONCE_RETIRE_BUDGET_MS = 5_000;
685
700
  * so nothing re-probed and `/model` kept serving a list up to 24h old.
686
701
  */
687
702
  const CLI_ENV_FRESH_MS = 60 * 60 * 1000;
703
+ /**
704
+ * How long a menu that opens on an empty model list waits for its one discovery, and how long an attempt that
705
+ * found nothing (a CLI not signed in, offline) is not repeated by the next open. Shorter than CLI_ENV_PROBE_DEADLINE_MS: a
706
+ * slower probe finishes behind the menu and the page reads again (the `models` event).
707
+ */
708
+ const MODEL_OPEN_PROBE_WAIT_MS = 12_000;
709
+ const MODEL_OPEN_PROBE_COOLDOWN_MS = 60_000;
688
710
  /**
689
711
  * Upper bound on a live probe driven by `/model`.
690
712
  *
@@ -708,6 +730,8 @@ const CLI_ENV_FRESH_MS = 60 * 60 * 1000;
708
730
  */
709
731
  /** #1690: how long `/model` waits for the daemon's word on our own runtime switch (its dialog wait plus settling). */
710
732
  export const RUNTIME_SWITCH_RESULT_MS = 12_000;
733
+ /** M-3175: a codex switch may wait up to a minute for its pane to be idle, then up to 10 s for codex to record it. */
734
+ export const CODEX_RUNTIME_SWITCH_RESULT_MS = 80_000;
711
735
  export const CLI_ENV_PROBE_DEADLINE_MS = 16_000;
712
736
  /**
713
737
  * How many CLIs may cold-start at once, from BOTH memory and cores.
@@ -1440,14 +1464,14 @@ export class FleetManager {
1440
1464
  return { result: null, error: "Native panes can only read Windows runtime model inventories" };
1441
1465
  return { result: await this.listModelCatalog({ instanceName: target }) };
1442
1466
  }
1443
- const ops = { list_instances: "list", describe_instance: "describe", task: "task", send_to_instance: "send",
1467
+ const ops = { hub_room_list: "hub-room-list", hub_room_post: "hub-room-post", hub_room_members: "hub-room-members", hub_people_search: "hub-people-search", list_instances: "list", describe_instance: "describe", task: "task", send_to_instance: "send",
1444
1468
  delegate_task: "delegate", request_information: "ask", report_result: "report", delivery_status: "delivery-status" };
1445
1469
  const { nativeAgentAdmissionContext } = await import("./native-agent-admission.js");
1446
1470
  const { dispatchAgentOperation } = await import("./agent-endpoint.js");
1447
1471
  return daemon.handlePaneToolCall(input, { current, allowed: tool => allowed(name, tool),
1448
1472
  dispatch: (tool, args) => ops[tool] ? dispatchAgentOperation(nativeAgentAdmissionContext(this, {
1449
1473
  instance: name, current: () => current() && allowed(name, tool), taskAllowed: () => current() && allowed(name, "task"),
1450
- }), name, ops[tool], args, input.operationId) : undefined });
1474
+ }), name, ops[tool], args, input.operationId, () => current() && allowed(name, tool)) : undefined });
1451
1475
  },
1452
1476
  });
1453
1477
  }
@@ -1671,6 +1695,344 @@ export class FleetManager {
1671
1695
  }
1672
1696
  invalidateHubCompanyJoin() { this.companyJoinController?.invalidate(); }
1673
1697
  hubMemberPairingApi = null;
1698
+ hubRecommendationRead = null;
1699
+ hubRecommendationListeners = new Set();
1700
+ hubRecommendedUpdate() { return this.hubRecommendationRead?.() ?? null; }
1701
+ /**
1702
+ * M-3140: the Hub's advice the asker was shown, if it is still this Fleet's current verified advice and still newer
1703
+ * than what runs (same Hub, version and revision) — else null. What a pinned Update installs comes only from here.
1704
+ */
1705
+ hubRecommendationFor(pin) {
1706
+ const advice = this.hubRecommendedUpdate();
1707
+ if (!advice || advice.version !== pin.version || advice.revision !== pin.revision)
1708
+ return null;
1709
+ let current;
1710
+ try {
1711
+ current = this.runningAgendVersion();
1712
+ }
1713
+ catch {
1714
+ return null;
1715
+ }
1716
+ return this.semverGt(advice.version, current) ? advice : null;
1717
+ }
1718
+ onHubRecommendation(listener) { this.hubRecommendationListeners.add(listener); return () => { this.hubRecommendationListeners.delete(listener); }; }
1719
+ hubRecommendationChanged() {
1720
+ for (const listener of this.hubRecommendationListeners) {
1721
+ try {
1722
+ listener();
1723
+ }
1724
+ catch { /* local presentation observer */ }
1725
+ }
1726
+ void this.maybeNotifyHubRecommendation(); // M-3140: the first notice need not wait for the daily check
1727
+ }
1728
+ /**
1729
+ * M-3140 (spec §3.3, chat): the Hub's recommended version in General, with Update now — when it first applies to this
1730
+ * Fleet, then every 7 days while still behind (hub-update-notice.ts). A web-only fleet has no chat: its banner says it.
1731
+ * Asked on every change of the advice and on the daily update check.
1732
+ */
1733
+ async maybeNotifyHubRecommendation() {
1734
+ if (this.hubUpdateNoticeBusy || this.shuttingDown)
1735
+ return;
1736
+ this.hubUpdateNoticeBusy = true;
1737
+ try {
1738
+ const advice = this.hubRecommendedUpdate();
1739
+ let current = null;
1740
+ try {
1741
+ current = this.runningAgendVersion();
1742
+ }
1743
+ catch {
1744
+ return;
1745
+ }
1746
+ const path = join(this.dataDir, HUB_UPDATE_NOTICE_FILE), now = Date.now();
1747
+ if (!hubNoticeDue(readHubNoticeState(path), advice, current, now, (a, b) => this.semverGt(a, b)) || !advice)
1748
+ return;
1749
+ if (this.webOnlyPromptPlace())
1750
+ return;
1751
+ const general = this.findGeneralInstance();
1752
+ const adapterId = general ? this.getInstanceAdapterId(general) : undefined;
1753
+ const adapter = general ? this.getAdapterForInstance(general) : undefined;
1754
+ const chatId = general ? this.getGroupIdForInstance(general) : undefined;
1755
+ const topic = general ? String(this.fleetConfig?.instances[general]?.topic_id ?? "") : "";
1756
+ if (!general || !adapterId || !adapter || !chatId)
1757
+ return;
1758
+ const nonce = await this.postNonceButtonPromptOrThrow({
1759
+ prefix: HUB_UPDATE_CALLBACK_PREFIX, alertType: "tip", instanceName: general, adapter, adapterId, chatId,
1760
+ ...(topic ? { threadId: topic } : {}),
1761
+ message: t("hub_update.notice", advice.hubName, `v${advice.version}`, `v${current}`),
1762
+ choices: [{ action: "update", label: t("hub_update.button") }],
1763
+ expiredText: t("hub_update.expired"),
1764
+ timeoutMs: HUB_UPDATE_REMIND_MS,
1765
+ });
1766
+ this.pendingHubUpdates.set(nonce, { version: advice.version, revision: advice.revision });
1767
+ const expiry = setTimeout(() => this.pendingHubUpdates.delete(nonce), HUB_UPDATE_REMIND_MS + 60_000);
1768
+ expiry.unref?.();
1769
+ writeHubNoticeState(path, { key: hubNoticeKey(advice), at: now });
1770
+ }
1771
+ catch (err) {
1772
+ this.logger.warn({ err: err.message }, "Hub recommended-version notice not posted");
1773
+ }
1774
+ finally {
1775
+ this.hubUpdateNoticeBusy = false;
1776
+ }
1777
+ }
1778
+ /**
1779
+ * M-3140: Update now on that notice — what chat /update does (a fleet admin's, the installed agend launched
1780
+ * independently, its progress on the message), pinned to the advice the notice named, re-read now and at the launch.
1781
+ */
1782
+ async handleHubUpdateCallback(data, adapterId, adapter) {
1783
+ // Fable #3955: a fleet admin's press only. Anyone else in General is told privately, and the nonce and the button stay
1784
+ // for an admin (consumeNonceCallback's authorize: refused before anything is consumed or retired).
1785
+ const claimed = this.consumeNonceCallback(HUB_UPDATE_CALLBACK_PREFIX, /^hub-update:([0-9a-f]{32}):(update)$/, data, adapterId, adapter, undefined, userId => this.fleetAdminGate(userId, adapterId) === "ok");
1786
+ if (claimed === null)
1787
+ return false;
1788
+ if (claimed === "consumed")
1789
+ return true;
1790
+ const { entry } = claimed;
1791
+ const nonce = data.callbackData.slice(HUB_UPDATE_CALLBACK_PREFIX.length, HUB_UPDATE_CALLBACK_PREFIX.length + 32);
1792
+ const pin = this.pendingHubUpdates.get(nonce);
1793
+ this.pendingHubUpdates.delete(nonce);
1794
+ const messageId = entry.messageId ?? data.messageId;
1795
+ const advice = pin ? this.hubRecommendationFor(pin) : null;
1796
+ if (!pin || !advice) {
1797
+ await this.retireNonceButtons(entry, messageId, t("hub_update.changed"));
1798
+ return true;
1799
+ }
1800
+ const by = data.userId ?? "";
1801
+ await this.retireNonceButtons(entry, messageId, t("update.progress.preparing", 0));
1802
+ if (messageId && entry.adapter)
1803
+ this.beginUpdateProgress(entry.adapter, entry.chatId, entry.threadId, messageId);
1804
+ await this.launchInstalledUpdate(`hub-recommended /update by ${adapterId}:${by}`, () => this.fleetAdminGate(by, adapterId) === "ok" && !this.shuttingDown && this.hubRecommendationFor(pin) !== null, advice.version);
1805
+ return true;
1806
+ }
1807
+ hubUpdates = null;
1808
+ hubUpdateOwned = null;
1809
+ hubUpdateBootProgress = null;
1810
+ pendingHubFleetUpdates = new Map();
1811
+ hubFleetUpdates() { return this.hubUpdates; }
1812
+ hubUpdateIdle() {
1813
+ if (!this.startupComplete || this.shuttingDown || this.reconcileInFlight || this.topicCleanupInFlight
1814
+ || this.deliveryPumpRunning || (this.webUpdateOwned && this.webUpdateOwned !== this.hubUpdateOwned?.claim))
1815
+ return false;
1816
+ for (const name of Object.keys(this.fleetConfig?.instances ?? {})) {
1817
+ if (this.restartsInFlight.has(name) || this.stopsInFlight.has(name) || this.handOffsInFlight.has(name)
1818
+ || this.ipcConnectInFlight.has(name) || this.ipcReconnectInFlight.has(name) || this.hasPendingIdleGatedDelivery(name)
1819
+ || this.webChannelEchoTails.has(name))
1820
+ return false;
1821
+ const worker = this.queueWorkers.get(name);
1822
+ if (worker?.busy || worker?.inFlight)
1823
+ return false;
1824
+ const process = this.getInstanceStatus(name);
1825
+ if (process === "stopped" || process === "crashed")
1826
+ continue;
1827
+ if (process === "paused" && ["stopped", "crashed"].includes(this.daemons.get(name)?.getProcessStatus?.() ?? "unknown"))
1828
+ continue;
1829
+ if (process !== "running" || this.getInstanceExecutionState(name) !== "idle")
1830
+ return false;
1831
+ if (this.getInstanceInteraction(name)?.phase === "waiting")
1832
+ return false;
1833
+ }
1834
+ return true;
1835
+ }
1836
+ async hubUpdateCanInstall() {
1837
+ const found = await npmForRunningInstall();
1838
+ if ("reason" in found)
1839
+ return false;
1840
+ const { access } = await import("node:fs/promises"), { constants } = await import("node:fs");
1841
+ try {
1842
+ await access(found.root, constants.W_OK);
1843
+ await access(found.prefix, constants.W_OK);
1844
+ return true;
1845
+ }
1846
+ catch {
1847
+ return false;
1848
+ }
1849
+ }
1850
+ async launchHubUpdate(row, control) {
1851
+ if (this.shuttingDown || this.webUpdateOwned || isUpdateInProgress(this.dataDir) || !control.current())
1852
+ return false;
1853
+ const claim = { startedAt: Date.now() }, owned = { id: row.id, claim };
1854
+ this.hubUpdateOwned = owned;
1855
+ this.webUpdateOwned = claim;
1856
+ const release = () => { if (this.hubUpdateOwned === owned)
1857
+ this.hubUpdateOwned = null; if (this.webUpdateOwned === claim)
1858
+ this.webUpdateOwned = null; };
1859
+ if (!persistUpdateProgress(this.dataDir, { ...webUpdateTarget(claim.startedAt), messageId: `hub-fleet-update:${row.id}` }, claim.startedAt)
1860
+ || !setUpdateProgressStage(this.dataDir, "preparing", { version: row.version })) {
1861
+ release();
1862
+ return false;
1863
+ }
1864
+ try {
1865
+ const child = await this.launchInstalledUpdate(`Hub-requested update ${row.id}`, () => !this.shuttingDown && this.hubUpdateOwned === owned && control.current() && control.claim(), row.version);
1866
+ if (!child) {
1867
+ release();
1868
+ return false;
1869
+ }
1870
+ let endedOnce = false;
1871
+ const ended = () => {
1872
+ if (endedOnce)
1873
+ return;
1874
+ endedOnce = true;
1875
+ const settle = () => {
1876
+ if (this.shuttingDown || this.hubUpdateOwned !== owned)
1877
+ return;
1878
+ // systemd-run may exit before its independent updater. Keep the claim while its bounded marker is active.
1879
+ const marker = readUpdateProgress(this.dataDir)?.progress;
1880
+ if (marker?.target.messageId === `hub-fleet-update:${row.id}` && isUpdateInProgress(this.dataDir)) {
1881
+ const timer = setTimeout(settle, 5000);
1882
+ timer.unref();
1883
+ return;
1884
+ }
1885
+ release();
1886
+ const outcome = this.hubUpdateOutcome(row);
1887
+ if (outcome)
1888
+ this.hubUpdates?.complete(row.id, outcome.state, outcome.currentVersion, "interrupted");
1889
+ };
1890
+ settle();
1891
+ };
1892
+ child.once("exit", ended);
1893
+ child.once("error", ended);
1894
+ return true;
1895
+ }
1896
+ catch {
1897
+ release();
1898
+ return false;
1899
+ }
1900
+ }
1901
+ hubUpdateOutcome(row) {
1902
+ if (!this.startupComplete || this.hubUpdateOwned?.id === row.id)
1903
+ return null;
1904
+ const currentVersion = this.runningAgendVersion();
1905
+ if (currentVersion.replace(/^v/, "") === row.version.replace(/^v/, ""))
1906
+ return { state: "done", currentVersion };
1907
+ const matches = (m) => m?.progress.target.messageId === `hub-fleet-update:${row.id}` && m.progress.version === row.version;
1908
+ const saved = readUpdateProgress(this.dataDir);
1909
+ // Startup may clear the ordinary progress marker before the optional Hub mount finishes.
1910
+ const marker = (matches(saved) ? saved : matches(this.hubUpdateBootProgress) ? this.hubUpdateBootProgress : null)?.progress;
1911
+ const reachedRestart = marker && (["installed", "stopping", "starting", "complete"].includes(marker.stage)
1912
+ || marker.stage === "failed" && (marker.failedStage === "starting" || marker.failedStage === "stopping"));
1913
+ return { state: reachedRestart ? "rolled-back" : "failed", currentVersion };
1914
+ }
1915
+ recordHubUpdateNotice(n) {
1916
+ const store = this.webNoticeStore();
1917
+ if (!store)
1918
+ return false;
1919
+ const text = t(`hub_fleet_update.${n.state}`, n.hubName, n.requestedBy, n.version, n.currentVersion ?? "");
1920
+ const prior = store.view().items.some(i => i.hubUpdate?.requestId === n.requestId && i.hubUpdate.state === n.state);
1921
+ const notice = store.addDurable({ kind: "update", text, hubUpdate: n });
1922
+ if (!notice)
1923
+ return false;
1924
+ this.emitSseEvent("notice", { notice, unread: store.unread() });
1925
+ if (!prior && !this.webOnlyPromptPlace())
1926
+ void this.postHubUpdateChat(n, text).catch(() => this.logger.warn("Hub update owner chat notice could not be posted"));
1927
+ return true;
1928
+ }
1929
+ async postHubUpdateChat(n, text) {
1930
+ const general = this.findGeneralInstance();
1931
+ if (!general)
1932
+ return;
1933
+ if (n.state !== "waiting" && n.state !== "expired") {
1934
+ this.notifyInstanceTopic(general, text);
1935
+ return;
1936
+ }
1937
+ const adapter = this.getAdapterForInstance(general), adapterId = this.getInstanceAdapterId(general), chatId = this.getGroupIdForInstance(general);
1938
+ if (!adapter || !adapterId || !chatId)
1939
+ return;
1940
+ const threadId = String(this.fleetConfig?.instances[general]?.topic_id ?? "");
1941
+ const nonce = await this.postNonceButtonPromptOrThrow({ prefix: HUB_FLEET_UPDATE_CALLBACK_PREFIX, alertType: "tip", instanceName: general,
1942
+ adapter, adapterId, chatId, ...(threadId ? { threadId } : {}), message: text,
1943
+ choices: [{ action: "update", label: t("hub_update.button") }, ...(n.state === "waiting" ? [{ action: "cancel", label: t("hub_fleet_update.cancel") }] : [])],
1944
+ expiredText: t("hub_update.expired"), timeoutMs: 24 * 60 * 60_000 });
1945
+ this.pendingHubFleetUpdates.set(nonce, n.requestId);
1946
+ const timer = setTimeout(() => this.pendingHubFleetUpdates.delete(nonce), 24 * 60 * 60_000 + 60_000);
1947
+ timer.unref();
1948
+ }
1949
+ async handleHubFleetUpdateCallback(data, adapterId, adapter) {
1950
+ const claimed = this.consumeNonceCallback(HUB_FLEET_UPDATE_CALLBACK_PREFIX, /^hub-fleet-update:([0-9a-f]{32}):(update|cancel)$/, data, adapterId, adapter, undefined, userId => this.fleetAdminGate(userId, adapterId) === "ok");
1951
+ if (claimed === null)
1952
+ return false;
1953
+ if (claimed === "consumed")
1954
+ return true;
1955
+ const nonce = data.callbackData.slice(HUB_FLEET_UPDATE_CALLBACK_PREFIX.length, HUB_FLEET_UPDATE_CALLBACK_PREFIX.length + 32);
1956
+ const id = this.pendingHubFleetUpdates.get(nonce);
1957
+ this.pendingHubFleetUpdates.delete(nonce);
1958
+ const owner = this.hubUpdates, value = id ? owner?.view(id) : null;
1959
+ await this.retireNonceButtons(claimed.entry, claimed.entry.messageId ?? data.messageId, t("hub_update.expired"));
1960
+ if (!id || !owner || !value)
1961
+ return true;
1962
+ if (claimed.action === "cancel")
1963
+ owner.cancel({ id, version: value.version });
1964
+ else
1965
+ await this.startHubRequestedUpdateOnce(`chat:${nonce}`, `${adapterId}:${data.userId}`, () => this.fleetAdminGate(data.userId ?? "", adapterId) === "ok" && !this.shuttingDown, id);
1966
+ return true;
1967
+ }
1968
+ hubSharingController = null;
1969
+ pendingHubSharing = new Map();
1970
+ hubSharing() { return this.hubSharingController; }
1971
+ async recordHubSharingNotice(value) {
1972
+ const store = this.webNoticeStore();
1973
+ if (!store)
1974
+ return false;
1975
+ const text = hubSharingNoticeText(value, (key, ...args) => t(key, ...args));
1976
+ const notice = store.upsertSharing(value, text);
1977
+ if (!notice)
1978
+ return false;
1979
+ this.emitSseEvent("notice", { notice, unread: store.unread() });
1980
+ if (value.state === "complete" && !this.webOnlyPromptPlace() && store.startSharingChat(value.key)) {
1981
+ void this.postHubSharingChat(value, text).catch(() => this.logger.warn("Hub sharing chat notice not confirmed; Undo remains in web Notices"));
1982
+ }
1983
+ return true;
1984
+ }
1985
+ async postHubSharingChat(value, text) {
1986
+ const general = this.findGeneralInstance(), controller = this.hubSharingController;
1987
+ if (!general || !controller)
1988
+ return;
1989
+ if (!value.rows.some(row => row.state === "shared" || row.state === "stopped") || Date.now() >= value.undoUntil) {
1990
+ this.notifyInstanceTopic(general, text);
1991
+ return;
1992
+ }
1993
+ const adapter = this.getAdapterForInstance(general), adapterId = this.getInstanceAdapterId(general), chatId = this.getGroupIdForInstance(general);
1994
+ if (!adapter || !adapterId || !chatId)
1995
+ return;
1996
+ const threadId = String(this.fleetConfig?.instances[general]?.topic_id ?? "");
1997
+ const nonce = await this.postNonceButtonPromptOrThrow({ prefix: HUB_SHARING_CALLBACK_PREFIX, alertType: "tip", instanceName: general,
1998
+ adapter, adapterId, chatId, ...(threadId ? { threadId } : {}), message: text, choices: [{ action: "undo", label: t("hub_sharing.undo") }],
1999
+ expiredText: t("hub_sharing.expired"), timeoutMs: Math.max(1, value.undoUntil - Date.now()) });
2000
+ if (this.hubSharingController !== controller || this.shuttingDown)
2001
+ return;
2002
+ this.pendingHubSharing.set(nonce, { key: value.key, controller });
2003
+ const timer = setTimeout(() => this.pendingHubSharing.delete(nonce), Math.max(1, value.undoUntil - Date.now()));
2004
+ timer.unref();
2005
+ }
2006
+ async handleHubSharingCallback(data, adapterId, adapter) {
2007
+ const claimed = this.consumeNonceCallback(HUB_SHARING_CALLBACK_PREFIX, /^hub-share:([0-9a-f]{32}):undo$/, data, adapterId, adapter, { keepText: true, notice: t("hub_sharing.restart") }, userId => this.fleetAdminGate(userId, adapterId) === "ok");
2008
+ if (claimed === null)
2009
+ return false;
2010
+ if (claimed === "consumed")
2011
+ return true;
2012
+ const nonce = data.callbackData.slice(HUB_SHARING_CALLBACK_PREFIX.length, HUB_SHARING_CALLBACK_PREFIX.length + 32);
2013
+ const pending = this.pendingHubSharing.get(nonce);
2014
+ this.pendingHubSharing.delete(nonce);
2015
+ const current = () => !!pending && this.hubSharingController === pending.controller && !this.shuttingDown
2016
+ && this.fleetAdminGate(data.userId ?? "", adapterId) === "ok";
2017
+ let text = t("hub_sharing.restart");
2018
+ if (pending && current()) {
2019
+ try {
2020
+ const value = pending.controller.view(pending.key);
2021
+ if (value && Date.now() >= value.undoUntil)
2022
+ text = t("hub_sharing.expired");
2023
+ else if (value) {
2024
+ const result = await pending.controller.undo(pending.key, `${adapterId}:${data.userId}`, current);
2025
+ text = hubSharingNoticeText(result, (key, ...args) => t(key, ...args));
2026
+ }
2027
+ }
2028
+ catch {
2029
+ text = t("hub_sharing.uncertain");
2030
+ this.logger.warn("Hub sharing Undo not confirmed; use web Notices");
2031
+ }
2032
+ }
2033
+ await this.retireNonceButtons(claimed.entry, claimed.entry.messageId ?? data.messageId, text);
2034
+ return true;
2035
+ }
1674
2036
  hubPairingNotices = null;
1675
2037
  hubMemberPairing() { return this.hubMemberPairingApi; }
1676
2038
  /** Explicit owner Settings read only. A paused binding is not permission to mount or connect a member. */
@@ -2194,6 +2556,7 @@ export class FleetManager {
2194
2556
  hubRuntimeCreated() {
2195
2557
  this.hubRuntimeInit ??= (async () => {
2196
2558
  const { HubRuntime } = await import("./hub/runtime.js");
2559
+ const { verifyRoomReceipt } = await import("./hub/member/room-post-receipt.js");
2197
2560
  // M-2682: the one writer for sealed Hub settings (a rename from Hub Administration). It saves hub.* through this
2198
2561
  // fleet's own synchronous writer, so nothing else here runs between its commit point and the new pair in force.
2199
2562
  const { createHubSettingsWriter } = await import("./hub/settings-commit.js");
@@ -2244,6 +2607,10 @@ export class FleetManager {
2244
2607
  // S3c's currentBinding: a fresh, fail-closed read of the pairing state (null unless consistent and connectable).
2245
2608
  boundHub: () => this.hubMemberBinding?.(this.dataDir)?.hubId ?? null,
2246
2609
  agents: () => this.hubMemberAgents(),
2610
+ catalogAgents: () => this.hubCatalogAgents(),
2611
+ sharingNotice: value => this.recordHubSharingNotice(value),
2612
+ attachSharing: controller => { this.hubSharingController = controller; },
2613
+ maxCrossInstanceMessageBytes: () => this.fleetConfig?.defaults?.max_cross_instance_message_bytes,
2247
2614
  // P1 representative mode (docs/design/hub-representative-agent.md): ordinary delivery + the report_result hook.
2248
2615
  representative: {
2249
2616
  quota: agent => this.hubAgentQuota(agent),
@@ -2262,9 +2629,34 @@ export class FleetManager {
2262
2629
  inboxDir: agent => isSafeInstanceDirName(agent) ? join(this.dataDir, "workspaces", agent, "inbox") : null,
2263
2630
  scratchDir: agent => isSafeInstanceDirName(agent) ? join(this.dataDir, "workspaces", agent, "hub-files") : null },
2264
2631
  attachReports: (handler, failed) => { this.hubReports = handler; this.hubDeliveryFailed = failed; },
2632
+ attachPrivateQuestions: read => { this.hubPrivateQuestions = read; },
2633
+ attachReacts: handler => { this.hubReacts = handler; },
2265
2634
  },
2635
+ attachAgentRooms: port => { this.hubAgentRooms = port; this.notifyHubRoomTools(); },
2636
+ roomToolsChanged: () => this.notifyHubRoomTools(),
2637
+ roomConversationGeneration: agent => this.daemons.get(agent)?.roomConversationGeneration() ?? null,
2638
+ attachRoomInputs: handler => { this.hubRoomInput = handler; },
2639
+ roomNotify: input => this.deliverHubRoomNotification(input),
2640
+ roomReceipt: (caller, receiptId) => verifyRoomReceipt({
2641
+ lookup: (agent, id) => {
2642
+ const item = this.queryDurableDeliveryStatus(agent, { messageId: id }).items[0];
2643
+ if (item?.message_id !== id || !item.authority)
2644
+ return null;
2645
+ const row = this.deliveryOutbox?.getHumanReceipt(id.slice(5));
2646
+ return row ? { row, authority: item.authority } : null;
2647
+ },
2648
+ admin: (agent, actor) => actor.adapter_id === HOST_OPERATOR.adapterId && actor.user_id === HOST_OPERATOR.userId
2649
+ ? this.isWebOnlyFleet()
2650
+ : this.getInstanceAdapterId(agent) === actor.adapter_id && this.isFleetAdmin(actor.user_id, actor.adapter_id),
2651
+ }, caller.agent, receiptId),
2266
2652
  attachExposures: api => this.attachHubMemberExposures(api),
2267
2653
  attachAttention: read => this.attachHubExecutionAttention(read),
2654
+ updates: { idle: () => this.hubUpdateIdle(), busy: () => !!this.webUpdateOwned || isUpdateInProgress(this.dataDir),
2655
+ canInstall: () => this.hubUpdateCanInstall(), launch: (row, control) => this.launchHubUpdate(row, control),
2656
+ active: id => this.hubUpdateOwned?.id === id, outcome: row => this.hubUpdateOutcome(row), notify: n => this.recordHubUpdateNotice(n) },
2657
+ attachUpdates: updates => { this.hubUpdates = updates; },
2658
+ attachRecommendations: read => { this.hubRecommendationRead = read; },
2659
+ recommendationChanged: () => this.hubRecommendationChanged(),
2268
2660
  attachPairingNotices: read => { this.hubPairingNotices = read; },
2269
2661
  pokeAttention: () => this.needsYou?.poke(),
2270
2662
  linkState: (state, digest) => { this.hubMemberLink = state; this.hubMemberLinkBinding = digest ?? null; },
@@ -2340,12 +2732,92 @@ export class FleetManager {
2340
2732
  * delivery addresses, General included, shown by its display name. The dedicated Hub daemon is not a fleet instance.
2341
2733
  */
2342
2734
  hubMemberAgents() {
2343
- return Object.keys(this.fleetConfig?.instances ?? {}).map(name => ({ name, display: this.shownInstanceName(name) }));
2735
+ const classicNames = new Set((this.classicChannels?.getAll() ?? []).map(ch => ch.instanceName));
2736
+ const fleet = Object.keys(this.fleetConfig?.instances ?? {}).filter(name => !classicNames.has(name)).map(name => ({ name, display: this.shownInstanceName(name) }));
2737
+ return [...fleet, ...(this.classicChannels?.getAll() ?? []).filter(ch => !Object.hasOwn(this.fleetConfig?.instances ?? {}, ch.instanceName))
2738
+ .map(ch => ({ name: ch.instanceName, display: ch.displayName || ch.name, kind: "classic-room" }))];
2739
+ }
2740
+ /** Owner-only cosmetic inventory. Lifecycle tokens only fence its digest; no paths or tools are projected. */
2741
+ hubCatalogAgents() {
2742
+ const profiles = profileIdentities(this.dataDir), colors = identityColors(this.dataDir);
2743
+ const rooms = new Map((this.classicChannels?.getAll() ?? []).map(room => [room.instanceName, room]));
2744
+ return this.hubMemberAgents().map(agent => {
2745
+ const config = this.hubAgentConfig(agent.name), room = rooms.get(agent.name);
2746
+ const identity = resolveInstanceIdentity({ cfg: config, classic: room, profile: profiles.get(agent.name) });
2747
+ const avatar = avatarFor({ name: agent.name, displayName: identity.display_name,
2748
+ personaEmoji: config?.status_emojis?.delivered });
2749
+ let color = colors.get(agent.name)?.color ? identityColorValue(colors.get(agent.name).color, "light") : null;
2750
+ try {
2751
+ color ??= this.webIdentityImage(agent.name, identity.display_name, null, { own: new Map(), speaking: new Map() }).agentColor ?? null;
2752
+ }
2753
+ catch { /* no cosmetic fallback data */ }
2754
+ const base = { instance: agent.name, displayName: identity.display_name || agent.display,
2755
+ description: identity.description ?? room?.description ?? "", avatar: { emoji: avatar.kind === "emoji" && "text" in avatar ? avatar.text : null, color: color ?? identityColorValue(autoIdentityColor(agent.name), "light") },
2756
+ kind: agent.kind ?? "agent", general: config?.general_topic === true, incarnation: this.hubAgentToken(agent.name) };
2757
+ return !config || !base.incarnation ? { ...base, shareable: false, reason: "delivery-unavailable" }
2758
+ : isNativeExecInstance(config) ? { ...base, shareable: false, reason: "remote-windows" }
2759
+ : { ...base, shareable: true };
2760
+ });
2761
+ }
2762
+ /** The actual launch target, including Classic's own effective backend/folder; never aliases a room to a Fleet topic. */
2763
+ hubAgentConfig(agent) {
2764
+ const instances = this.fleetConfig?.instances ?? {};
2765
+ const room = this.classicChannels?.getAll().find(ch => ch.instanceName === agent);
2766
+ if (Object.hasOwn(instances, agent))
2767
+ return room ? null : instances[agent];
2768
+ return room ? { ...DEFAULT_INSTANCE_CONFIG, ...this.fleetConfig?.defaults,
2769
+ backend: this.classicChannels.getBackendByInstance(agent, this.fleetConfig?.defaults?.backend), working_directory: this.classicWorkspaceDir(agent),
2770
+ hubClassicIdentity: JSON.stringify([room.adapterId ?? "", room.channelId]) } : null;
2771
+ }
2772
+ hubClassicPrivacy = null;
2773
+ classicPrivacy() { return this.hubClassicPrivacy ??= new HubClassicPrivateTurns(join(this.dataDir, "hub-classic-private.json")); }
2774
+ /** The mark outlives registration: a late tool from a removed room must not fall through to General. */
2775
+ classicHubPrivateBlocked(agent) { return !!this.dataDir && this.classicPrivacy().blocked(agent); }
2776
+ classicHubSerialized(agent) {
2777
+ if (this.classicHubPrivateBlocked(agent))
2778
+ return true;
2779
+ if (!this.isClassicInstance(agent))
2780
+ return false;
2781
+ try {
2782
+ return this.hubMemberExposureApi?.list().some(row => row.agent === agent && row.state !== "withdrawn") ?? false;
2783
+ }
2784
+ catch {
2785
+ return true;
2786
+ }
2787
+ }
2788
+ hubPrivateQuestions = null;
2789
+ classicRoomPersonInput(agent, payload) {
2790
+ const meta = payload.meta;
2791
+ return (this.isClassicInstance(agent) || this.classicHubPrivateBlocked(agent)) && payload.type === "fleet_inbound" && !!meta && typeof meta.chat_id === "string" && !!meta.chat_id
2792
+ && typeof meta.user_id === "string" && !!meta.user_id && !meta.from_instance && !meta.is_cross_instance;
2793
+ }
2794
+ /** Prepare a public handoff without opening output until IPC accepts that exact input. */
2795
+ async prepareClassicForPerson(agent, payload, epoch, current) {
2796
+ if (!this.classicRoomPersonInput(agent, payload))
2797
+ return null;
2798
+ while (this.classicHubPrivateBlocked(agent)) {
2799
+ if (this.shuttingDown || !this.deliveryCurrent(agent, epoch, current))
2800
+ return false;
2801
+ const row = this.classicPrivacy().read(agent);
2802
+ if (!row)
2803
+ return false;
2804
+ const idle = await this.waitForInstanceIdle(agent, 60_000, Math.max(row.since + 1, Date.now()), () => !this.deliveryCurrent(agent, epoch, current));
2805
+ if (!this.deliveryCurrent(agent, epoch, current))
2806
+ return false;
2807
+ let pending = true;
2808
+ try {
2809
+ pending = this.hubPrivateQuestions?.(agent) ?? false;
2810
+ }
2811
+ catch { /* An unreadable journal never grants public output. */ }
2812
+ if (idle && !pending && this.classicPrivacy().read(agent)?.token === row.token)
2813
+ return row.token;
2814
+ }
2815
+ return null;
2344
2816
  }
2345
2817
  /** Same cached usage source as the owner's rail, scoped to the representative's CLI and credential profile. */
2346
2818
  async hubAgentQuota(agent) {
2347
2819
  const binding = () => {
2348
- const config = this.fleetConfig?.instances[agent];
2820
+ const config = this.hubAgentConfig(agent);
2349
2821
  if (!config || isWindowsInstance(config))
2350
2822
  return null; // runner usage never belongs to a Linux login
2351
2823
  const backend = this.backendNameForInstance(agent), provider = usageProviderIdForBackend(backend);
@@ -2377,15 +2849,15 @@ export class FleetManager {
2377
2849
  * earlier consent never matches again without an explicit republish. Stopping or pausing changes nothing.
2378
2850
  */
2379
2851
  hubAgentToken(agent) {
2380
- const instances = this.fleetConfig?.instances ?? {};
2381
- if (!Object.prototype.hasOwnProperty.call(instances, agent))
2852
+ const config = this.hubAgentConfig(agent);
2853
+ if (!config)
2382
2854
  return null;
2383
2855
  if (this.hubIncarnationsBroken)
2384
2856
  return null;
2385
2857
  let id;
2386
2858
  try {
2387
2859
  this.settleHubIncarnations();
2388
- id = this.hubIncarnationsBroken ? null : this.hubAgentIncarnation(agent, instances[agent], true);
2860
+ id = this.hubIncarnationsBroken ? null : this.hubAgentIncarnation(agent, config, true);
2389
2861
  }
2390
2862
  catch (err) {
2391
2863
  this.logger.warn({ err: err?.message, agent }, "Hub agent incarnation could not be saved; the agent is not a deliverable representative");
@@ -2486,13 +2958,13 @@ export class FleetManager {
2486
2958
  }
2487
2959
  /** The agent's durable incarnation id (create: make one if none; else null). A changed fingerprint rotates it. */
2488
2960
  hubAgentIncarnation(agent, cfg, create) {
2489
- const fp = createHash("sha256").update(JSON.stringify([cfg.backend ?? "claude-code", cfg.working_directory, cfg.runtime ?? "", cfg.machine_id ?? ""])).digest("hex");
2961
+ const fp = createHash("sha256").update(JSON.stringify([cfg.backend ?? "claude-code", cfg.working_directory, cfg.runtime ?? "", cfg.machine_id ?? "", ...(cfg.hubClassicIdentity ? [cfg.hubClassicIdentity] : [])])).digest("hex");
2490
2962
  const map = this.readHubIncarnations(), entry = Object.prototype.hasOwnProperty.call(map, agent) ? map[agent] : undefined;
2491
2963
  if (entry && entry.fp === fp && typeof entry.id === "string")
2492
2964
  return entry.id;
2493
2965
  if (!entry && !create)
2494
2966
  return null;
2495
- map[agent] = { id: randomUUID(), fp };
2967
+ map[agent] = { id: randomUUID(), fp, ...(cfg.hubClassicIdentity ? { classic: true } : {}) };
2496
2968
  // A rotation that could only clear the file still invalidated the old id durably; the new one is made next time.
2497
2969
  return this.writeHubIncarnations(map) === "written" ? map[agent].id : null;
2498
2970
  }
@@ -2512,12 +2984,12 @@ export class FleetManager {
2512
2984
  throw new Error("Hub agent incarnations cannot be written here");
2513
2985
  if (!existsSync(this.hubIncarnationsPath()))
2514
2986
  return;
2515
- const instances = this.fleetConfig.instances;
2516
2987
  for (const agent of Object.keys(this.readHubIncarnations())) {
2517
2988
  // Gone from the configuration in force (removed by hand in fleet.yaml, too): forgotten, never revived by a re-add.
2518
- if (Object.prototype.hasOwnProperty.call(instances, agent))
2519
- this.hubAgentIncarnation(agent, instances[agent], false);
2520
- else
2989
+ const config = this.hubAgentConfig(agent);
2990
+ if (config)
2991
+ this.hubAgentIncarnation(agent, config, false);
2992
+ else if (this.classicChannels || this.readHubIncarnations()[agent]?.classic !== true)
2521
2993
  this.forgetHubAgentIncarnation(agent, true);
2522
2994
  }
2523
2995
  }
@@ -2544,16 +3016,22 @@ export class FleetManager {
2544
3016
  throw new Error(`Hub consent for ${agent} could not be invalidated durably; refusing the change (${err?.message})`);
2545
3017
  }
2546
3018
  }
3019
+ hubContactWindows = null;
3020
+ contactWindows() {
3021
+ return this.hubContactWindows ??= new HubContactWindows(join(this.dataDir, "hub-contact-windows.json"));
3022
+ }
3023
+ hubContactRestricted(agent) { return this.contactWindows().restricted(agent); }
2547
3024
  /**
2548
3025
  * A Hub question to its representative agent: ordinary cross-instance delivery (idle gate, wake, retries), from the
2549
3026
  * reserved Hub sender with the Hub-issued correlation id. beforeInput runs immediately before the IPC hand-off.
2550
3027
  */
2551
3028
  async deliverHubQuestion(input) {
2552
3029
  const { HUB_REPORT_TARGET } = await import("./hub/representative.js");
2553
- if (this.shuttingDown || !this.fleetConfig?.instances[input.agent])
3030
+ const config = this.hubAgentConfig(input.agent);
3031
+ if (this.shuttingDown || !config)
2554
3032
  return false;
2555
3033
  // Windows agents run through their own runtime, which has no pre-input hook: not a P1 representative.
2556
- if (isNativeExecInstance(this.fleetConfig.instances[input.agent]))
3034
+ if (isNativeExecInstance(config))
2557
3035
  return false;
2558
3036
  const ipcMeta = {
2559
3037
  chat_id: "",
@@ -2569,7 +3047,37 @@ export class FleetManager {
2569
3047
  requires_reply: "true",
2570
3048
  task_summary: "A question from the Hub",
2571
3049
  };
2572
- const result = await this.deliverToInstance(input.agent, { type: "fleet_inbound", targetSession: input.agent, content: input.text, meta: ipcMeta }, { isCrossInstance: true, stillCurrent: input.stillCurrent, beforeInput: input.beforeInput });
3050
+ if (input.roomContextGeneration)
3051
+ ipcMeta.hub_room_context_generation = input.roomContextGeneration;
3052
+ const result = await this.deliverToInstance(input.agent, { type: "fleet_inbound", targetSession: input.agent, content: input.text, meta: ipcMeta }, { isCrossInstance: true, stillCurrent: input.stillCurrent, beforeInput: async () => {
3053
+ const classic = this.isClassicInstance(input.agent);
3054
+ // A busy Classic room must finish its public turn first; never force a private question into that turn's queue.
3055
+ const idle = () => this.waitForInstanceIdle(input.agent, 0, this.lastDeliveryAt.get(input.agent) ?? 0, () => !input.stillCurrent());
3056
+ if (classic && !await idle())
3057
+ return false;
3058
+ if (!(await input.beforeInput()))
3059
+ return false;
3060
+ if (classic) {
3061
+ if (!await idle())
3062
+ return false;
3063
+ this.classicPrivacy().begin(input.agent, input.correlationId);
3064
+ }
3065
+ // Before any possible IPC exposure. An uncertain write retains the window, never replays the question.
3066
+ if (input.contactLimit !== false)
3067
+ this.contactWindows().begin(input.agent, input.correlationId);
3068
+ return input.stillCurrent();
3069
+ } });
3070
+ return result !== false;
3071
+ }
3072
+ async deliverHubRoomNotification(input) {
3073
+ const { HUB_REPORT_TARGET } = await import("./hub/representative.js");
3074
+ if (this.shuttingDown || !this.fleetConfig?.instances[input.agent] || isNativeExecInstance(this.fleetConfig.instances[input.agent]))
3075
+ return false;
3076
+ const prefix = input.kind === "mention-feedback" ? "hub-room-mention-feedback" : "hub-room-post-answer";
3077
+ const result = await this.deliverToInstance(input.agent, { type: "fleet_inbound", targetSession: input.agent, content: input.text,
3078
+ meta: { chat_id: "", message_id: `${prefix}-${input.id}`, user: `instance:${HUB_REPORT_TARGET}`, user_id: `instance:${HUB_REPORT_TARGET}`,
3079
+ ts: new Date().toISOString(), thread_id: "", from_instance: HUB_REPORT_TARGET, from_display: "Hub", correlation_id: `${prefix}-${input.id}`,
3080
+ request_kind: "notification", requires_reply: "false", task_summary: input.kind === "mention-feedback" ? "Hub mention delivery feedback" : "A reply to your Hub room post" } }, { isCrossInstance: true, stillCurrent: input.stillCurrent, beforeInput: input.beforeInput });
2573
3081
  return result !== false;
2574
3082
  }
2575
3083
  /** S-51: why the Hub (or this fleet's Hub membership) is not running, if it is held. Empty while off or running. */
@@ -2578,6 +3086,11 @@ export class FleetManager {
2578
3086
  }
2579
3087
  hubBrowserCertificate() { return this.hubRuntime?.browserCertificateSettings() ?? null; }
2580
3088
  hubRetention() { return this.hubRuntime?.retentionSettings() ?? null; }
3089
+ /** M-3281: the archived chat files, for Settings (their size limit: what is kept, what a lower one removes). */
3090
+ chatArchiveFiles() {
3091
+ const archive = this.webChatArchive;
3092
+ return archive ? { usage: (capBytes) => archive.filesUsage(capBytes), enforce: () => archive.enforceFilesCap({ exact: true }) } : null;
3093
+ }
2581
3094
  /** M-2682: an unfinished sealed-settings commit; Hub setting saves wait until recover() has run. */
2582
3095
  hubSettingsBusy() { return this.hubSettingsWriter?.pending() === true || this.hubSetupController?.pending() === true; }
2583
3096
  /** #3298 S-89: this fleet's own Hub offers group permissions (the page mark that shows Settings → Hub's Group permissions row). */
@@ -2673,10 +3186,48 @@ export class FleetManager {
2673
3186
  hubMemberLinkBinding = null;
2674
3187
  /** OutboundContext: the Hub representative's answer hook (null: no member service running, or not a Hub answer). */
2675
3188
  hubReport(input) {
2676
- return this.hubReports?.(input) ?? null;
3189
+ const result = this.hubReports?.(input) ?? null;
3190
+ if (!result)
3191
+ return null;
3192
+ return result.then(outcome => {
3193
+ if (outcome.ok) {
3194
+ try {
3195
+ this.contactWindows().answered(input.caller, input.correlationId);
3196
+ }
3197
+ catch (err) {
3198
+ this.logger.warn({ err }, "Hub contact window could not be closed; it will expire");
3199
+ }
3200
+ }
3201
+ return outcome;
3202
+ });
3203
+ }
3204
+ /** M-3127 OutboundContext: an agent's `react` on a Hub room question (its correlation id as message_id); null: not one. */
3205
+ hubReact(input) {
3206
+ return this.hubReacts?.(input) ?? null;
2677
3207
  }
3208
+ hubReacts = null;
2678
3209
  /** The member side's pane-failure hook for a Hub-issued correlation id (else null). */
3210
+ hubRoomInput = null;
2679
3211
  hubDeliveryFailed = null;
3212
+ /** The connected member adapter; never an agent-selectable identity. */
3213
+ hubAgentRooms = null;
3214
+ hubRoomToolsAvailable() { return this.hubAgentRooms?.available() === true; }
3215
+ hubRoomList(caller) {
3216
+ return this.hubAgentRooms?.rooms(caller) ?? Promise.resolve({ ok: false, code: "unavailable" });
3217
+ }
3218
+ hubRoomMembers(caller, room) {
3219
+ return this.hubAgentRooms?.members(caller, room) ?? Promise.resolve({ ok: false, code: "unavailable" });
3220
+ }
3221
+ hubPeopleSearch(caller, q) {
3222
+ return this.hubAgentRooms?.people(caller, q) ?? Promise.resolve({ ok: false, code: "unavailable" });
3223
+ }
3224
+ hubRoomPost(caller, value) {
3225
+ return this.hubAgentRooms?.post(caller, value) ?? Promise.resolve({ ok: false, code: "unavailable" });
3226
+ }
3227
+ notifyHubRoomTools() {
3228
+ for (const ipc of this.instanceIpcClients.values())
3229
+ ipc.send({ type: "hub_room_tools_changed" });
3230
+ }
2680
3231
  /** The member side's report_result hook for HUB_REPORT_TARGET while a representative service runs (else null). */
2681
3232
  hubReports = null;
2682
3233
  /** The one in-flight creation (single flight): overlapping first observations share it, Stop waits for it. */
@@ -2770,6 +3321,8 @@ export class FleetManager {
2770
3321
  livenessGone = new Map();
2771
3322
  /** #3647: when each instance last showed working (after the startup grace): activity for "quiet". */
2772
3323
  lastWorkingAt = new Map();
3324
+ /** M-3239: the instances whose progress is read from their transcript (see cacheInstanceExecutionState). */
3325
+ livenessTurnEvidence = new Set();
2773
3326
  dispatcherLiveness = null;
2774
3327
  /** Adapters whose last slash command registration failed and General was told (#1131). */
2775
3328
  slashRegistrationFailed = new Set();
@@ -2867,6 +3420,9 @@ export class FleetManager {
2867
3420
  pendingNonceButtons = new Map();
2868
3421
  /** #2598 B2: the kiro moves waiting on a fleet admin's Confirm in General, by prompt nonce. */
2869
3422
  pendingKiroMigrations = new Map();
3423
+ /** M-3140: a posted Hub-update notice's advice (by its nonce) — which advice the button was offered for. */
3424
+ pendingHubUpdates = new Map();
3425
+ hubUpdateNoticeBusy = false;
2870
3426
  pendingKiroReconciliations = new Map();
2871
3427
  kiroMigrationRuns = new Map();
2872
3428
  /** #1386 "Needs you": the list, its live chat messages and Acknowledge. Started with the fleet (finishStartup). */
@@ -3040,6 +3596,8 @@ export class FleetManager {
3040
3596
  webChatHistory = new WebChatHistory();
3041
3597
  /** #1565: the web chat history's files (set at fleet start, once the home and the instances are known). */
3042
3598
  webChatStore = null;
3599
+ /** M-3272: the archive past each agent's 500-message web chat window (web-chat-archive.ts). */
3600
+ webChatArchive = null;
3043
3601
  /** #2293: the dashboard's global search (null: web.search.enabled is false, or the fleet has not started). */
3044
3602
  searchIndex = null;
3045
3603
  /** Uploaded files and the files the dashboard may fetch back (uploads, reply attachments). */
@@ -3188,6 +3746,9 @@ export class FleetManager {
3188
3746
  officeStoreInstance;
3189
3747
  /** Fleet → Org chart → Office: the offices people made (web-offices.json, beside web-themes.json). */
3190
3748
  get officeStore() { return (this.officeStoreInstance ??= new OfficeStore(this.dataDir, id => this.officeSkins.pack(id))); }
3749
+ pinStoreInstance;
3750
+ /** M-3271: pinned chat messages per agent (web-pins.json, beside web-themes.json). */
3751
+ get pinStore() { return (this.pinStoreInstance ??= new WebPinStore(this.dataDir)); }
3191
3752
  officeSkinsInstance;
3192
3753
  /** #2513: the Office view's uploaded skin packs (<AGEND_HOME>/web-office-skins/). */
3193
3754
  get officeSkins() { return (this.officeSkinsInstance ??= new OfficeSkinStore(this.dataDir)); }
@@ -3521,6 +4082,7 @@ export class FleetManager {
3521
4082
  settingsRuntimeRevision = 0;
3522
4083
  settingsConfirmation = null;
3523
4084
  settingsControl = null;
4085
+ ownerAppControl = null;
3524
4086
  settingsJobSettlements = new Map();
3525
4087
  classicSettingsOwners = new WeakMap();
3526
4088
  queueSettingsOperation(job, resources, execution, run) {
@@ -3578,6 +4140,7 @@ export class FleetManager {
3578
4140
  config: () => this.fleetConfig, current: () => [this.settingsGeneration, this.settingsRuntimeRevision, this.shuttingDown],
3579
4141
  generalLocation: input => this.previewGeneralLocation(input),
3580
4142
  hubMembership: raw => hubMembershipSettings(raw),
4143
+ hubPageSharing: raw => hubPageSharingSettings(raw),
3581
4144
  hubPilotTrust: raw => hubPilotTrustSettings(raw, RUNNING_AGEND_VERSION),
3582
4145
  // S3c (S-55): a Hub exposure publish's confirmation summary, while a member composition is attached.
3583
4146
  hubBrowserCertificate: (input, binding) => {
@@ -3637,7 +4200,9 @@ export class FleetManager {
3637
4200
  return null;
3638
4201
  const record = auth.session, sessions = this.webSessions, exposure = gatewayRequestContext(req);
3639
4202
  return { requester: { handle: record.handle, label: record.label }, localSession: this.hubCompanySession(req) ?? undefined, id: record.idHash, label: record.label, source: exposure ? "public_link" : "web_session",
3640
- localAdmin: () => record.tier === "admin" && record.surface === "local" && !exposure,
4203
+ // M-3278 (decision 7933bf90): an admin session on any listener, the public link's too (its exposure still
4204
+ // current: `current` below; a closed link's sessions are revoked with it).
4205
+ localAdmin: () => record.tier === "admin" && (!exposure || exposure.isCurrent()),
3641
4206
  current: () => current() && sessions === this.webSessions && !!this.webToken
3642
4207
  && sessions.isCurrent(record, tokenEpoch(this.webToken)) && (!exposure || exposure.isCurrent()) };
3643
4208
  }, baseline: () => baselines.read(), snapshot: () => baselines.snapshot(),
@@ -3892,8 +4457,8 @@ export class FleetManager {
3892
4457
  return null;
3893
4458
  if (role.account && !this.settingsAccountMayConfirm(store, id, role.actor))
3894
4459
  return null;
3895
- if (store.opensLink(id) && gatewayRequestContext(req))
3896
- return null;
4460
+ // M-3278 (decision 7933bf90, the leader's (a)): a verified admin over a link confirms a change that opens a link too, as
4461
+ // by Apply now; the role decides (its link option, Only this computer, the strict switch), and a Notice is posted.
3897
4462
  return { handle, actor: role.actor, account: role.account };
3898
4463
  };
3899
4464
  const first = check(true);
@@ -3943,8 +4508,6 @@ export class FleetManager {
3943
4508
  return null;
3944
4509
  if (role.account && !this.settingsAccountMayConfirm(store, id, role.actor))
3945
4510
  return null;
3946
- if (store.opensLink(id) && gatewayRequestContext(req))
3947
- return "on_host";
3948
4511
  return this.webRemoteAccess()?.isEnrolled(adminKey(role.actor.adapter_id, role.actor.user_id)) ? "ready" : "not_set_up";
3949
4512
  }
3950
4513
  /**
@@ -4775,6 +5338,45 @@ export class FleetManager {
4775
5338
  throw err;
4776
5339
  }
4777
5340
  }
5341
+ /** A person's local app gets a private, read/chat-only surface, never an instance's tool permissions. */
5342
+ async startOwnerAppControl() {
5343
+ if (this.shuttingDown || this.ownerAppControl)
5344
+ return;
5345
+ const [{ OwnerAppControl }, { createOwnerAppService }] = await Promise.all([import("./connect/control.js"), import("./connect/service.js")]);
5346
+ if (this.shuttingDown || this.ownerAppControl)
5347
+ return;
5348
+ const service = createOwnerAppService({
5349
+ current: () => !this.shuttingDown && !!this.fleetConfig,
5350
+ agents: () => Object.entries(this.fleetConfig?.instances ?? {}).map(([name, config]) => ({ name,
5351
+ display_name: config.display_name, backend: config.backend ?? "claude-code", status: this.getInstanceStatus(name) })),
5352
+ identity: name => this.fleetConfig?.instances[name],
5353
+ history: this.webChatHistory,
5354
+ board: () => this.scheduler?.db.board ?? null,
5355
+ deliver: async (name, text, messageId, current) => {
5356
+ if (!current())
5357
+ return false;
5358
+ const config = this.fleetConfig.instances[name];
5359
+ const adapter = this.getAdapterForInstance(name);
5360
+ const result = await this.deliverHumanToInstance(name, { type: "fleet_inbound", targetSession: name, content: text,
5361
+ meta: { chat_id: String(this.getGroupIdForInstance(name) ?? ""), thread_id: String(config.topic_id ?? ""),
5362
+ message_id: messageId, user: "Local app", user_id: "local-connector", source: "app", adapter_id: adapter?.id,
5363
+ ts: new Date().toISOString() } }, undefined, text, { stillCurrent: current, authorityCurrent: () => !this.shuttingDown && this.fleetConfig?.instances[name] === config });
5364
+ // No web-verified origin or human receipt authority is manufactured for an external app.
5365
+ if (result !== false)
5366
+ this.emitSseEvent("message", { instance: name, sender: "Local app", role: "user", text, messageId, ts: new Date().toISOString() });
5367
+ return result;
5368
+ },
5369
+ });
5370
+ const control = this.ownerAppControl = new OwnerAppControl(this.dataDir, service);
5371
+ try {
5372
+ await control.listen();
5373
+ }
5374
+ catch (error) {
5375
+ if (this.ownerAppControl === control)
5376
+ this.ownerAppControl = null;
5377
+ throw error;
5378
+ }
5379
+ }
4778
5380
  get webToken() { return readWebToken(this.dataDir); }
4779
5381
  /**
4780
5382
  * Server-side web sessions (see web-session.ts). Created with the token, not per
@@ -5398,6 +6000,39 @@ export class FleetManager {
5398
6000
  claimedAt: Math.max(ms(board.lastChangeAt(c.uuid)), ms(c.startedAt)), updatedAt: ms(c.updatedAt),
5399
6001
  }));
5400
6002
  }
6003
+ /**
6004
+ * M-3239: a tool call or an answer in the agent's transcript. Unlike the pane's spinner it counts from the fleet's start
6005
+ * (the boot shows working; a transcript line is real work, and the monitor starts at the transcript's end).
6006
+ */
6007
+ noteTurnActivity(name, at) {
6008
+ if (!Number.isFinite(at) || at > Date.now() + 60_000 || at < this.startedAt)
6009
+ return;
6010
+ if (at > (this.lastWorkingAt.get(name) ?? 0))
6011
+ this.lastWorkingAt.set(name, at);
6012
+ }
6013
+ /**
6014
+ * M-3239: an agent ended a turn without messaging anyone. If its final text asks a question and it holds a card
6015
+ * another agent handed it, that dispatcher is told, quoting the question — otherwise the question sits on the agent's
6016
+ * own screen and the card stalls (a beta.7 rehearsal waited 1.5 h on one).
6017
+ */
6018
+ onTurnEndedQuietly(name, startedAt, text) {
6019
+ if (this.shuttingDown || this.isPlannedRestart() || !livenessSettings(this.fleetConfig).enabled)
6020
+ return;
6021
+ const question = turnQuestion(text);
6022
+ if (!question)
6023
+ return;
6024
+ const outbox = this.deliveryOutbox;
6025
+ if (!outbox?.isOpen)
6026
+ return;
6027
+ const sent = outbox.latestSentAt(name);
6028
+ if (sent !== null && sent >= startedAt)
6029
+ return; // it did tell someone during the turn
6030
+ const isAgent = (d) => (this.fleetConfig?.instances?.[d] != null || this.isClassicInstance(d)) && !taskBoardOffIn(this.fleetConfig, d);
6031
+ for (const n of questionNotices(this.livenessCards(), name, question, startedAt, isAgent)) {
6032
+ this.admitTaskBoardNotice(n.dispatcher, n.message, n.key);
6033
+ this.logger.info({ assignee: name, dispatcher: n.dispatcher }, "Dispatcher told: assignee ended its turn on a question it sent no one");
6034
+ }
6035
+ }
5401
6036
  /** #3647: what the fleet knows about an assignee now; null when it is not an instance here. */
5402
6037
  livenessFacts(name) {
5403
6038
  if (this.fleetConfig?.instances?.[name] == null)
@@ -5427,6 +6062,9 @@ export class FleetManager {
5427
6062
  usageHold: this.daemons.get(name)?.usageHold?.() ?? null,
5428
6063
  execution: exec ? { state: exec.state, since: exec.stateChangedAt } : null,
5429
6064
  lastWorkingAt: this.lastWorkingAt.get(name) ?? null,
6065
+ turnEvidence: this.livenessTurnEvidence.has(name),
6066
+ // M-3239 (Fable F1): a restart forgets the transcript's progress; its quiet clock starts no earlier than the fleet.
6067
+ quietFloor: this.livenessTurnEvidence.has(name) ? this.startedAt : null,
5430
6068
  prompt: p.state === "awaiting_input" && p.interaction?.since ? { since: p.interaction.since } : null,
5431
6069
  waitingOn,
5432
6070
  // Asked only when it could be quiet (one indexed read per idle assignee).
@@ -6025,16 +6663,9 @@ export class FleetManager {
6025
6663
  this.tightenInstanceDirectories();
6026
6664
  // #1723: the public link's preview tunnel keeps its own lease beside it; a leftover one is reaped the same way (and
6027
6665
  // #2636's Office share tunnel's).
6028
- for (const leaseDir of [this.dataDir, join(this.dataDir, PUBLIC_PREVIEW_TUNNEL_DIR), join(this.dataDir, OFFICE_SHARE_TUNNEL_DIR)]) {
6029
- void reapStaleTunnel(leaseDir)
6030
- .then(outcome => {
6031
- if (outcome.kind === "manual")
6032
- this.logger.warn({ tunnel: outcome }, manualCleanupMessage(outcome));
6033
- else if (outcome.kind === "reaped")
6034
- this.logger.info({ how: outcome.how, pid: outcome.pid }, "Reaped a leftover tunnel");
6035
- })
6036
- .catch(err => this.logger.warn({ err }, "Tunnel reaper failed"));
6037
- }
6666
+ // M-3247: this runs after auto_open (and a /web click) may already have opened this run's own tunnels; the sweep
6667
+ // spares leases this process wrote — it once killed the named link it had opened 10 s earlier.
6668
+ void reapLeftoverTunnels([this.dataDir, join(this.dataDir, PUBLIC_PREVIEW_TUNNEL_DIR), join(this.dataDir, OFFICE_SHARE_TUNNEL_DIR)], { log: (level, message, detail) => this.logger[level](detail, message) });
6038
6669
  // An existing installation has never written the setup marker — it predates
6039
6670
  // it — so `agend setup` would open a pre-fleet form for a fleet that plainly
6040
6671
  // exists. A fleet that just came up on a config with agents in it is proof
@@ -6444,7 +7075,7 @@ export class FleetManager {
6444
7075
  * independently with its log — or a failure in the progress marker. `stillAllowed` is asked again once the awaits
6445
7076
  * are done (the asker may have lost the right, or the fleet begun stopping, meanwhile).
6446
7077
  */
6447
- async launchInstalledUpdate(origin, stillAllowed) {
7078
+ async launchInstalledUpdate(origin, stillAllowed, pin) {
6448
7079
  const { spawn } = await import("./child-process.js");
6449
7080
  const installed = await resolveInstalledAgend();
6450
7081
  if (!installed.ok) {
@@ -6452,7 +7083,8 @@ export class FleetManager {
6452
7083
  return null;
6453
7084
  }
6454
7085
  recordInternalRequest(this.dataDir, "update", origin);
6455
- const launch = await resolveUpdateLaunch(installed.agend, undefined, installed.npmDir);
7086
+ // M-3140: `pin` — this exact version (a Hub's recommendation, re-resolved by the caller), not the install's channel.
7087
+ const launch = await resolveUpdateLaunch(installed.agend, undefined, installed.npmDir, pin);
6456
7088
  if (!launch.ok) {
6457
7089
  this.failUpdateProgress(`${t("update.failure.shell")} ${t("update.failure.independent", launch.reason)}`);
6458
7090
  return null;
@@ -7102,8 +7734,16 @@ export class FleetManager {
7102
7734
  // asks "is anyone still reporting", which only the receiver can date.
7103
7735
  receivedAt: now,
7104
7736
  });
7105
- // #3647: activity, for "quiet" — not the boot itself (every agent shows working while it starts).
7106
- if (state === "working" && now - this.startedAt >= LIVENESS_STARTUP_GRACE_MS)
7737
+ // #3647: activity, for "quiet" — not the boot itself (every agent shows working while it starts). M-3239: an agent
7738
+ // whose transcript tells its turns (Claude, Codex) shows progress by its tool calls and answers, not by its pane's
7739
+ // spinner — Claude compacting its context on its own, idle, held off a stalled card's notice.
7740
+ if (msg.turnEvidence === true)
7741
+ this.livenessTurnEvidence.add(name);
7742
+ else if (msg.turnEvidence === false)
7743
+ this.livenessTurnEvidence.delete(name);
7744
+ if (typeof msg.turnActivityAt === "number")
7745
+ this.noteTurnActivity(name, msg.turnActivityAt);
7746
+ if (state === "working" && !this.livenessTurnEvidence.has(name) && now - this.startedAt >= LIVENESS_STARTUP_GRACE_MS)
7107
7747
  this.lastWorkingAt.set(name, now);
7108
7748
  // The dashboard's "working" line and its Stop button follow the edges, not the heartbeat.
7109
7749
  if (previous?.state !== state)
@@ -7348,7 +7988,8 @@ export class FleetManager {
7348
7988
  this.logger[log.level](log.fields, log.message);
7349
7989
  }
7350
7990
  // The Hub representative's begin lease + input intent run inside the final connected hand-off (sendWhenConnected).
7351
- const sent = await this.sendWhenConnected(instanceName, payload, deliveryEpoch, stillCurrent, onStartRetryHold, beforeInput);
7991
+ const sent = await this.sendWhenConnected(instanceName, payload, deliveryEpoch, stillCurrent, onStartRetryHold, beforeInput ?? (this.classicHubPrivateBlocked(instanceName) && this.classicRoomPersonInput(instanceName, payload)
7992
+ ? async () => true : undefined));
7352
7993
  if (!sent)
7353
7994
  return false;
7354
7995
  if (this.deliveryCurrent(instanceName, deliveryEpoch, stillCurrent)) {
@@ -7424,10 +8065,26 @@ export class FleetManager {
7424
8065
  async handOffAfterBeforeInput(instanceName, payload, deliveryEpoch, stillCurrent, beforeInput) {
7425
8066
  if (!(await beforeInput()))
7426
8067
  return false;
7427
- if (this.shuttingDown || !this.deliveryCurrent(instanceName, deliveryEpoch, stillCurrent))
8068
+ const privateToken = await this.prepareClassicForPerson(instanceName, payload, deliveryEpoch, stillCurrent);
8069
+ if (privateToken === false || this.shuttingDown || !this.deliveryCurrent(instanceName, deliveryEpoch, stillCurrent))
7428
8070
  return false;
7429
8071
  const ipc = this.instanceIpcClients.get(instanceName);
7430
- return !!ipc?.connected && ipc.send(this.bindHumanReceiptPayload(instanceName, payload));
8072
+ if (!ipc?.connected || (privateToken && this.classicPrivacy().read(instanceName)?.token !== privateToken))
8073
+ return false;
8074
+ const sent = ipc.send(this.bindHumanReceiptPayload(instanceName, payload));
8075
+ if (sent && privateToken) {
8076
+ try {
8077
+ if (this.classicPrivacy().resume(instanceName, privateToken)) {
8078
+ this.instanceProgress.delete(instanceName);
8079
+ this.instanceActivity.delete(instanceName);
8080
+ }
8081
+ }
8082
+ catch (err) {
8083
+ // Input was accepted: never invite a duplicate. Keep output closed if its durable release fails.
8084
+ this.logger.warn({ err, instanceName }, "Classic room output remains private after the person input");
8085
+ }
8086
+ }
8087
+ return sent;
7431
8088
  }
7432
8089
  /** Poll for the instance's IPC to come back, then send. Throws if it does not. */
7433
8090
  async sendAfterIpcReturns(instanceName, payload, deliveryEpoch = this.getDeliveryEpoch(instanceName), stillCurrent, onStartRetryHold, beforeInput) {
@@ -7912,8 +8569,8 @@ export class FleetManager {
7912
8569
  const inferredCrossInstance = (typeof meta?.from_instance === "string" && meta.from_instance.length > 0)
7913
8570
  || meta?.is_cross_instance === true
7914
8571
  || payload.is_cross_instance === true;
7915
- const waitForIdle = options.waitForIdle
7916
- ?? ((options.isCrossInstance ?? inferredCrossInstance) || payload.type === "fleet_schedule_trigger");
8572
+ const waitForIdle = (this.classicHubSerialized(instanceName) && this.classicRoomPersonInput(instanceName, payload)) || (options.waitForIdle
8573
+ ?? ((options.isCrossInstance ?? inferredCrossInstance) || payload.type === "fleet_schedule_trigger"));
7917
8574
  if (!waitForIdle) {
7918
8575
  if (this.lifecycle.isPaused(instanceName)) {
7919
8576
  if (options.noInlineWake) {
@@ -8598,6 +9255,7 @@ export class FleetManager {
8598
9255
  const hasDaemon = this.daemons.has(instanceName);
8599
9256
  const wasRunning = hasDaemon || opts?.startIfStopped === true;
8600
9257
  this.classicChannels.reloadFromDisk();
9258
+ this.observeHubAgentIncarnations(true);
8601
9259
  this.reportClassicUnrecoverableIds();
8602
9260
  this.reregisterClassicChannels();
8603
9261
  const channel = this.classicChannels.getAll().find(item => item.instanceName === instanceName);
@@ -9895,6 +10553,22 @@ export class FleetManager {
9895
10553
  && this.getInstanceAdapterId(name) === owner.adapterId && String(this.getGroupIdForInstance(name) ?? "") === owner.chatId
9896
10554
  && cfg.topic_id?.toString() === owner.threadId);
9897
10555
  }
10556
+ /**
10557
+ * M-3163: the one General of `adapterId` (its group and topic) as `userId`'s code owner — where a returning device's new code is
10558
+ * meant for (#1570; requestReturningCode still checks it all again, with the live binding, before anything is sent). Null when
10559
+ * that connection has no General with a topic, or more than one.
10560
+ */
10561
+ generalOwnerOf(adapterId, userId) {
10562
+ const found = [];
10563
+ for (const [name, cfg] of Object.entries(this.fleetConfig?.instances ?? {})) {
10564
+ if (!cfg.general_topic || this.getInstanceAdapterId(name) !== adapterId)
10565
+ continue;
10566
+ const group = String(this.getGroupIdForInstance(name) ?? ""), topic = cfg.topic_id?.toString();
10567
+ if (group && topic)
10568
+ found.push({ adapterId, userId, chatId: group, threadId: topic });
10569
+ }
10570
+ return found.length === 1 ? found[0] : null;
10571
+ }
9898
10572
  /** Exact owning General. No primary-adapter or name fallback participates in authorization. */
9899
10573
  dashboardOwner(userId, adapterId, address, threadId, username) {
9900
10574
  const world = this.worlds.get(adapterId);
@@ -10141,7 +10815,8 @@ export class FleetManager {
10141
10815
  this.initializeWebSessions();
10142
10816
  // #1827: the code goes privately to this account (a DM, or else this slash command's ephemeral answer): whoever
10143
10817
  // redeems it is recognised as that account. Recognition only — no owner (this is not an owning General's code).
10144
- const login = this.webLoginCodes.issue({ epoch: tokenEpoch(token), recipient: { adapterId, userId: data.userId, ...(data.username ? { username: data.username } : {}) } });
10818
+ // M-3277: private — a DM, else this slash command's ephemeral answer, else withdrawn (below): the session starts verified.
10819
+ const login = this.webLoginCodes.issue({ epoch: tokenEpoch(token), recipient: { adapterId, userId: data.userId, ...(data.username ? { username: data.username } : {}) }, private: true });
10145
10820
  const current = () => !this.shuttingDown && this.adapters.get(adapterId) === adapter
10146
10821
  && this.webToken === token && this.hasFleetAdmins(adapterId) && this.isFleetAdmin(data.userId, adapterId);
10147
10822
  const privateText = `${text}\n${t("dashboard.code", login.display, Math.round(LOGIN_CODE_TTL_MS / 60_000))}`;
@@ -10336,7 +11011,8 @@ export class FleetManager {
10336
11011
  if (!token || !current())
10337
11012
  return false;
10338
11013
  this.initializeWebSessions();
10339
- const issued = this.webLoginCodes.issue({ epoch: tokenEpoch(token), audience: exposureId, owner });
11014
+ // M-3277: private — the owner's DM, else (Discord) the click's ephemeral answer, else withdrawn below; never the menu itself.
11015
+ const issued = this.webLoginCodes.issue({ epoch: tokenEpoch(token), audience: exposureId, owner, private: true });
10340
11016
  // Only a public link has a link expiry (null: none — a named tunnel's ttl_minutes 0); the code's five-minute
10341
11017
  // lifetime applies to either packet.
10342
11018
  const minutes = Math.round(LOGIN_CODE_TTL_MS / 60_000);
@@ -10871,7 +11547,8 @@ export class FleetManager {
10871
11547
  }
10872
11548
  else if (input.exposureId !== undefined)
10873
11549
  return { kind: "refused" };
10874
- const issued = this.webLoginCodes.issue({ epoch: tokenEpoch(token), audience: input.exposureId ?? "local", owner });
11550
+ // M-3277: private — by DM only (withdrawn when that is not confirmed).
11551
+ const issued = this.webLoginCodes.issue({ epoch: tokenEpoch(token), audience: input.exposureId ?? "local", owner, private: true });
10875
11552
  const text = t("web.resend_code", issued.display, Math.round(LOGIN_CODE_TTL_MS / 60_000), input.label || t("web.resend_unknown_browser"), t(input.surface === "gateway" ? "web.resend_public" : "web.resend_local")) + "\n" + t("dashboard.code_next");
10876
11553
  try {
10877
11554
  await withinBudget(adapter.sendDirect(userId, text, { disablePreview: true }), performance.now() + 5_000);
@@ -11429,6 +12106,7 @@ export class FleetManager {
11429
12106
  // #1737 review: the marker this boot adopts — the startup clear may only ever clear this one.
11430
12107
  const bootUpdateMarker = updateMarkerIdentity(this.dataDir);
11431
12108
  const savedUpdateProgress = readUpdateProgress(this.dataDir);
12109
+ this.hubUpdateBootProgress = savedUpdateProgress;
11432
12110
  const pendingUpdateProgress = savedUpdateProgress
11433
12111
  && savedUpdateProgress.progress.stage !== "failed"
11434
12112
  && savedUpdateProgress.progress.stage !== "complete"
@@ -11559,6 +12237,7 @@ export class FleetManager {
11559
12237
  this.classicChannels = new ClassicChannelManager(this.dataDir, this.logger, this.getConfigHistory());
11560
12238
  const classicAdapters = fleet.channels?.length ? fleet.channels : (fleet.channel ? [fleet.channel] : []);
11561
12239
  this.classicChannels.configureAdapters(classicAdapters);
12240
+ this.observeHubAgentIncarnations();
11562
12241
  // The unrecoverable-id report is deliberately NOT sent here: no adapter
11563
12242
  // exists yet at this point in startAll(), so notifyFleetError would find
11564
12243
  // nothing to deliver through, drop the message silently, AND burn its
@@ -12118,7 +12797,7 @@ export class FleetManager {
12118
12797
  /**
12119
12798
  * #3066 §1: estimate each account's weekly 100% from the quota history (§1d) and the usage ledger's hours — both read
12120
12799
  * asynchronously, the arithmetic small (usage/capacity.ts). An account is its usage provider id ("claude",
12121
- * "claude:hsinlin", "codex:yanxianchen"): its hours are the ledger sources of that backend under that credential profile
12800
+ * "claude:work", "codex:team"): its hours are the ledger sources of that backend under that credential profile
12122
12801
  * (Codex's "unrecorded" hours are no account's). A per-model weekly ("Sonnet (weekly)") counts only that model's tokens.
12123
12802
  *
12124
12803
  * Prism #3073: no estimate rather than a wrong one —
@@ -12340,10 +13019,12 @@ export class FleetManager {
12340
13019
  * Delete inbox files older than retentionDays (by mtime). Cleans the shared
12341
13020
  * inbox (`<dataDir>/inbox`) and every workspace inbox
12342
13021
  * (`<agendHome>/workspaces/*\/inbox`). Piggybacks on the daily summary timer,
12343
- * mirroring classic chat-log rotation (same 7-day retention).
13022
+ * mirroring classic chat-log rotation (same 7-day retention). M-3281: never a file the web chat still shows.
12344
13023
  */
12345
13024
  rotateInboxes(retentionDays = 7) {
12346
13025
  const cutoff = Date.now() - retentionDays * 86400_000;
13026
+ // M-3281: a file the web chat still shows stays (device + inode), so it is there to keep when its message is archived.
13027
+ const shown = this.webFiles.shownFiles();
12347
13028
  const dirs = [join(this.dataDir, "inbox")];
12348
13029
  const workspacesDir = join(getAgendHome(), "workspaces");
12349
13030
  if (existsSync(workspacesDir)) {
@@ -12359,7 +13040,7 @@ export class FleetManager {
12359
13040
  const full = join(dir, file);
12360
13041
  try {
12361
13042
  const st = statSync(full);
12362
- if (st.isFile() && st.mtimeMs < cutoff) {
13043
+ if (st.isFile() && st.mtimeMs < cutoff && !shown.has(`${st.dev}:${st.ino}`)) {
12363
13044
  unlinkSync(full);
12364
13045
  deleted++;
12365
13046
  }
@@ -13060,6 +13741,10 @@ export class FleetManager {
13060
13741
  else if (msg.type === "instance_progress") {
13061
13742
  this.cacheInstanceProgress(name, msg.progress || null);
13062
13743
  }
13744
+ else if (msg.type === "hub_room_input") {
13745
+ if (this.instanceIpcClients.get(name) === ipc && typeof msg.correlationId === "string" && typeof msg.generation === "string")
13746
+ this.hubRoomInput?.(msg.correlationId, name, msg.generation);
13747
+ }
13063
13748
  else if (msg.type === "cross_instance_delivery_failed") {
13064
13749
  const senderSession = String(msg.senderSession ?? "");
13065
13750
  const targetInstance = String(msg.targetInstance ?? name);
@@ -13115,6 +13800,14 @@ export class FleetManager {
13115
13800
  waiter(msg);
13116
13801
  }
13117
13802
  }
13803
+ else if (msg.type === "turn_activity") {
13804
+ if (typeof msg.at === "number")
13805
+ this.noteTurnActivity(name, msg.at);
13806
+ }
13807
+ else if (msg.type === "turn_ended") {
13808
+ if (typeof msg.startedAt === "number" && typeof msg.text === "string")
13809
+ this.onTurnEndedQuietly(name, msg.startedAt, msg.text);
13810
+ }
13118
13811
  else if (msg.type === "instance_state" || msg.type === "instance_state_response") {
13119
13812
  this.cacheInstanceExecutionState(name, msg);
13120
13813
  if (msg.type === "instance_state_response") {
@@ -13387,7 +14080,7 @@ export class FleetManager {
13387
14080
  * A reaction is context, not a message (#432, reworking #413): it never triggers
13388
14081
  * an agent turn and never wakes anything. It is queued in the event log and rides
13389
14082
  * into the instance's NEXT real message as one compact leading line —
13390
- * `[Recent reactions: 👍×2 from hanhanv]` — after which it is marked consumed.
14083
+ * `[Recent reactions: 👍×2 from user1]` — after which it is marked consumed.
13391
14084
  * No pending reactions → no line → zero context spent, which is the common case.
13392
14085
  */
13393
14086
  async handleInboundReaction(r) {
@@ -13413,6 +14106,14 @@ export class FleetManager {
13413
14106
  this.eventLog?.removeReaction(instanceName, r.messageId, r.username, r.emoji);
13414
14107
  }
13415
14108
  }
14109
+ /**
14110
+ * M-3293 (#4119): an Office pat or feed a person chose to tell `instance` about (their "Tell" on, the page's per-agent
14111
+ * choice). Queued with the reactions (EventLog.addOfficeReaction): it rides the instance's next real message in the
14112
+ * same `[Recent reactions: …]` line, never wakes it and never sends anything by itself. Whether it was stored (capped).
14113
+ */
14114
+ officeTell(instance, person, kind) {
14115
+ return this.eventLog?.addOfficeReaction(instance, person, kind) ?? false;
14116
+ }
13416
14117
  /**
13417
14118
  * The queued-reaction summary for an instance's next real message, or {} when
13418
14119
  * nothing is pending (the common case must add zero context). The consume
@@ -13656,7 +14357,27 @@ export class FleetManager {
13656
14357
  }
13657
14358
  return true;
13658
14359
  }
13659
- /** File a Telegram update that was too old to inject; Needs you lists it until Acknowledge. */
14360
+ /**
14361
+ * Who a Telegram update that was too old to inject would have gone to live (handleInboundMessageCore), or null when live
14362
+ * delivery would not have taken it — then it is not "missed". A topic of the fleet group: its instance (an unbound topic
14363
+ * only gets the bind prompt live, so nobody). The fleet group's root: general ("" when none is configured). Any other chat
14364
+ * is a ClassicBot candidate: its registered room — in a group only when the message @mentions the bot — and otherwise
14365
+ * nobody (live, an unregistered chat is ignored, and an @mention there only gets the no-agent reply).
14366
+ */
14367
+ missedOfflineInstance(ev, stub) {
14368
+ const threadId = this.inboundRouteThreadId(stub);
14369
+ if (threadId)
14370
+ return this.resolveInboundTarget(stub, threadId)?.name ?? null;
14371
+ if (ev.chatId !== String(this.getChannelConfig(ev.adapterId)?.group_id ?? "")) {
14372
+ const room = this.classicChannels?.getInstanceByChannel(ev.chatId, ev.adapterId);
14373
+ if (!room)
14374
+ return null;
14375
+ const isPrivateChat = !ev.chatId.startsWith("-");
14376
+ return isPrivateChat || ev.mentionsBot ? room : null;
14377
+ }
14378
+ return Object.entries(this.fleetConfig?.instances ?? {}).find(([name, cfg]) => cfg.general_topic && this.getInstanceAdapterId(name) === ev.adapterId)?.[0] ?? "";
14379
+ }
14380
+ /** File a Telegram update that was too old to inject, where live delivery would have taken it; Needs you lists it until Acknowledge. */
13660
14381
  recordMissedOffline(ev) {
13661
14382
  if (!this.missedOfflineStore)
13662
14383
  this.missedOfflineStore = new MissedOfflineStore(this.dataDir);
@@ -13665,11 +14386,10 @@ export class FleetManager {
13665
14386
  messageId: ev.messageId, userId: ev.userId, username: ev.username, text: ev.preview,
13666
14387
  timestamp: ev.timestamp, isBotMessage: false,
13667
14388
  };
13668
- const threadId = this.inboundRouteThreadId(stub);
13669
- const target = threadId ? this.resolveInboundTarget(stub, threadId) : undefined;
13670
- let instance = target?.name ?? "";
13671
- if (!instance) {
13672
- instance = Object.entries(this.fleetConfig?.instances ?? {}).find(([name, cfg]) => cfg.general_topic && this.getInstanceAdapterId(name) === ev.adapterId)?.[0] ?? "";
14389
+ const instance = this.missedOfflineInstance(ev, stub);
14390
+ if (instance === null) {
14391
+ this.logger.debug({ adapterId: ev.adapterId, updateId: ev.updateId, chatId: ev.chatId, threadId: ev.threadId }, "Telegram message from while AgEnD was offline is not for this fleet — not filed");
14392
+ return;
13673
14393
  }
13674
14394
  const place = [ev.chatTitle, ev.threadId ? `#${ev.threadId}` : ""].filter(Boolean).join(" · ") || ev.chatId;
13675
14395
  this.missedOfflineStore.add({
@@ -14501,7 +15221,7 @@ export class FleetManager {
14501
15221
  // Above the adapter check on purpose: "retry shortly" is the wrong answer
14502
15222
  // to a call that will never be allowed, and an agent that believes it is a
14503
15223
  // timing problem will keep trying.
14504
- const permitted = this.checkToolPermission("ipc-outbound", instanceName, tool);
15224
+ const permitted = this.checkToolPermission("ipc-outbound", instanceName, tool === "hub_room_status" ? "hub_room_list" : tool);
14505
15225
  if (!permitted.allowed) {
14506
15226
  respond(null, permitted.message);
14507
15227
  return;
@@ -14516,6 +15236,31 @@ export class FleetManager {
14516
15236
  });
14517
15237
  return;
14518
15238
  }
15239
+ // M-3127: a reaction to a Hub room question (message_id = the correlation id it came with) goes to that room, under
15240
+ // the question — never to a chat. Only that question's agent; the same source-daemon fence as its Hub answer.
15241
+ if (tool === "react" && typeof args.message_id === "string" && /^hub-room-[0-9a-f-]{36}$/.test(args.message_id)) {
15242
+ const bootNow = this.getDaemonBootId(instanceName), bootSent = sourceDaemonBootId ?? bootNow;
15243
+ if (!bootNow || bootSent !== bootNow) {
15244
+ respond(null, "Source daemon generation is no longer current; outcome is unknown");
15245
+ return;
15246
+ }
15247
+ const claimed = this.hubReact({ correlationId: args.message_id, caller: instanceName, emoji: typeof args.emoji === "string" ? args.emoji : "",
15248
+ callerCurrent: () => this.getDaemonBootId(instanceName) === bootSent });
15249
+ if (!claimed) {
15250
+ respond(null, "That message_id is not a Hub room question you were asked.");
15251
+ return;
15252
+ }
15253
+ const outcome = await claimed;
15254
+ if (outcome.ok)
15255
+ respond("ok");
15256
+ else
15257
+ respond(null, outcome.message);
15258
+ return;
15259
+ }
15260
+ if (this.classicHubPrivateBlocked(instanceName) && usesChannelAddress(tool)) {
15261
+ respond(null, "This ClassicBot agent is handling private Hub input. Room output is blocked; answer the Hub with report_result.");
15262
+ return;
15263
+ }
14519
15264
  // #2305: a reaction to a web chat message is the web chat's own (any fleet, web-only included): never an adapter's.
14520
15265
  if (tool === "react" && typeof args.message_id === "string" && isWebMessageId(args.message_id)) {
14521
15266
  // The socket's own instance, never a session name the caller wrote itself (as checkToolPermission: it was not
@@ -14592,6 +15337,10 @@ export class FleetManager {
14592
15337
  // still in flight and about to succeed. One real send, everyone gets its
14593
15338
  // outcome; a genuinely failed send clears the entry so a retry passes.
14594
15339
  if (tool === "reply") {
15340
+ if (!replyPreviews(args.previews)) {
15341
+ respond(null, "reply: invalid previews");
15342
+ return;
15343
+ }
14595
15344
  // Registered synchronously before a web message is handed to this CLI.
14596
15345
  // This waits only on display ordering, never on the web delivery itself.
14597
15346
  const echoTail = this.webChannelEchoTails.get(instanceName)?.tail;
@@ -14637,6 +15386,11 @@ export class FleetManager {
14637
15386
  respond(null, stickerProblem);
14638
15387
  return;
14639
15388
  }
15389
+ // Echo ordering and sticker validation await external work; a Hub turn may have begun meanwhile.
15390
+ if (this.classicHubPrivateBlocked(instanceName)) {
15391
+ respond(null, "This ClassicBot agent is handling private Hub input. Room output is blocked; answer the Hub with report_result.");
15392
+ return;
15393
+ }
14640
15394
  const ticket = this.replyDeduper.begin(instanceName, replyDedupText(args), Array.isArray(args.files) ? args.files : []);
14641
15395
  if (ticket.duplicate) {
14642
15396
  this.logger.info({ instanceName }, "Concurrent duplicate reply joined — awaiting the original send's outcome");
@@ -14778,6 +15532,12 @@ export class FleetManager {
14778
15532
  return false;
14779
15533
  }
14780
15534
  }
15535
+ captureReplyPreview(instance, args) {
15536
+ if (!replyPreviews(args.previews)?.length)
15537
+ return undefined;
15538
+ const identity = this.webChatIdentity(instance);
15539
+ return result => { void this.afterReplyRouted(instance, args, instance, null, false, undefined, identity, result); };
15540
+ }
14781
15541
  afterReplyRouted(instanceName, args, senderSessionName, buttons = null, inChannel = false, sentAs, identity = this.webChatIdentity(instanceName), replyResult = sentAs?.result) {
14782
15542
  // AGEND-181: the id the reply call returned (also on a fleet with no adapter: web-only), the row's anchor.
14783
15543
  const returned = replyResult && typeof replyResult === "object" ? replyResult.messageId : undefined;
@@ -14830,6 +15590,7 @@ export class FleetManager {
14830
15590
  ts,
14831
15591
  ...(attachments.length ? { attachments } : {}),
14832
15592
  ...(buttons ? { buttons } : {}), // #1266
15593
+ ...(replyPreviews(args.previews)?.length ? { previews: replyPreviews(args.previews) } : {}),
14833
15594
  ...(inChannel ? { channel: true } : {}), // #1920 §5.2
14834
15595
  ...(post ? { posts: [post] } : {}), // #2281
14835
15596
  ...(typeof returned === "string" && returned ? { anchor: returned } : {}), // AGEND-181: what the reply call returned
@@ -16729,6 +17490,8 @@ export class FleetManager {
16729
17490
  clean("files", () => this.webFiles.forget(name));
16730
17491
  clean("compact", () => this.compactWatchService?.forget(name));
16731
17492
  clean("preferences", () => this.webPrefs.forgetInstance(name));
17493
+ clean("pins", () => { if (this.pinStore.forget(name))
17494
+ this.emitSseEvent("pins", { instance: name, rev: this.pinStore.rev() }); });
16732
17495
  clean("appearance", () => { this.themeStore.forget(name); this.webAppearance.forget(name); this.appearanceTools.forget(name); this.mods.forgetInstance(name); this.officeActsInstance?.forget(name); this.officePackToolsInstance?.forget(name); });
16733
17496
  }
16734
17497
  async removeInstanceOwned(name, authorization, execution, transition) {
@@ -16817,6 +17580,14 @@ export class FleetManager {
16817
17580
  catch (err) {
16818
17581
  this.logger.warn({ err: err.message, name }, "Dropping a removed instance from web favorites failed");
16819
17582
  }
17583
+ // M-3271: and its pinned messages (a later instance of the same name starts with none).
17584
+ try {
17585
+ if (this.pinStore.forget(name))
17586
+ this.emitSseEvent("pins", { instance: name, rev: this.pinStore.rev() });
17587
+ }
17588
+ catch (err) {
17589
+ this.logger.warn({ err: err.message, name }, "Dropping a removed instance's pins failed");
17590
+ }
16820
17591
  try {
16821
17592
  this.themeStore.forget(name);
16822
17593
  this.webAppearance.forget(name);
@@ -17215,6 +17986,15 @@ export class FleetManager {
17215
17986
  const caches = [...this.adapters.values()].filter(a => typeof a.mentionNames === "function").map(a => (q) => a.mentionNames(q));
17216
17987
  return resolveMentions(query, [bots, seen, ...caches]);
17217
17988
  }
17989
+ /** Guest labels use the exact instance connection/channel, never Fleet-wide seen users or another bot. */
17990
+ guestMentionNames(owner, instance, query) {
17991
+ const adapterId = this.topicAdapterIdOf(instance), world = adapterId ? this.worlds.get(adapterId) : undefined;
17992
+ const cfg = this.fleetConfig?.instances[instance];
17993
+ const channel = cfg?.topic_id ?? this.classicChannels?.getChannelIdByInstance(instance) ?? this.getGroupIdForInstance(instance);
17994
+ if (this.worlds.get(owner.adapterId)?.type !== "discord" || world?.type !== "discord" || !channel || !world.adapter.mentionNamesInChannel)
17995
+ return { u: {}, r: {}, c: {} };
17996
+ return resolveMentions(query, [q => world.adapter.mentionNamesInChannel(q, String(channel), owner.userId)]);
17997
+ }
17218
17998
  /** GET /ui/emojis: the custom emoji of every server the fleet's Discord bots are in (the Settings picker's cache). */
17219
17999
  async webEmojiList() {
17220
18000
  const adopted = [];
@@ -18404,6 +19184,10 @@ export class FleetManager {
18404
19184
  * would have to make this async and change every caller.
18405
19185
  */
18406
19186
  notifyInstanceTopic(instanceName, text, extraOpts, ack) {
19187
+ if (this.classicHubPrivateBlocked(instanceName)) {
19188
+ ack?.(false);
19189
+ return false;
19190
+ }
18407
19191
  if (isNativeExecInstance(this.fleetConfig?.instances[instanceName])) {
18408
19192
  this.emitSseEvent("message", { instance: instanceName, role: "status", sender: "AgEnD", text, ts: new Date().toISOString() });
18409
19193
  return !ack; // an SSE event is no acknowledgement
@@ -18427,6 +19211,8 @@ export class FleetManager {
18427
19211
  * edit or delete the message later (#2897). Null when there is no adapter or no postable target (already logged).
18428
19212
  */
18429
19213
  sendToInstanceTopic(instanceName, text, extraOpts) {
19214
+ if (this.classicHubPrivateBlocked(instanceName))
19215
+ return null;
18430
19216
  const adapter = this.getAdapterForInstance(instanceName) ?? this.adapter;
18431
19217
  if (!adapter) {
18432
19218
  // Early startup: adapters are created well after the fleet object exists.
@@ -18792,6 +19578,12 @@ export class FleetManager {
18792
19578
  return true;
18793
19579
  if (await this.handleKiroMigrateCallback(data, adapterId, adapter))
18794
19580
  return true;
19581
+ if (await this.handleHubSharingCallback(data, adapterId, adapter))
19582
+ return true;
19583
+ if (await this.handleHubFleetUpdateCallback(data, adapterId, adapter))
19584
+ return true;
19585
+ if (await this.handleHubUpdateCallback(data, adapterId, adapter))
19586
+ return true;
18795
19587
  if (await this.handleKiroReconcileCallback(data, adapterId, adapter))
18796
19588
  return true;
18797
19589
  if (await this.handleOfficePackCallback(data, adapterId, adapter))
@@ -19382,7 +20174,10 @@ export class FleetManager {
19382
20174
  const buttons = this.replyButtons();
19383
20175
  return buttons ? buttons.clickWeb(instance, id, index, voter) : Promise.resolve({ status: 409, error: t("reply_buttons.closed") });
19384
20176
  }
19385
- async clickWebPrompt(instance, nonce, action, text) {
20177
+ webPromptNeedsHuman(nonce) {
20178
+ return this.pendingNonceButtons.get(nonce)?.remoteCard?.humanOnly === true;
20179
+ }
20180
+ async clickWebPrompt(instance, nonce, action, text, humanSession = false) {
19386
20181
  if (!/^[0-9a-f]{32}$/.test(nonce) || !/^[a-z][a-z0-9-]{0,23}$/.test(action))
19387
20182
  return { status: 400, error: "Malformed prompt answer" };
19388
20183
  // #2675: only an action the page shows a text box for takes text, and it must say something.
@@ -19397,6 +20192,8 @@ export class FleetManager {
19397
20192
  return { status: 403, error: "This prompt belongs to another instance" };
19398
20193
  if (!entry.web.actions.some(a => a.id === action))
19399
20194
  return { status: 400, error: "Not one of this prompt's answers" };
20195
+ if (entry.remoteCard?.humanOnly && !humanSession)
20196
+ return { status: 403, error: "This decision needs a signed-in administrator" };
19400
20197
  let notice;
19401
20198
  const data = {
19402
20199
  callbackData: `${entry.prefix}${nonce}:${action}`,
@@ -19789,6 +20586,25 @@ export class FleetManager {
19789
20586
  store.prune(a => a.epoch === state.epoch && now <= Math.min(a.until, a.authorizedAt + policy.maxSessionMs) && live.has(a.handle));
19790
20587
  return { ok: true, ...store.authorize(session.handle, session.owner, now, state.epoch, now + policy.maxSessionMs, peer) };
19791
20588
  }
20589
+ /**
20590
+ * M-3277 (decision 7933bf90; auth-api, at sign-in): an admin session that signed in with a code AgEnD delivered privately
20591
+ * to its account (a DM, or Discord's ephemeral reply) starts verified — that code went to the very DM a Confirm card
20592
+ * would. §3 is judged as at a Confirm (authorizeWebSession: the switch, loopback only, the named / quick link options,
20593
+ * still an admin, the namespace); a refusal leaves the session signed in and unverified, as before. The account is told
20594
+ * at once, with Not me (noteAuthorized). Re-verifying once that authorization has run out still takes the card.
20595
+ */
20596
+ authorizeSignedInSession(session, peer, gateway) {
20597
+ if (session.tier !== "admin" || !session.owner || session.host)
20598
+ return;
20599
+ const r = this.authorizeWebSession(session, peer, gateway);
20600
+ if (!r.ok) {
20601
+ this.logger.info({ handle: session.handle, refusal: r.refusal }, "Web session signed in with a private code, not verified");
20602
+ return;
20603
+ }
20604
+ this.logger.info({ handle: session.handle, durable: r.durable }, "Web session verified at sign-in (a private code)");
20605
+ void this.sessionAuthorizationRequests().noteAuthorized({ handle: session.handle, owner: session.owner, label: session.label, peer, until: Math.min(r.authorization.until, session.absoluteExpiry) })
20606
+ .catch(err => this.logger.warn({ err: err?.message }, "Web sign-in notice failed"));
20607
+ }
19792
20608
  /**
19793
20609
  * #2910 D1 (auth-api, at sign-in): a web-only fleet's host session — signed in with the host's own code (`agend web
19794
20610
  * --code`) on this computer — is the host operator, authorized from now for max_session_hours (as an account's
@@ -19913,8 +20729,8 @@ export class FleetManager {
19913
20729
  * and their switch are another thing and stay a web-only fleet's, on its own computer (liveOwner).
19914
20730
  */
19915
20731
  authenticatorOwner(req) {
19916
- if (gatewayRequestContext(req))
19917
- return null;
20732
+ // M-3278 (decision 7933bf90): over a link too — the settings role decides (its link option, Only this computer), and an
20733
+ // app that exists asks its current code off this computer (authenticatorCodeAsked), as from the LAN.
19918
20734
  const first = this.settingsRole(req);
19919
20735
  if (!first.role.ok || !first.handle)
19920
20736
  return null;
@@ -20220,6 +21036,8 @@ export class FleetManager {
20220
21036
  kind: "ok",
20221
21037
  knownCookie: addSigninKnownDevice(webToken, input.knownCookie, who, enrollment, epoch, now),
20222
21038
  session: outside ? { remote: "totp" } : actor ? { owner: actor } : {},
21039
+ // M-3163: a chat admin's browser becomes their returning device, as a code DM'd to them makes it (#1570).
21040
+ ...(!outside && actor ? (() => { const o = this.generalOwnerOf(actor.adapterId, actor.userId); return o ? { returningOwner: o } : {}; })() : {}),
20223
21041
  // Asked again as the session is made: the same app, still an admin, still allowed here.
20224
21042
  commit: (record, label) => {
20225
21043
  if (!this.totpSignInOpen(exposureId, peer) || store.enrollmentOf(who) !== enrollment)
@@ -20318,6 +21136,36 @@ export class FleetManager {
20318
21136
  return true;
20319
21137
  }
20320
21138
  authorityStateStore = null;
21139
+ namedLinkDefaultChecked = false;
21140
+ /**
21141
+ * M-3277 (#4099 review, F1): the named link is on by default now, and before M-3277 the Settings card turned it off by
21142
+ * removing `named_link` from fleet.yaml. A fleet whose owner did that (the state file: seen, and off now) would read the
21143
+ * absent key as the new default — on again, and the epoch moved — against that owner's last choice. Once per process
21144
+ * (and again after a reload), before the state is read: such a fleet gets `named_link: false`, in memory at once and in
21145
+ * fleet.yaml (a backup first, as every upgrade migration). A fleet that never turned it on gets the default (nothing
21146
+ * was ever authorized over that link); an explicit value is never touched.
21147
+ */
21148
+ migrateNamedLinkDefault() {
21149
+ if (this.namedLinkDefaultChecked || !this.fleetConfig || !this.dataDir)
21150
+ return;
21151
+ this.namedLinkDefaultChecked = true;
21152
+ const va = this.fleetConfig.web?.verified_authority;
21153
+ if (va?.named_link !== undefined && va?.named_link !== null)
21154
+ return;
21155
+ if (!namedLinkLastTurnedOff(join(this.dataDir, "web-authority.json")))
21156
+ return;
21157
+ this.fleetConfig.web = { ...(this.fleetConfig.web ?? {}), verified_authority: { ...(va ?? {}), named_link: false } };
21158
+ this.logger.info("Web authority over the named link stays off, as last turned off (stored as named_link: false now that it is on by default)");
21159
+ if (!this.configPath || this.configHistory?.isFallback(this.configPath) || !validateFleetConfig(this.rawFleetConfig).valid)
21160
+ return;
21161
+ try {
21162
+ this.writeFleetConfigBackup(readFileSync(this.configPath, "utf8"));
21163
+ this.saveFleetConfig();
21164
+ }
21165
+ catch (err) {
21166
+ this.logger.warn({ err }, "Could not store named_link: false in fleet.yaml; it stays off for this run");
21167
+ }
21168
+ }
20321
21169
  /**
20322
21170
  * #1939 §10: the switch, "Only this computer can authorize" and the revocation epoch in force for the configuration as
20323
21171
  * it is now (a change since last seen moves the epoch first; authority-state.ts). No data directory: off.
@@ -20325,6 +21173,7 @@ export class FleetManager {
20325
21173
  webAuthorityState() {
20326
21174
  if (!this.dataDir)
20327
21175
  return { enabled: false, loopbackOnly: true, namedLink: false, quickLink: false, epoch: 0 };
21176
+ this.migrateNamedLinkDefault(); // M-3277 F1: before the first read of the state (it would move the epoch)
20328
21177
  this.authorityStateStore ??= new AuthorityStateStore(join(this.dataDir, "web-authority.json"), this.logger, undefined, undefined, () => { this.ensureDeliveryOutbox?.(); return this.deliveryOutbox?.maxWebAuthorityEpoch() ?? 0; });
20329
21178
  const state = this.authorityStateStore.current(this.fleetConfig?.web?.verified_authority);
20330
21179
  // #2453 (§0.2) / §0.3: a link's option seen going off — the authority of every session over that link ends now, for
@@ -20460,6 +21309,8 @@ export class FleetManager {
20460
21309
  text: {
20461
21310
  ask: (c) => t("web_auth.card_ask", c.label, where(c.peer), when(c.askedAt), when(c.until)),
20462
21311
  confirmed: (c) => t("web_auth.card_confirmed", c.label, where(c.peer), when(c.until)),
21312
+ signedIn: (c) => t("web_auth.signed_in", c.label, where(c.peer), when(c.until)),
21313
+ signedInHint: () => t("web_auth.signed_in_hint"),
20463
21314
  denied: (c) => t("web_auth.card_denied", c.label),
20464
21315
  expired: (c) => t("web_auth.card_expired", c.label),
20465
21316
  refused: (c) => t("web_auth.card_refused", c.label, t(`web_auth.refusal_${c.refusal}`)),
@@ -20574,7 +21425,7 @@ export class FleetManager {
20574
21425
  return null;
20575
21426
  return { handle, current: verified, revoke: () => { const session = live(); return this.revokeWebAuthority(session ? { session, peer, gateway: false } : undefined); } };
20576
21427
  }
20577
- /** #1269: an instance's chat command from the web chat (web-commands.ts); `publicLink`: a gateway request. */
21428
+ /** #1269: an instance's chat command from the web chat (web-commands.ts); `publicLink`: a gateway request by anyone but an admin session (M-3278). */
20578
21429
  /** #2855: the table scope of an instance the web chat may command (a fleet instance or a ClassicBot room), else null. */
20579
21430
  webCommandScope(instance) {
20580
21431
  // Own entries only: a name like "__proto__" or "constructor" must not be found on the prototype (#1476 review).
@@ -20602,6 +21453,9 @@ export class FleetManager {
20602
21453
  return { current: catalog.current_model, options: catalog.models.map(m => ({ id: m.id, label: m.label })), actions: ["refresh"] };
20603
21454
  }
20604
21455
  const backend = this.backendNameForInstance(instance);
21456
+ // Opened on an empty list, the menu waits for one bounded discovery ("loading") instead of showing nothing.
21457
+ if (!more)
21458
+ await this.ensureModelCatalog(backend, instance);
20605
21459
  const env = this.webModelEnv(backend, instance);
20606
21460
  const current = this.resolveInstanceModel(instance).model;
20607
21461
  const models = more ? this.modelCatalogFor(backend, instance) : env?.models ?? [];
@@ -20671,7 +21525,11 @@ export class FleetManager {
20671
21525
  const refusal = this.backendCommandRefusal(instance);
20672
21526
  if (refusal)
20673
21527
  return { error: refusal };
20674
- // The cached model lists only, as the web's /model: never a live probe on this path.
21528
+ // The cached model lists, as the web's /model; an empty one is discovered once, bounded (moving to a CLI
21529
+ // never signed in at startup, or probed before it was installed, must not offer an empty list).
21530
+ const wanted = backendArgs(args)[0];
21531
+ if (wanted && KNOWN_BACKENDS.includes(wanted))
21532
+ await this.ensureModelCatalog(wanted, instance);
20675
21533
  const step = await backendStep({ ...this.backendCommandDeps(instance, { live: false }), models: async (backend) => this.modelCatalogFor(backend, instance) }, instance, backendArgs(args));
20676
21534
  if (step.kind === "refuse")
20677
21535
  return step.noop ? { text: step.text } : { error: step.text };
@@ -20680,6 +21538,7 @@ export class FleetManager {
20680
21538
  return { choices: { step: step.step, args: joinBackendArgs(step.args), ...(step.step === "model" ? { actions: ["refresh"] } : {}), prompt: step.text, current: step.current === null ? null : id(step.current), options: step.choices.map(c => {
20681
21539
  // #2233: the web offers Sign in beside it, so its reason is no longer "use /login".
20682
21540
  // Not over the public link: Sign in is refused there, so the choice keeps its "(use /login)" (#2262 review).
21541
+ // M-3278 (decision 7933bf90): `publicLink` is set for a non-admin only, so the link's admin session gets Sign in.
20683
21542
  const signIn = c.signIn && !stepOpts?.publicLink && dashboardSignInSupported(c.signIn) ? c.signIn : null;
20684
21543
  const disabled = signIn ? t("backend.reason_not_signed_in_web") : c.disabled;
20685
21544
  return { id: id(c.token), label: signIn ? `${c.token} — ${disabled}` : c.label, ...(disabled ? { disabled } : {}), ...(signIn ? { signIn } : {}) };
@@ -20861,6 +21720,8 @@ export class FleetManager {
20861
21720
  await this.notifyNormalExit(instanceName, unclear ? "unclear" : true);
20862
21721
  }
20863
21722
  async notifyNormalExit(instanceName, oom = false) {
21723
+ if (this.classicHubPrivateBlocked(instanceName))
21724
+ return;
20864
21725
  const daemon = oom === "unclear" ? this.daemons.get(instanceName) : undefined;
20865
21726
  const owner = daemon ? { ...daemon.getInteractionSnapshot().owner } : undefined;
20866
21727
  const current = daemon && owner ? () => this.daemons.get(instanceName) === daemon
@@ -21169,7 +22030,7 @@ export class FleetManager {
21169
22030
  message: prompt.message, choices: prompt.choices, webInput: prompt.webInput,
21170
22031
  expiredText: t("card.expired", instanceName), timeoutMs: REMOTE_CARD_TIMEOUT_MS,
21171
22032
  extra: { remoteCard: { identity: card.identity, kind: card.kind, options: shown.kind === "question" ? shown.options.map(o => ({ n: o.n, title: o.title })) : [],
21172
- requiresAdmin, ownerAdapterId: this.getInstanceAdapterId(instanceName) } },
22033
+ requiresAdmin, ownerAdapterId: this.getInstanceAdapterId(instanceName), humanOnly: card.kind === "question" && card.humanOnly === true } },
21173
22034
  });
21174
22035
  if (nonce)
21175
22036
  this.remoteCardPosts.set(instanceName, nonce);
@@ -21633,7 +22494,7 @@ export class FleetManager {
21633
22494
  * so claiming every retained checkpoint is "completed" would be false. */
21634
22495
  composeRetiredBubbleText(entry) {
21635
22496
  const elapsed = FleetManager.formatProgressElapsed(Date.now() - (entry.startedAt ?? Date.now()));
21636
- return `🧾 工具歷程 (記錄至 ${elapsed})\n${entry.toolProgress}`;
22497
+ return `${t("progress.trace_title", elapsed)}\n${entry.toolProgress}`;
21637
22498
  }
21638
22499
  /**
21639
22500
  * Make a tool summary safe to paste into a channel message.
@@ -21663,6 +22524,8 @@ export class FleetManager {
21663
22524
  * never used to decide anything — purely what the user is shown.
21664
22525
  */
21665
22526
  cacheInstanceActivity(name, activity) {
22527
+ if (this.classicHubPrivateBlocked(name))
22528
+ return;
21666
22529
  if (activity)
21667
22530
  this.instanceActivity.set(name, activity);
21668
22531
  else
@@ -21675,6 +22538,8 @@ export class FleetManager {
21675
22538
  * rate-limited per bubble AND ride behind the daemon-side 3s coalescer).
21676
22539
  */
21677
22540
  cacheInstanceProgress(name, progress) {
22541
+ if (this.classicHubPrivateBlocked(name))
22542
+ return;
21678
22543
  if (progress)
21679
22544
  this.instanceProgress.set(name, progress);
21680
22545
  else
@@ -21726,6 +22591,8 @@ export class FleetManager {
21726
22591
  }
21727
22592
  /** Recompose and edit the bubble in place; skips when nothing changed. */
21728
22593
  refreshBubble(entry) {
22594
+ if (this.classicHubPrivateBlocked(entry.instanceName))
22595
+ return;
21729
22596
  if (entry.retiring || !this.cancelButtons.has(entry.messageId)) {
21730
22597
  clearInterval(entry.progressTimer);
21731
22598
  return;
@@ -22075,8 +22942,10 @@ export class FleetManager {
22075
22942
  // #2072: a sign-in just finished — the pickers learn it now, not at the next pass.
22076
22943
  if (!profile)
22077
22944
  void this.backendAvailability.refresh([backend], { force: true });
22945
+ this.modelsAfterSignIn(backend, profile ?? null); // Chat /login and the dashboard's terminal sign-in
22078
22946
  return this.recoverBackendInstances(backend, undefined, profile ?? null);
22079
22947
  },
22948
+ agentLabel: name => this.fleetConfig?.instances[name]?.display_name?.trim() || name, // M-3249: the outcome line names agents as people see them
22080
22949
  claimWindow: backend => this.loginWindow.tryClaim("web", backend),
22081
22950
  releaseWindow: claim => { this.loginWindow.release(claim); },
22082
22951
  isClaimCurrent: claim => this.loginWindow.isCurrent(claim),
@@ -22110,7 +22979,7 @@ export class FleetManager {
22110
22979
  reported: (id, profile, backend) => this.machineAccounts.profileState(id, profile, backend),
22111
22980
  reportedDefault: (id, backend) => this.machineAccounts.reportedDefault(id, backend),
22112
22981
  readiness: (id, backend, named) => this.machineAccounts.readiness(id, backend, named),
22113
- actor: owner => { const handle = owner.handle; return typeof handle === "string" && /^[a-f0-9]{16}$/.test(handle) ? `admin:${handle}` : null; },
22982
+ actor: owner => this.machineSignInActor(owner),
22114
22983
  changed: (event, owner) => {
22115
22984
  // Safe fields only: the computer, the CLI, the profile name (none for Antigravity's default login), a phase and a fixed reason. Never a URL, a code, output or an e-mail address.
22116
22985
  this.logger.info({ machine: event.machine, backend: event.backend, ...(event.profile ? { profile: event.profile } : {}), phase: event.phase, ...(event.reason ? { reason: event.reason } : {}), by: owner.label }, "Computer account sign-in from Settings → Accounts");
@@ -22118,11 +22987,44 @@ export class FleetManager {
22118
22987
  // Only the computer's OWN login (no profile) is remembered here: a named account's sign-in is reported by its Runtime's inventory, which it sends before the sign-in ends.
22119
22988
  if (event.phase === "done" && event.profile === undefined)
22120
22989
  this.machineAccounts.noteDefaultLogin(event.machine, event.backend, true);
22990
+ // That computer's Runtime lists models in its own inventory (never a host probe): pages read it again now,
22991
+ // and the Runtime is asked once, for the admin who finished the sign-in, to list them as this account.
22992
+ if (event.phase === "done") {
22993
+ this.announceModels(event.backend);
22994
+ void this.nativeModelsAfterSignIn(event, owner);
22995
+ }
22121
22996
  broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed"));
22122
22997
  this.needsYou?.poke();
22123
22998
  },
22124
22999
  });
22125
23000
  }
23001
+ /**
23002
+ * A paired computer's sign-in ended — ask its Runtime once (`models.refresh`, as the admin who finished the
23003
+ * sign-in) for the list as this account, so the next read of its agents' and the create dialog's list has it without the
23004
+ * Refresh button. Once per sign-in; never on a read (M-2239 P1-2). A Runtime without the capability, a refused account or any
23005
+ * failure is skipped quietly: the sign-in is done either way.
23006
+ */
23007
+ /** The name a paired computer's audit log records for the admin session that signed in on it (`admin:<handle>`); null refuses. */
23008
+ machineSignInActor(owner) {
23009
+ const handle = owner.handle;
23010
+ return typeof handle === "string" && /^[a-f0-9]{16}$/.test(handle) ? `admin:${handle}` : null;
23011
+ }
23012
+ async nativeModelsAfterSignIn(event, owner) {
23013
+ try {
23014
+ const actor = this.machineSignInActor(owner);
23015
+ if (!actor || this.shuttingDown || !this.browserSignInOwnerCurrent(owner))
23016
+ return;
23017
+ const refreshed = await refreshNativeModelCatalogAfterSignIn(this, {
23018
+ backend: event.backend, machineId: event.machine, ...(event.profile ? { profile: event.profile } : {}), actor,
23019
+ stillAdmin: () => !this.shuttingDown && this.browserSignInOwnerCurrent(owner),
23020
+ });
23021
+ if (refreshed)
23022
+ this.announceModels(event.backend);
23023
+ }
23024
+ catch (err) {
23025
+ this.logger.debug({ backend: event.backend, err }, "Model refresh after a computer's sign-in skipped");
23026
+ }
23027
+ }
22126
23028
  machineAccountsInstance = null;
22127
23029
  /** #3190 Part 3c: a paired computer's accounts in Settings → Accounts (machine-accounts.ts). */
22128
23030
  get machineAccounts() {
@@ -22171,6 +23073,7 @@ export class FleetManager {
22171
23073
  broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed"));
22172
23074
  if (event.phase === "done") {
22173
23075
  this.forgetSignInIdentities(); // a sign-in may be a different account now
23076
+ this.modelsAfterSignIn(event.backend, null); // The list read before this sign-in (a signed-out CLI answers none) is not this account's
22174
23077
  this.keepAliveAfterSignIn(event.backend, null); // its file changed, whoever is watching: a "needs sign-in" left from before is no longer the answer
22175
23078
  this.usageAfterSignIn(); // the usage read before this sign-in is not this account's
22176
23079
  }
@@ -22226,6 +23129,7 @@ export class FleetManager {
22226
23129
  broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed"));
22227
23130
  if (event.phase === "done") {
22228
23131
  this.forgetSignInIdentities(); // a sign-in may be a different account now
23132
+ this.modelsAfterSignIn(event.backend, event.profile);
22229
23133
  this.keepAliveAfterSignIn(event.backend, event.profile);
22230
23134
  this.usageAfterSignIn();
22231
23135
  }
@@ -22948,7 +23852,7 @@ export class FleetManager {
22948
23852
  if (!structuredSignInSupported(backend) || !STRUCTURED_PROFILE_BACKENDS.has(backend))
22949
23853
  return false;
22950
23854
  const row = this.backendAvailabilityRows().find(r => r.backend === backend);
22951
- return !!row && row.state !== "not_installed" && row.state !== "too_old" && versionAtLeast(row.version, hostFacts(backend, "structuredSignIn")?.minVersion);
23855
+ return !!row && row.state !== "not_installed" && row.state !== "too_old" && structuredSignInReady(row, hostFacts(backend, "structuredSignIn")?.minVersion);
22952
23856
  }
22953
23857
  backendSignInTargets() {
22954
23858
  const out = [];
@@ -22959,10 +23863,11 @@ export class FleetManager {
22959
23863
  // whether it is over, and then it is not signed in (never the other way: the file can't vouch for a login).
22960
23864
  const ended = row.state === "usable" && this.claudeSignInEnded(row.backend, null);
22961
23865
  // A CLI the dashboard drives with the structured sign-in (registry: `host.structuredSignIn`) although chat's /login and the browser terminal decline it (Antigravity: `agy acp --login`, agy
22962
- // >= its `minVersion`) is signed in from Settings → Accounts. A CLI that is older, or whose version is not known, keeps "Sign in on the host" and is told to update.
23866
+ // >= its `minVersion`, or — AGEND-274, only while the version is unknown — its file holds the command's `marker`) is signed in from Settings → Accounts. A CLI that is older, or whose version is not
23867
+ // known and whose file was not seen to hold the marker, keeps "Sign in on the host" (told to update only when the version is known to be older).
22963
23868
  const structured = hostFacts(row.backend, "structuredSignIn");
22964
23869
  const viaStructured = !!structured && flow?.remoteLogin === "unsupported" && row.state !== "not_installed";
22965
- const structuredSignIn = viaStructured && versionAtLeast(row.version, structured.minVersion);
23870
+ const structuredSignIn = viaStructured && structuredSignInReady(row, structured.minVersion);
22966
23871
  // Told to update only when the version is KNOWN to be older: a version that was not read yet is not "too old".
22967
23872
  const structuredUpdate = viaStructured && !structuredSignIn && typeof row.version === "string" && /\d/.test(row.version);
22968
23873
  out.push({
@@ -22995,11 +23900,14 @@ export class FleetManager {
22995
23900
  }
22996
23901
  return out;
22997
23902
  }
22998
- /** #2233: the session with this handle is live, admin, local and of the current dashboard token. */
23903
+ /**
23904
+ * #2233: the session with this handle is live, admin and of the current dashboard token. M-3278 (decision 7933bf90): on
23905
+ * any listener — the public link's admin session too (closing the link revokes its sessions, so none outlives it).
23906
+ */
22999
23907
  isLocalAdminSession(handle) {
23000
23908
  const sessions = this.webSessions, token = this.webToken;
23001
23909
  const record = sessions?.findByHandle(handle);
23002
- return !!record && !!token && record.tier === "admin" && record.surface === "local" && sessions.isCurrent(record, tokenEpoch(token));
23910
+ return !!record && !!token && record.tier === "admin" && sessions.isCurrent(record, tokenEpoch(token));
23003
23911
  }
23004
23912
  /**
23005
23913
  * #2233: `/login` for a dashboard requester. The same controller and checks; a CLI that is not installed is refused
@@ -23982,6 +24890,9 @@ export class FleetManager {
23982
24890
  storablePath: (id) => this.webFiles.storablePath(id),
23983
24891
  restore: (entry, instance) => this.webFiles.restoreServed(entry, instance, join(getAgendHome(), "workspaces", instance, "inbox"), webFilesDir(getAgendHome(), instance) ?? undefined),
23984
24892
  drop: (ids) => this.webFiles.dropServed(ids),
24893
+ // M-3281: an archived message keeps its files (web-chat-archive.ts `files/`), served from there while it is read.
24894
+ keep: (id, dest) => this.webFiles.keepCopy(id, dest),
24895
+ restoreKept: (entry, instance, keptDir) => this.webFiles.restoreKept(entry, instance, keptDir),
23985
24896
  });
23986
24897
  let restored = 0;
23987
24898
  for (const name of names)
@@ -23998,6 +24909,21 @@ export class FleetManager {
23998
24909
  this.logger.info({ swept }, "Removed web reply snapshots no message holds");
23999
24910
  this.webChatStore = store;
24000
24911
  this.webChatHistory.setStore(store);
24912
+ // M-3272: messages leaving the 500-message window are archived per agent (owner-bound as web-chat.json is), kept
24913
+ // for web.chat_archive.retention_days (unset or 0: everything). M-3281: with their files, every agent's together
24914
+ // within web.chat_archive.files_max_gb (default 5 GiB; the oldest go first) — checked once soon after the start too.
24915
+ const archive = new WebChatArchive({ home: getAgendHome(), ownerOf: (name) => this.webChatOwner(name), logger: this.logger,
24916
+ retentionDays: () => this.fleetConfig?.web?.chat_archive?.retention_days,
24917
+ filesMaxGb: () => this.fleetConfig?.web?.chat_archive?.files_max_gb });
24918
+ this.webChatArchive = archive;
24919
+ this.webChatHistory.setArchive(archive);
24920
+ const capCheck = setTimeout(() => { try {
24921
+ archive.enforceFilesCap();
24922
+ }
24923
+ catch (err) {
24924
+ this.logger.warn({ err }, "Web chat archive: the files' size limit could not be checked");
24925
+ } }, 30_000);
24926
+ capCheck.unref?.();
24001
24927
  if (restored)
24002
24928
  this.logger.info({ restored, instances: names.size }, "Web chat history restored from disk");
24003
24929
  }
@@ -24033,6 +24959,7 @@ export class FleetManager {
24033
24959
  anchor: typeof m.anchor === "string" ? m.anchor : undefined,
24034
24960
  role: typeof m.role === "string" ? m.role : undefined,
24035
24961
  buttons: m.buttons,
24962
+ previews: m.previews,
24036
24963
  click: m.click,
24037
24964
  links: m.links,
24038
24965
  channel: m.channel,
@@ -24135,6 +25062,8 @@ export class FleetManager {
24135
25062
  }
24136
25063
  }
24137
25064
  async sendHangNotification(instanceName, unchangedForMs) {
25065
+ if (this.classicHubPrivateBlocked(instanceName))
25066
+ return;
24138
25067
  const web = this.webOnlyPromptPlace(); // no chat platform: asked on the dashboard (#1307 item 6)
24139
25068
  const adapter = web?.adapter ?? this.getAdapterForInstance(instanceName) ?? this.adapter;
24140
25069
  const adapterId = web?.adapterId ?? this.getInstanceAdapterId(instanceName);
@@ -25033,6 +25962,114 @@ export class FleetManager {
25033
25962
  this.logger.info({ instanceName, model }, "Runtime model switch sent");
25034
25963
  });
25035
25964
  }
25965
+ /**
25966
+ * M-3175: codex's `/model [NAME] --reasoning=LEVEL` in the running session. The daemon types it only into an idle pane of a
25967
+ * codex at 0.164.0 or later (else `not_sent`, with the reason) and reports what codex recorded. Its wait for idle is part of
25968
+ * the time allowed here.
25969
+ */
25970
+ runCodexRuntimeSwitch(instanceName, model, effort) {
25971
+ const ipc = this.instanceIpcClients.get(instanceName), line = codexModelCommand(model, effort);
25972
+ if (!ipc || !line)
25973
+ return Promise.resolve({ outcome: "not_sent" });
25974
+ const id = `switch-${randomUUID()}`;
25975
+ return new Promise(resolve => {
25976
+ const timer = setTimeout(() => { this.runtimeSwitchWaiters.delete(id); resolve({ outcome: "not_confirmed" }); }, CODEX_RUNTIME_SWITCH_RESULT_MS);
25977
+ timer.unref?.();
25978
+ this.runtimeSwitchWaiters.set(id, result => { clearTimeout(timer); resolve(result); });
25979
+ const sent = ipc.send({ type: "raw_paste", content: line, runtime_switch: { id, kind: "model", requested: model ?? "", codex: { model, effort } } });
25980
+ if (!sent) {
25981
+ clearTimeout(timer);
25982
+ this.runtimeSwitchWaiters.delete(id);
25983
+ resolve({ outcome: "not_sent" });
25984
+ return;
25985
+ }
25986
+ this.logger.info({ instanceName, model, effort }, "Codex runtime switch sent");
25987
+ });
25988
+ }
25989
+ /**
25990
+ * M-3180: the in-session switch of a CLI in CLI_RUNTIME_SWITCH, one command at a time (the entry's steps), each typed by the
25991
+ * daemon only into an idle pane of a running binary at the entry's minimum for that step, and confirmed by what the CLI showed
25992
+ * after it. The first step that did not switch ends it, with that step. A model the CLI cannot vouch for is not typed.
25993
+ */
25994
+ async runCliRuntimeSwitch(instanceName, backend, want) {
25995
+ const entry = CLI_RUNTIME_SWITCH[backend];
25996
+ let last = { result: { outcome: "not_sent" }, step: want };
25997
+ for (const step of entry.steps(want)) {
25998
+ if (step.model !== null && entry.knownModel && entry.knownModel(step.model) !== true)
25999
+ return { result: { outcome: "not_sent", reason: "unknown_model" }, step };
26000
+ const line = entry.command(step), ipc = this.instanceIpcClients.get(instanceName);
26001
+ if (!line)
26002
+ return { result: { outcome: "not_sent", reason: "command" }, step };
26003
+ if (!ipc)
26004
+ return { result: { outcome: "not_sent" }, step };
26005
+ const id = `switch-${randomUUID()}`;
26006
+ const result = await new Promise(resolve => {
26007
+ const timer = setTimeout(() => { this.runtimeSwitchWaiters.delete(id); resolve({ outcome: "not_confirmed" }); }, CODEX_RUNTIME_SWITCH_RESULT_MS);
26008
+ timer.unref?.();
26009
+ this.runtimeSwitchWaiters.set(id, r => { clearTimeout(timer); resolve(r); });
26010
+ const sent = ipc.send({ type: "raw_paste", content: line, runtime_switch: { id, kind: "model", requested: step.model ?? "", cli: { backend, model: step.model, effort: step.effort } } });
26011
+ if (!sent) {
26012
+ clearTimeout(timer);
26013
+ this.runtimeSwitchWaiters.delete(id);
26014
+ resolve({ outcome: "not_sent" });
26015
+ return;
26016
+ }
26017
+ this.logger.info({ instanceName, backend, step }, "CLI runtime switch sent");
26018
+ });
26019
+ last = { result, step };
26020
+ if (result.outcome !== "switched")
26021
+ return last;
26022
+ }
26023
+ return last;
26024
+ }
26025
+ /**
26026
+ * M-3180: whether this instance's `/model` / `/effort` try its CLI's in-session switch. kiro: only an instance last launched on the
26027
+ * TUI (the v2 engine; the engine ledger) — classic and V3 keep the restart.
26028
+ */
26029
+ cliSwitchRouted(instanceName, backend) {
26030
+ if (!Object.hasOwn(CLI_RUNTIME_SWITCH, backend))
26031
+ return false;
26032
+ if (backend === "kiro-cli")
26033
+ return readKiroLedger()[instanceName]?.lastLaunch.ui === "tui";
26034
+ return true;
26035
+ }
26036
+ /** M-3180: why a CLI_RUNTIME_SWITCH switch fell back to a restart, in the reply's words. */
26037
+ cliSwitchFallbackReason(backend, { result, step }) {
26038
+ const cli = BACKEND_LABELS[backend] ?? backend, entry = CLI_RUNTIME_SWITCH[backend];
26039
+ if (result.outcome === "not_sent" && result.reason === "busy")
26040
+ return t("codex_switch.busy");
26041
+ if (result.outcome === "not_sent" && result.reason === "version") {
26042
+ return t("cli_switch.version", cli, result.version ?? t("codex_switch.version_unknown"), step.model !== null ? entry.minVersion.model : entry.minVersion.effort);
26043
+ }
26044
+ if (result.outcome === "not_sent" && result.reason === "unknown_model")
26045
+ return t("cli_switch.unknown_model", cli, step.model ?? "");
26046
+ if (result.outcome === "not_sent" && result.reason === "command")
26047
+ return t("cli_switch.not_one_command", cli, step.model ?? step.effort ?? "");
26048
+ if (result.outcome === "mismatch")
26049
+ return t("cli_switch.mismatch", cli, result.shown);
26050
+ return t("cli_switch.unconfirmed", cli);
26051
+ }
26052
+ /** M-3175: why a codex switch fell back to a restart, in the reply's words. */
26053
+ codexSwitchFallbackReason(result) {
26054
+ if (result.outcome === "not_sent" && result.reason === "busy")
26055
+ return t("codex_switch.busy");
26056
+ if (result.outcome === "not_sent" && result.reason === "version")
26057
+ return t("codex_switch.version", result.version ?? t("codex_switch.version_unknown"), CODEX_INLINE_MODEL_MIN);
26058
+ if (result.outcome === "mismatch")
26059
+ return t("codex_switch.mismatch", result.shown);
26060
+ return t("codex_switch.unconfirmed");
26061
+ }
26062
+ /**
26063
+ * M-3175: the effort a codex model switch carries — the one a restart would launch with (configured, and listed by that
26064
+ * model's catalog, as the launch flag is gated); null when there is none, and codex then takes the model's default, as a
26065
+ * launch without an effort does.
26066
+ */
26067
+ codexSwitchEffort(instanceName, model) {
26068
+ const effort = this.resolveInstanceEffort(instanceName).effort;
26069
+ if (!effort)
26070
+ return null;
26071
+ return this.instanceEffortMetadata(instanceName, model).levels.includes(effort) ? effort : null;
26072
+ }
25036
26073
  /**
25037
26074
  * #1690: the names claude-code is known to accept, for checking `/model <name>` BEFORE it is typed — claude itself
25038
26075
  * accepts any string ("Set model to opsu"), and its "Switch model?" then names the typo. Static aliases (with [1m]),
@@ -25328,6 +26365,8 @@ export class FleetManager {
25328
26365
  /** Preserve the existing cache merge rules for worker probes. */
25329
26366
  persistCliEnvProbeResult(backend, probed, profile = null) {
25330
26367
  const env = { backend, probedAt: Date.now(), ...probed };
26368
+ const listed = (e) => (e?.models ?? []).map(m => m.id).join("\0");
26369
+ const before = listed(this.readCliEnv(backend, profile));
25331
26370
  // An empty result must never overwrite a catalog we already have. Some
25332
26371
  // probes hit the network (`agy models` fetches, 5s cap), so a slow moment
25333
26372
  // returns [] — and writing that would blank the list for the whole 24h
@@ -25358,6 +26397,8 @@ export class FleetManager {
25358
26397
  const path = this.cliEnvPath(backend, profile);
25359
26398
  mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
25360
26399
  writeFileSync(path, JSON.stringify(env, null, 2));
26400
+ if (listed(env) !== before)
26401
+ this.announceModels(backend); // An open /model or Settings page reads the new list
25361
26402
  return env;
25362
26403
  }
25363
26404
  /** Background-probe every distinct backend in use at startup (non-blocking). */
@@ -25379,6 +26420,105 @@ export class FleetManager {
25379
26420
  void this.probeBackendBounded(b);
25380
26421
  this.probeChangedCliEnvs(null);
25381
26422
  }
26423
+ /**
26424
+ * Whether a named account's catalog can be discovered without publishing another account's models under its name
26425
+ * (#3526 / D7). A CLI whose profile is a variable the probe inherits (codex, kiro, claude) is. A CLI told its account by an
26426
+ * argument (agy, `launch-argument`) is too, since AGEND-278: the probe is run with the account's own folder
26427
+ * (backend/antigravity.ts `listModels`), and it answers nothing for a folder with no sign-in. Never a profile on a
26428
+ * backend that has no credential home at all.
26429
+ */
26430
+ modelDiscoverable(backend, binding) {
26431
+ return !binding.profile || !!credentialHomeSpec(backend);
26432
+ }
26433
+ /** One model discovery for a binding — the scoped (own config) or the shared per-backend/profile cache — or null when fenced. */
26434
+ discoverModels(backend, name, binding = this.webModelBinding(backend, name), opts = {}) {
26435
+ if (!binding || !this.modelDiscoverable(backend, binding))
26436
+ return null;
26437
+ // A scoped read resolves its binding again (publication and current checks included), so it is handed the selection the
26438
+ // binding came from: without it the agent's saved/default account would be probed and populated instead.
26439
+ return binding.scoped
26440
+ ? this.refreshModelCatalogFor(backend, name, opts.selection, opts.afterSignIn ? { afterSignIn: true } : {})
26441
+ : this.probeBackendBounded(backend, { profile: binding.profile, ...(opts.refreshVendorCatalog ? { refreshVendorCatalog: true } : {}) });
26442
+ }
26443
+ /** The `models` stream event: a backend's model list changed — an open page reads it again (no details, as `backend_login`). */
26444
+ announceModels(backend) {
26445
+ try {
26446
+ broadcastSseEvent(this.sseClients, "models", { backend }, err => this.logger.debug({ err }, "models event failed"));
26447
+ }
26448
+ catch { /* best effort */ }
26449
+ }
26450
+ modelOpenProbes = new Map();
26451
+ /**
26452
+ * The list a menu opens on. Cached and fresh: nothing to do. Empty (never discovered: the CLI was signed out
26453
+ * at startup, or the agent just moved to this CLI): one bounded discovery that the caller waits for — so `/model` and
26454
+ * Settings show "loading" instead of an empty list. Stale: the list stands and is refreshed behind it. Both join a
26455
+ * discovery already running, and an attempt that found nothing is not repeated for MODEL_OPEN_PROBE_COOLDOWN_MS.
26456
+ * Never throws; a Windows Runtime's catalog is its inventory's and is not a host probe.
26457
+ */
26458
+ async ensureModelCatalog(backend, instance, selection) {
26459
+ try {
26460
+ const binding = this.webModelBinding(backend, instance, selection);
26461
+ if (!binding || this.shuttingDown)
26462
+ return;
26463
+ const env = this.webModelEnv(backend, instance, selection);
26464
+ const empty = !env?.models?.length;
26465
+ if (!empty && !this.cliEnvNeedsRefresh(env))
26466
+ return;
26467
+ this.modelOpenProbes ??= new Map();
26468
+ const last = this.modelOpenProbes.get(binding.key);
26469
+ if (last !== undefined && Date.now() - last < MODEL_OPEN_PROBE_COOLDOWN_MS)
26470
+ return;
26471
+ const work = this.discoverModels(backend, instance, binding, { selection });
26472
+ if (!work)
26473
+ return;
26474
+ const done = work.catch(err => { this.logger.debug({ backend, instance, err }, "Model discovery on open failed"); }).then(() => {
26475
+ const after = this.webModelEnv(backend, instance, selection);
26476
+ if (!after?.models?.length || this.cliEnvNeedsRefresh(after))
26477
+ this.modelOpenProbes.set(binding.key, Date.now());
26478
+ else
26479
+ this.modelOpenProbes.delete(binding.key);
26480
+ });
26481
+ if (!empty)
26482
+ return;
26483
+ let timer;
26484
+ await Promise.race([done, new Promise(resolve => { timer = setTimeout(resolve, MODEL_OPEN_PROBE_WAIT_MS); timer.unref?.(); })]);
26485
+ if (timer)
26486
+ clearTimeout(timer);
26487
+ }
26488
+ catch (err) {
26489
+ this.logger.debug({ backend, instance, err }, "Model discovery on open failed");
26490
+ }
26491
+ }
26492
+ /**
26493
+ * A sign-in just ended, so the CLI can now answer `models` as this account — whatever started the sign-in
26494
+ * (Settings → Accounts, a named account, chat `/login`, the dashboard's terminal). The account's list is read again now,
26495
+ * not at the next startup or by hand. The default account: the backend's shared cache. A named account: its own store
26496
+ * (claude's profile catalog), or each agent's scoped one (the other CLIs, agy included: its probe runs with the account's folder).
26497
+ * A provider-bound agent does not depend on the sign-in. Background; each page is told when the list changed.
26498
+ */
26499
+ modelsAfterSignIn(backend, profile) {
26500
+ if (this.shuttingDown || !KNOWN_BACKENDS.includes(backend) || backend === "mock")
26501
+ return;
26502
+ (this.modelOpenProbes ??= new Map()).clear(); // a cooldown from before the sign-in said "nothing to find": it no longer does
26503
+ const settle = (work) => {
26504
+ void work?.catch(err => this.logger.debug({ backend, profile, err }, "Model discovery after sign-in failed"));
26505
+ };
26506
+ if (profile === null) {
26507
+ settle(this.discoverModels(backend, null, undefined, { refreshVendorCatalog: true }));
26508
+ return;
26509
+ }
26510
+ if (backend === "claude-code") {
26511
+ settle(this.probeBackendBounded(backend, { profile, refreshVendorCatalog: true }));
26512
+ return;
26513
+ }
26514
+ for (const name of this.configuredBackendInstanceNames()) {
26515
+ if (this.backendNameOf(name) !== backend || this.credentialProfileOf(name, backend) !== profile)
26516
+ continue;
26517
+ const binding = this.webModelBinding(backend, name);
26518
+ if (binding?.scoped)
26519
+ settle(this.discoverModels(backend, name, binding, { afterSignIn: true }));
26520
+ }
26521
+ }
25382
26522
  /** Maintain discovery after committed config changes; a model-field read remains passive. */
25383
26523
  probeChangedCliEnvs(previous) {
25384
26524
  const signature = (fleet, name) => {
@@ -25393,11 +26533,7 @@ export class FleetManager {
25393
26533
  continue;
25394
26534
  const backend = this.backendNameForInstance(name);
25395
26535
  const binding = this.webModelBinding(backend, name);
25396
- // A named agy account has no verified relocation/discovery contract. In particular,
25397
- // never publish the ambient account's models under that profile (#3526 / D7). (AGEND-119: agy now HAS
25398
- // named accounts, but `agy models` is not run with the account's folder, so its answer would still be the
25399
- // default account's: only a CLI whose profile is a variable the probe inherits is discovered under one.)
25400
- if (!binding || (binding.profile && (!credentialHomeSpec(backend) || credentialHomeSpec(backend).kind === "launch-argument")))
26536
+ if (!binding || !this.modelDiscoverable(backend, binding))
25401
26537
  continue;
25402
26538
  // A description/defaults save can retire a scoped answer's full binding even
25403
26539
  // though its account signature is unchanged. Keep the conservative fence and
@@ -25405,10 +26541,8 @@ export class FleetManager {
25405
26541
  if (previous && signature(previous, name) === signature(this.fleetConfig, name)
25406
26542
  && (!binding.scoped || this.webModelEnv(backend, name) || this.webModelRefreshes.has(binding.key)))
25407
26543
  continue;
25408
- const work = binding.scoped
25409
- ? this.refreshModelCatalogFor(backend, name)
25410
- : this.probeBackendBounded(backend, { profile: binding.profile });
25411
- void work.catch(err => this.logger.debug({ backend, name, err }, "Background model discovery failed"));
26544
+ const work = this.discoverModels(backend, name, binding);
26545
+ void work?.catch(err => this.logger.debug({ backend, name, err }, "Background model discovery failed"));
25412
26546
  }
25413
26547
  }
25414
26548
  /** Best-effort model list for `/model`: cached CLI env first, else live probe. Never throws. */
@@ -26282,12 +27416,40 @@ export class FleetManager {
26282
27416
  this.fleetConfig.instances[instanceName].effort = applied;
26283
27417
  this.saveFleetConfig();
26284
27418
  }
27419
+ // M-3180: a CLI with a verified in-session switch (CLI_RUNTIME_SWITCH) — typed when it can be, confirmed, else restarted.
27420
+ // The effort is already saved above, so a restart launches with it.
27421
+ if (this.cliSwitchRouted(instanceName, backendName) && this.instanceIpcClients.get(instanceName)) {
27422
+ const done = await this.runCliRuntimeSwitch(instanceName, backendName, { model: null, effort: applied });
27423
+ if (opts?.current && !opts.current())
27424
+ return t("menu.instance_replaced", this.shownInstanceName(instanceName));
27425
+ if (done.result.outcome === "switched")
27426
+ return `${warn}${t("effort.codex_switched", instanceName, applied)}`;
27427
+ const why = this.cliSwitchFallbackReason(backendName, done);
27428
+ this.logger.info({ instanceName, backend: backendName, effort: applied, result: done.result }, "CLI runtime effort switch fell back to a restart");
27429
+ await this.restartSingleInstance(instanceName, { ownerCurrent: opts?.current });
27430
+ return `${warn}${t("effort.codex_restarted", instanceName, applied, why)}`;
27431
+ }
26285
27432
  if (strategy === "runtime") {
26286
27433
  if (!this.instanceIpcClients.get(instanceName))
26287
27434
  return `${warn}${t("effort.not_running", instanceName)}`;
26288
27435
  this.pasteRawToClassicInstance(instanceName, `/effort ${applied}`);
26289
27436
  return `${warn}${t("effort.runtime_success", instanceName, applied)}`;
26290
27437
  }
27438
+ // M-3175: codex 0.164+ takes the effort in the running session (`/model [MODEL] --reasoning=L`, its configured model named
27439
+ // when known); restarted when the switch was not typed or not confirmed. The effort is already saved above.
27440
+ if (backendName === "codex" && this.instanceIpcClients.get(instanceName)) {
27441
+ const resolved = this.resolveInstanceModel(instanceName);
27442
+ const model = resolved.source === "instance" || resolved.source === "fleet-default" ? resolved.model : null;
27443
+ const result = await this.runCodexRuntimeSwitch(instanceName, model, applied);
27444
+ if (opts?.current && !opts.current())
27445
+ return t("menu.instance_replaced", this.shownInstanceName(instanceName));
27446
+ if (result.outcome === "switched")
27447
+ return `${warn}${t("effort.codex_switched", instanceName, applied)}`;
27448
+ const why = this.codexSwitchFallbackReason(result);
27449
+ this.logger.info({ instanceName, effort: applied, result }, "Codex runtime effort switch fell back to a restart");
27450
+ await this.restartSingleInstance(instanceName, { ownerCurrent: opts?.current });
27451
+ return `${warn}${t("effort.codex_restarted", instanceName, applied, why)}`;
27452
+ }
26291
27453
  await this.restartSingleInstance(instanceName, { ownerCurrent: opts?.current });
26292
27454
  return `${warn}${t("effort.restart_success", instanceName, applied)}`;
26293
27455
  }
@@ -26349,6 +27511,40 @@ export class FleetManager {
26349
27511
  : t("model.switch_unconfirmed", instanceName, model, Math.round(RUNTIME_SWITCH_RESULT_MS / 1000));
26350
27512
  return `${warn}${head}${this.effortSuffix(instanceName)}`;
26351
27513
  }
27514
+ // M-3175: codex 0.164+ switches in the running session; saved first (a fallback restart launches from it), restarted when
27515
+ // the switch was not typed or not confirmed.
27516
+ if (backendName === "codex" && this.instanceIpcClients.get(instanceName)) {
27517
+ if (!this.persistInstanceModel(instanceName, model))
27518
+ return `${warn}${t("model.persist_failed", instanceName)}`;
27519
+ const effort = this.codexSwitchEffort(instanceName, model);
27520
+ const result = await this.runCodexRuntimeSwitch(instanceName, model, effort);
27521
+ if (opts?.current && !opts.current())
27522
+ return t("menu.instance_replaced", this.shownInstanceName(instanceName));
27523
+ if (result.outcome === "switched")
27524
+ return `${warn}${t("model.codex_switched", instanceName, model)}${this.effortSuffix(instanceName)}`;
27525
+ const why = this.codexSwitchFallbackReason(result);
27526
+ this.logger.info({ instanceName, model, result }, "Codex runtime model switch fell back to a restart");
27527
+ await this.restartSingleInstance(instanceName, { ownerCurrent: opts?.current });
27528
+ return `${warn}${t("model.codex_restarted", instanceName, model, why)}${this.effortSuffix(instanceName)}`;
27529
+ }
27530
+ // M-3180: the same for a CLI with a verified in-session switch (CLI_RUNTIME_SWITCH): saved first, switched in place when
27531
+ // it can be and confirmed, else restarted (as these CLIs always were).
27532
+ if (this.cliSwitchRouted(instanceName, backendName) && this.instanceIpcClients.get(instanceName)) {
27533
+ if (!this.persistInstanceModel(instanceName, model))
27534
+ return `${warn}${t("model.persist_failed", instanceName)}`;
27535
+ const entry = CLI_RUNTIME_SWITCH[backendName];
27536
+ const effort = this.codexSwitchEffort(instanceName, model); // configured level, only when the target model supports it
27537
+ const want = entry.modelWant?.(model, effort) ?? { model, effort: null };
27538
+ const done = await this.runCliRuntimeSwitch(instanceName, backendName, want);
27539
+ if (opts?.current && !opts.current())
27540
+ return t("menu.instance_replaced", this.shownInstanceName(instanceName));
27541
+ if (done.result.outcome === "switched")
27542
+ return `${warn}${t("model.codex_switched", instanceName, model)}${this.effortSuffix(instanceName)}`;
27543
+ const why = this.cliSwitchFallbackReason(backendName, done);
27544
+ this.logger.info({ instanceName, backend: backendName, model, result: done.result }, "CLI runtime model switch fell back to a restart");
27545
+ await this.restartSingleInstance(instanceName, { ownerCurrent: opts?.current });
27546
+ return `${warn}${t("model.codex_restarted", instanceName, model, why)}${this.effortSuffix(instanceName)}`;
27547
+ }
26352
27548
  // Persist either way: a runtime switch must survive the next respawn too,
26353
27549
  // or the instance silently reverts to the CLI default after a fleet restart.
26354
27550
  if (!this.persistInstanceModel(instanceName, model))
@@ -26560,11 +27756,22 @@ export class FleetManager {
26560
27756
  return shapeWebModelCatalog(backend, env?.models ?? [], env?.apiModels ?? []);
26561
27757
  }
26562
27758
  /** Explicit, bounded vendor rediscovery. Never publish an answer under a different account/config/instance. */
26563
- async refreshModelCatalogFor(backend, instance, selection) {
27759
+ async refreshModelCatalogFor(backend, instance, selection, opts = {}) {
26564
27760
  const binding = this.webModelBinding(backend, instance, selection);
26565
27761
  if (!binding || this.shuttingDown)
26566
27762
  return { models: [], refreshed: false };
26567
27763
  const pending = this.webModelRefreshes.get(binding.key);
27764
+ if (pending && opts.afterSignIn) {
27765
+ // A sign-in changes the credentials, not the binding key, so a flight started before it is answering as the signed-out
27766
+ // account. Join it for admission (the worker limit), then read once more as the signed-in one; sign-ins that land on the
27767
+ // same flight meet in that one read (the second finds the first's flight).
27768
+ return pending.catch(() => null).then(() => {
27769
+ const next = this.webModelBinding(backend, instance, selection);
27770
+ if (next?.key !== binding.key)
27771
+ return { models: [], refreshed: false };
27772
+ return this.refreshModelCatalogFor(backend, instance, selection);
27773
+ });
27774
+ }
26568
27775
  if (pending)
26569
27776
  return pending;
26570
27777
  const epoch = this.cliEnvProbeEpoch;
@@ -26582,7 +27789,11 @@ export class FleetManager {
26582
27789
  return { models: this.modelCatalogFor(backend, instance, selection), refreshed: false };
26583
27790
  if (this.webModelCatalogs.size >= 64)
26584
27791
  this.webModelCatalogs.delete(this.webModelCatalogs.keys().next().value);
27792
+ const listed = (models) => models.map(m => m.id).join("\0");
27793
+ const before = listed(this.webModelEnv(backend, instance, selection)?.models ?? []);
26585
27794
  this.webModelCatalogs.set(binding.key, { ...result, backend, probedAt: Date.now() });
27795
+ if (listed(result.models) !== before)
27796
+ this.announceModels(backend);
26586
27797
  return { models: this.modelCatalogFor(backend, instance, selection), refreshed: true };
26587
27798
  }).finally(() => { if (this.webModelRefreshes.get(binding.key) === work)
26588
27799
  this.webModelRefreshes.delete(binding.key); });
@@ -27241,6 +28452,9 @@ export class FleetManager {
27241
28452
  async handleClassicStop(channelId, adapterId) {
27242
28453
  if (!this.classicChannels)
27243
28454
  return t("classic.manager_unavailable");
28455
+ const previous = this.classicChannels.getInstanceByChannel(channelId, adapterId);
28456
+ if (previous)
28457
+ this.forgetHubAgentIncarnation(previous, true);
27244
28458
  const ch = this.classicChannels.unregister(channelId, adapterId);
27245
28459
  if (!ch)
27246
28460
  return t("classic.no_agent");
@@ -27413,6 +28627,9 @@ export class FleetManager {
27413
28627
  const settingsControl = this.settingsControl;
27414
28628
  this.settingsControl = null;
27415
28629
  const settingsControlStopped = settingsControl?.close();
28630
+ const ownerAppControl = this.ownerAppControl;
28631
+ this.ownerAppControl = null;
28632
+ const ownerAppStopped = ownerAppControl?.close();
27416
28633
  this.publicLinkAutoOpen?.stop();
27417
28634
  const publicStopped = this.publicWebLink?.close("fleet shutdown");
27418
28635
  this.webRemoteAccessState?.close(); // #3008: an unsaved switch gets its last write
@@ -27427,7 +28644,7 @@ export class FleetManager {
27427
28644
  // ledger flush completes before process.exit(0) in doStopAll's caller.
27428
28645
  const cacheStopped = this.cacheService?.stop() ?? Promise.resolve();
27429
28646
  // #1565: the web chat's last changes reach the disk (bounded: a slow disk does not hold the shutdown).
27430
- const webChatStopped = this.webChatStore ? Promise.race([this.webChatStore.flush().catch(() => { }), new Promise(r => setTimeout(r, 3_000).unref?.())]) : Promise.resolve();
28647
+ const webChatStopped = this.webChatStore ? Promise.race([Promise.all([this.webChatStore.flush().catch(() => { }), this.webChatArchive?.flush().catch(() => { })]), new Promise(r => setTimeout(r, 3_000).unref?.())]) : Promise.resolve();
27431
28648
  const profileStopped = this.runtimeCpuProfiler?.shutdown("fleet shutdown");
27432
28649
  // S-51: the Hub closes in the same drain, bounded so an unanswering listener does not hold the shutdown.
27433
28650
  const hubInit = this.hubRuntimeInit, hubNow = this.hubRuntime;
@@ -27479,6 +28696,7 @@ export class FleetManager {
27479
28696
  await hubStopped;
27480
28697
  await needsStopped;
27481
28698
  await settingsControlStopped;
28699
+ await ownerAppStopped;
27482
28700
  await cacheStopped;
27483
28701
  await quotaNoticesStopped;
27484
28702
  this.quotaNotices = null;
@@ -27845,6 +29063,8 @@ export class FleetManager {
27845
29063
  this.probeChangedCliEnvs(oldConfig);
27846
29064
  this.migrateOfficeStorage();
27847
29065
  this.migrateNoticeDeliveryStorage();
29066
+ this.namedLinkDefaultChecked = false;
29067
+ this.migrateNamedLinkDefault(); // M-3277 F1: a reloaded file is checked again
27848
29068
  // Classic behavior settings share the fleet defaults but are not entries
27849
29069
  // in fleet.yaml. Snapshot the old effective chain before reloading the
27850
29070
  // Classic file so SIGHUP can hot-apply either source without waiting for
@@ -27866,8 +29086,10 @@ export class FleetManager {
27866
29086
  ?? this.classicChannels.getReplyCompletionGuard(ch.channelId, ch.adapterId, oldConfig?.defaults?.reply_completion_guard),
27867
29087
  });
27868
29088
  }
27869
- if (this.classicChannels.checkReload())
29089
+ if (this.classicChannels.checkReload()) {
29090
+ this.observeHubAgentIncarnations();
27870
29091
  this.reportClassicUnrecoverableIds();
29092
+ }
27871
29093
  }
27872
29094
  this.routing.rebuild(this.fleetConfig);
27873
29095
  this.reregisterClassicChannels();
@@ -27923,10 +29145,21 @@ export class FleetManager {
27923
29145
  if (!this.daemons.has(name)) {
27924
29146
  // New instance — startInstance already calls connectIpcToInstance. #2482: a paused one is not started (startInstance
27925
29147
  // returns at its pause); say so, quietly, instead of "starting" on every reload.
27926
- if (this.lifecycle.isPaused(name))
29148
+ if (this.lifecycle.isPaused(name)) {
27927
29149
  this.logger.debug({ name }, "Paused instance in config — not started");
27928
- else
27929
- this.logger.info({ name }, "New instance in config — starting");
29150
+ continue;
29151
+ }
29152
+ const previous = oldConfig?.instances[name];
29153
+ const change = previous ? classifyInstanceChange(previous, config) : "restart";
29154
+ // A Settings apply (observe set) of an unrelated fleet field must not start or list every
29155
+ // stopped agent whose instance block did not change (M-3165). SIGHUP still recovers missing ones.
29156
+ if (observe && change === "none")
29157
+ continue;
29158
+ this.logger.info({ name }, !previous
29159
+ ? "New instance in config — starting"
29160
+ : change === "none"
29161
+ ? "Instance not running — starting"
29162
+ : "Instance config changed — starting");
27930
29163
  observe?.(name, "restart", "running");
27931
29164
  await this.startInstanceUnattended(name, config, topicMode, "new instance");
27932
29165
  observe?.(name, "restart", "done");
@@ -29420,13 +30653,15 @@ export class FleetManager {
29420
30653
  const classicNames = new Set(this.classicChannels?.getAll().map(ch => ch.instanceName) ?? []);
29421
30654
  for (const [name, config] of Object.entries(next)) {
29422
30655
  const daemon = this.daemons.get(name);
29423
- if (!daemon) {
29424
- rows.push({ target: name, kind: "restart" });
30656
+ // Compare the live snapshot when we have one; otherwise the in-memory instance
30657
+ // (last load). "No daemon" is not itself a change — parked / other-team agents
30658
+ // whose YAML block is untouched must not appear as "restart this agent" (M-3165).
30659
+ const runtime = daemon?.getConfigSnapshot?.() ?? this.fleetConfig?.instances[name];
30660
+ if (!runtime) {
30661
+ if (!this.lifecycle.isPaused(name))
30662
+ rows.push({ target: name, kind: "restart" });
29425
30663
  continue;
29426
30664
  }
29427
- const runtime = daemon.getConfigSnapshot?.();
29428
- if (!runtime)
29429
- continue;
29430
30665
  const change = classifyInstanceChange(runtime, config);
29431
30666
  if (change !== "none")
29432
30667
  rows.push({ target: name, kind: change === "restart" ? "restart" : "hot" });
@@ -29802,6 +31037,7 @@ export class FleetManager {
29802
31037
  catch {
29803
31038
  this.recordUpdateCheck(currentVersion, null); /* silent — network issues */
29804
31039
  }
31040
+ await this.maybeNotifyHubRecommendation(); // M-3140: the 7-day reminder rides the daily check
29805
31041
  }
29806
31042
  // ── M-2738: updating from the web (src/web-update.ts) ───────────────
29807
31043
  /** The web's update routes (web-api.ts handleWebUpdate) read and start through this. */
@@ -29814,11 +31050,12 @@ export class FleetManager {
29814
31050
  }
29815
31051
  catch { /* unknown: the page compares nothing */ }
29816
31052
  const s = this.updateCheckState;
29817
- return { current, offer: s?.offer ?? null, checkedAt: s?.checkedAt ?? null, checkFailed: s?.failed ?? false };
31053
+ return { current, offer: s?.offer ?? null, hubRecommendation: this.hubRecommendedUpdate(), checkedAt: s?.checkedAt ?? null, checkFailed: s?.failed ?? false };
29818
31054
  },
29819
31055
  checkUpdateNow: () => this.checkUpdateNow(),
29820
31056
  updateProgress: () => webProgressOf(readUpdateProgress(this.dataDir)),
29821
- startWebUpdate: (key, person, stillAllowed) => this.startWebUpdateOnce(key, person, stillAllowed),
31057
+ startWebUpdate: (key, person, stillAllowed, pin) => this.startWebUpdateOnce(key, person, stillAllowed, pin),
31058
+ startHubRequestedUpdate: (key, person, stillAllowed, id) => this.startHubRequestedUpdateOnce(key, person, stillAllowed, id),
29822
31059
  updateLog: () => ({ text: readLogTail(updateLogPath(this.dataDir)), error: readUpdateProgress(this.dataDir)?.progress.error ?? null }),
29823
31060
  };
29824
31061
  }
@@ -29860,14 +31097,32 @@ export class FleetManager {
29860
31097
  * last check offers as installable; the update itself is chat `/update`'s (launchInstalledUpdate). Its progress marker
29861
31098
  * targets no chat message (WEB_UPDATE_ADAPTER); the page reads the stages the updater writes into it.
29862
31099
  */
29863
- async startWebUpdate(person, stillAllowed) {
31100
+ async startWebUpdate(person, stillAllowed, pin, hubRequestId) {
29864
31101
  if (this.shuttingDown)
29865
31102
  return { ok: false, status: 409, error: "stopping" };
29866
31103
  // Synchronous from here to the claim: a second start cannot slip in between on the event loop.
29867
31104
  if (this.webUpdateOwned || isUpdateInProgress(this.dataDir))
29868
31105
  return { ok: false, status: 409, error: "update_running" };
29869
- const offer = this.updateCheckState?.offer;
29870
- if (!offer?.installable)
31106
+ // M-3140: Update pinned to the Hub's recommendation. The page only names which advice it was shown; the version is
31107
+ // this Fleet's own verified view, re-read now (and again at the launch) — a page's word never chooses what installs.
31108
+ let pinned;
31109
+ const requestOwner = this.hubUpdates;
31110
+ if (hubRequestId) {
31111
+ const version = requestOwner?.manualCandidate(hubRequestId);
31112
+ if (!version || !this.semverGt(version, this.runningAgendVersion()))
31113
+ return { ok: false, status: 409, error: "request_changed" };
31114
+ pinned = version;
31115
+ }
31116
+ if (pin) {
31117
+ const advice = this.hubRecommendationFor(pin);
31118
+ if (!advice)
31119
+ return { ok: false, status: 409, error: "recommendation_changed" };
31120
+ pinned = advice.version;
31121
+ }
31122
+ const offer = pinned ? { version: pinned } : this.updateCheckState?.offer;
31123
+ if (!pinned && !this.updateCheckState?.offer?.installable)
31124
+ return { ok: false, status: 409, error: "nothing_to_install" };
31125
+ if (!offer)
29871
31126
  return { ok: false, status: 409, error: "nothing_to_install" };
29872
31127
  const startedAt = Date.now();
29873
31128
  const claim = { startedAt };
@@ -29883,7 +31138,8 @@ export class FleetManager {
29883
31138
  }
29884
31139
  const origin = `web update by ${person}`;
29885
31140
  // Prism #3505 P2-3: the asking session must still be current and an admin's when the updater is launched.
29886
- void this.launchInstalledUpdate(origin, () => !this.shuttingDown && stillAllowed()).then(child => {
31141
+ void this.launchInstalledUpdate(origin, () => !this.shuttingDown && stillAllowed() && (!pin || this.hubRecommendationFor(pin) !== null)
31142
+ && (!hubRequestId || this.hubUpdates === requestOwner && requestOwner?.manualCandidate(hubRequestId) === pinned), pinned).then(child => {
29887
31143
  if (!child) {
29888
31144
  release();
29889
31145
  return;
@@ -29898,17 +31154,44 @@ export class FleetManager {
29898
31154
  return { ok: true };
29899
31155
  }
29900
31156
  /** M-2738: a web start's answer for its key, the same on a retry (at most 32 kept). */
29901
- startWebUpdateOnce(key, person, stillAllowed) {
31157
+ startWebUpdateOnce(key, person, stillAllowed, pin) {
29902
31158
  // Prism #3505 P3: reserved before anything is awaited — a concurrent request with the same key shares this answer.
29903
31159
  const known = this.webUpdateStarts.get(key);
29904
31160
  if (known)
29905
31161
  return known;
29906
- const answer = this.startWebUpdate(person, stillAllowed);
31162
+ const answer = this.startWebUpdate(person, stillAllowed, pin);
29907
31163
  this.webUpdateStarts.set(key, answer);
29908
31164
  while (this.webUpdateStarts.size > 32)
29909
31165
  this.webUpdateStarts.delete(this.webUpdateStarts.keys().next().value);
29910
31166
  return answer;
29911
31167
  }
31168
+ startHubRequestedUpdateOnce(key, person, stillAllowed, id) {
31169
+ const cacheKey = JSON.stringify(["hub-request", person, id, key]);
31170
+ const known = this.webUpdateStarts.get(cacheKey);
31171
+ if (known)
31172
+ return known;
31173
+ const answer = (async () => {
31174
+ const owner = this.hubUpdates, request = owner?.view(id);
31175
+ if (!owner || !request || !owner.manualCandidate(id))
31176
+ return { ok: false, status: 404, error: "request_not_found" };
31177
+ const current = () => !this.shuttingDown && this.hubUpdates === owner && stillAllowed();
31178
+ if (!current())
31179
+ return { ok: false, status: 403, error: "not_authorized" };
31180
+ if (request.state === "waiting") {
31181
+ if (this.webUpdateOwned || isUpdateInProgress(this.dataDir))
31182
+ return { ok: false, status: 409, error: "update_running" };
31183
+ return await owner.updateNow(id, current) ? { ok: true } : { ok: false, status: 409, error: "update_not_started" };
31184
+ }
31185
+ // An expired request's button is a new, explicitly confirmed local update. Its old Hub result stays expired.
31186
+ if (request.state === "expired")
31187
+ return this.startWebUpdate(person, current, undefined, id);
31188
+ return { ok: false, status: 409, error: request.state === "updating" ? "update_running" : "request_changed" };
31189
+ })();
31190
+ this.webUpdateStarts.set(cacheKey, answer);
31191
+ while (this.webUpdateStarts.size > 32)
31192
+ this.webUpdateStarts.delete(this.webUpdateStarts.keys().next().value);
31193
+ return answer;
31194
+ }
29912
31195
  /**
29913
31196
  * Semver "a > b". Compares major.minor.patch numerically; a version without a
29914
31197
  * prerelease outranks the same core with one (2.0.8 > 2.0.8-beta.16); two
@@ -30275,6 +31558,7 @@ export class FleetManager {
30275
31558
  // §3.2: a stream that connects reads its rooms again (in the background; at most once a minute).
30276
31559
  streamOpened: () => { void this.refreshGuestRooms(owner, { mode: "force" }); },
30277
31560
  history: () => this.webChatHistory,
31561
+ mentionNames: (instance, query) => this.guestMentionNames(owner, instance, query),
30278
31562
  // #1920 §5.1: guests chat unless the host made them read-only (web.guests.chat: false).
30279
31563
  chat: () => this.fleetConfig?.web?.guests?.chat !== false,
30280
31564
  // #2855: the admin's level for this guest, read at each request (a change applies at once).