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

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 (860) 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 +39 -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 +20 -5
  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.d.ts +6 -4
  41. package/dist/backend/codex.js +26 -9
  42. package/dist/backend/codex.js.map +1 -1
  43. package/dist/backend/credential-profile.js +1 -1
  44. package/dist/backend/credential-profile.js.map +1 -1
  45. package/dist/backend/grok-model-switch.d.ts +16 -0
  46. package/dist/backend/grok-model-switch.js +45 -0
  47. package/dist/backend/grok-model-switch.js.map +1 -0
  48. package/dist/backend/grok.js +1 -1
  49. package/dist/backend/grok.js.map +1 -1
  50. package/dist/backend/kiro.js +4 -4
  51. package/dist/backend/kiro.js.map +1 -1
  52. package/dist/backend/muse.d.ts +2 -0
  53. package/dist/backend/muse.js +7 -3
  54. package/dist/backend/muse.js.map +1 -1
  55. package/dist/backend/native-pane.js +1 -1
  56. package/dist/backend/native-pane.js.map +1 -1
  57. package/dist/backend/types.d.ts +2 -0
  58. package/dist/backend/types.js.map +1 -1
  59. package/dist/backend-availability.d.ts +22 -0
  60. package/dist/backend-availability.js +71 -2
  61. package/dist/backend-availability.js.map +1 -1
  62. package/dist/backend-signin-guide.js +1 -1
  63. package/dist/backend-signin-guide.js.map +1 -1
  64. package/dist/build-provenance.json +1 -1
  65. package/dist/channel/adapters/discord.d.ts +10 -0
  66. package/dist/channel/adapters/discord.js +35 -0
  67. package/dist/channel/adapters/discord.js.map +1 -1
  68. package/dist/channel/adapters/telegram.d.ts +2 -0
  69. package/dist/channel/adapters/telegram.js +3 -0
  70. package/dist/channel/adapters/telegram.js.map +1 -1
  71. package/dist/channel/mcp-server.js +10 -1
  72. package/dist/channel/mcp-server.js.map +1 -1
  73. package/dist/channel/mcp-tools.js +9 -1
  74. package/dist/channel/mcp-tools.js.map +1 -1
  75. package/dist/channel/tool-router.js +9 -2
  76. package/dist/channel/tool-router.js.map +1 -1
  77. package/dist/channel/types.d.ts +10 -0
  78. package/dist/classic-channel-manager.d.ts +1 -1
  79. package/dist/classic-channel-manager.js +1 -1
  80. package/dist/cli-audited.js +14 -13
  81. package/dist/cli-audited.js.map +1 -1
  82. package/dist/cli-capability.d.ts +3 -0
  83. package/dist/cli-capability.js.map +1 -1
  84. package/dist/cli-registry-check.js +1 -1
  85. package/dist/cli-registry-check.js.map +1 -1
  86. package/dist/cli-registry.d.ts +1 -0
  87. package/dist/cli-spec-antigravity.d.ts +1 -0
  88. package/dist/cli-spec-antigravity.js +3 -1
  89. package/dist/cli-spec-antigravity.js.map +1 -1
  90. package/dist/cli.js +8 -0
  91. package/dist/cli.js.map +1 -1
  92. package/dist/config-validator.js +18 -1
  93. package/dist/config-validator.js.map +1 -1
  94. package/dist/connect/control.d.ts +20 -0
  95. package/dist/connect/control.js +236 -0
  96. package/dist/connect/control.js.map +1 -0
  97. package/dist/connect/install.d.ts +13 -0
  98. package/dist/connect/install.js +12 -0
  99. package/dist/connect/install.js.map +1 -0
  100. package/dist/connect/mcp.d.ts +9 -0
  101. package/dist/connect/mcp.js +10 -0
  102. package/dist/connect/mcp.js.map +1 -0
  103. package/dist/connect/protocol.d.ts +38 -0
  104. package/dist/connect/protocol.js +36 -0
  105. package/dist/connect/protocol.js.map +1 -0
  106. package/dist/connect/service.d.ts +19 -0
  107. package/dist/connect/service.js +79 -0
  108. package/dist/connect/service.js.map +1 -0
  109. package/dist/connect/stdio-entry.d.ts +1 -0
  110. package/dist/connect/stdio-entry.js +6 -0
  111. package/dist/connect/stdio-entry.js.map +1 -0
  112. package/dist/connect/stdio.d.ts +5 -0
  113. package/dist/connect/stdio.js +33 -0
  114. package/dist/connect/stdio.js.map +1 -0
  115. package/dist/daemon.d.ts +64 -2
  116. package/dist/daemon.js +397 -31
  117. package/dist/daemon.js.map +1 -1
  118. package/dist/delivery-consumed-watch.d.ts +2 -0
  119. package/dist/delivery-consumed-watch.js +4 -1
  120. package/dist/delivery-consumed-watch.js.map +1 -1
  121. package/dist/dispatcher-liveness.d.ts +51 -1
  122. package/dist/dispatcher-liveness.js +92 -2
  123. package/dist/dispatcher-liveness.js.map +1 -1
  124. package/dist/event-log.d.ts +1 -1
  125. package/dist/event-log.js +1 -1
  126. package/dist/fleet-manager.d.ts +222 -6
  127. package/dist/fleet-manager.js +1271 -100
  128. package/dist/fleet-manager.js.map +1 -1
  129. package/dist/fleet-windows-runtime.js +4 -2
  130. package/dist/fleet-windows-runtime.js.map +1 -1
  131. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +11 -1
  132. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +10 -0
  133. package/dist/general-knowledge/skills/fleet-health/SKILL.md +18 -0
  134. package/dist/general-knowledge/skills/hub/SKILL.md +290 -24
  135. package/dist/general-knowledge/skills/model-discovery/SKILL.md +4 -0
  136. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +118 -26
  137. package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +2 -0
  138. package/dist/hub/admin-dashboard.d.ts +85 -0
  139. package/dist/hub/admin-dashboard.js +177 -0
  140. package/dist/hub/admin-dashboard.js.map +1 -0
  141. package/dist/hub/attachments/store.d.ts +2 -0
  142. package/dist/hub/attachments/store.js +6 -0
  143. package/dist/hub/attachments/store.js.map +1 -1
  144. package/dist/hub/audit/index.d.ts +2 -0
  145. package/dist/hub/audit/index.js +8 -0
  146. package/dist/hub/audit/index.js.map +1 -1
  147. package/dist/hub/buttons.js +3 -1
  148. package/dist/hub/buttons.js.map +1 -1
  149. package/dist/hub/catalog.d.ts +7 -4
  150. package/dist/hub/catalog.js +19 -10
  151. package/dist/hub/catalog.js.map +1 -1
  152. package/dist/hub/client.d.ts +13 -0
  153. package/dist/hub/client.js +85 -11
  154. package/dist/hub/client.js.map +1 -1
  155. package/dist/hub/compose/member.d.ts +22 -0
  156. package/dist/hub/compose/member.js +233 -18
  157. package/dist/hub/compose/member.js.map +1 -1
  158. package/dist/hub/compose/server.d.ts +13 -0
  159. package/dist/hub/compose/server.js +107 -14
  160. package/dist/hub/compose/server.js.map +1 -1
  161. package/dist/hub/display-name.d.ts +10 -0
  162. package/dist/hub/display-name.js +35 -0
  163. package/dist/hub/display-name.js.map +1 -0
  164. package/dist/hub/execution/service.d.ts +1 -0
  165. package/dist/hub/execution/service.js +1 -1
  166. package/dist/hub/execution/service.js.map +1 -1
  167. package/dist/hub/fleet-info.d.ts +12 -0
  168. package/dist/hub/fleet-info.js +14 -0
  169. package/dist/hub/fleet-info.js.map +1 -0
  170. package/dist/hub/fleet-update-model.d.ts +100 -0
  171. package/dist/hub/fleet-update-model.js +15 -0
  172. package/dist/hub/fleet-update-model.js.map +1 -0
  173. package/dist/hub/fleet-updates.d.ts +46 -0
  174. package/dist/hub/fleet-updates.js +282 -0
  175. package/dist/hub/fleet-updates.js.map +1 -0
  176. package/dist/hub/fleet-versions.d.ts +28 -0
  177. package/dist/hub/fleet-versions.js +80 -0
  178. package/dist/hub/fleet-versions.js.map +1 -0
  179. package/dist/hub/group-policy/admin-api.d.ts +1 -0
  180. package/dist/hub/group-policy/admin-api.js +10 -1
  181. package/dist/hub/group-policy/admin-api.js.map +1 -1
  182. package/dist/hub/group-policy/admin-control.d.ts +1 -0
  183. package/dist/hub/group-policy/admin-control.js +13 -4
  184. package/dist/hub/group-policy/admin-control.js.map +1 -1
  185. package/dist/hub/group-policy/admin-dto.d.ts +39 -1
  186. package/dist/hub/group-policy/admin-dto.js.map +1 -1
  187. package/dist/hub/group-policy/admin-facts.d.ts +4 -2
  188. package/dist/hub/group-policy/admin-facts.js +17 -2
  189. package/dist/hub/group-policy/admin-facts.js.map +1 -1
  190. package/dist/hub/group-policy/admin-impact.d.ts +36 -6
  191. package/dist/hub/group-policy/admin-impact.js +21 -7
  192. package/dist/hub/group-policy/admin-impact.js.map +1 -1
  193. package/dist/hub/group-policy/admin-inventory.d.ts +2 -0
  194. package/dist/hub/group-policy/admin-inventory.js +13 -4
  195. package/dist/hub/group-policy/admin-inventory.js.map +1 -1
  196. package/dist/hub/group-policy/admin-search.d.ts +2 -1
  197. package/dist/hub/group-policy/admin-search.js +56 -7
  198. package/dist/hub/group-policy/admin-search.js.map +1 -1
  199. package/dist/hub/group-policy/authorization.d.ts +2 -0
  200. package/dist/hub/group-policy/authorization.js +7 -2
  201. package/dist/hub/group-policy/authorization.js.map +1 -1
  202. package/dist/hub/group-policy/impact-inventory.d.ts +4 -1
  203. package/dist/hub/group-policy/impact-inventory.js +23 -2
  204. package/dist/hub/group-policy/impact-inventory.js.map +1 -1
  205. package/dist/hub/group-policy/model.d.ts +52 -1
  206. package/dist/hub/group-policy/model.js +20 -7
  207. package/dist/hub/group-policy/model.js.map +1 -1
  208. package/dist/hub/group-policy/resources.d.ts +2 -0
  209. package/dist/hub/group-policy/resources.js +12 -1
  210. package/dist/hub/group-policy/resources.js.map +1 -1
  211. package/dist/hub/group-policy/store.js +22 -3
  212. package/dist/hub/group-policy/store.js.map +1 -1
  213. package/dist/hub/group-policy/team-subjects.d.ts +16 -0
  214. package/dist/hub/group-policy/team-subjects.js +32 -0
  215. package/dist/hub/group-policy/team-subjects.js.map +1 -0
  216. package/dist/hub/http/compose.d.ts +2 -0
  217. package/dist/hub/http/compose.js +385 -32
  218. package/dist/hub/http/compose.js.map +1 -1
  219. package/dist/hub/http/core.js +27 -0
  220. package/dist/hub/http/core.js.map +1 -1
  221. package/dist/hub/http/deps.d.ts +13 -0
  222. package/dist/hub/http/schema.js +21 -1
  223. package/dist/hub/http/schema.js.map +1 -1
  224. package/dist/hub/join/client.js +75 -42
  225. package/dist/hub/join/client.js.map +1 -1
  226. package/dist/hub/join/service.d.ts +1 -1
  227. package/dist/hub/join/service.js.map +1 -1
  228. package/dist/hub/mcp/auth-schema.d.ts +7 -0
  229. package/dist/hub/mcp/auth-schema.js +31 -0
  230. package/dist/hub/mcp/auth-schema.js.map +1 -0
  231. package/dist/hub/mcp/auth.d.ts +89 -0
  232. package/dist/hub/mcp/auth.js +374 -0
  233. package/dist/hub/mcp/auth.js.map +1 -0
  234. package/dist/hub/mcp/catalog.d.ts +44 -0
  235. package/dist/hub/mcp/catalog.js +31 -0
  236. package/dist/hub/mcp/catalog.js.map +1 -0
  237. package/dist/hub/mcp/door-schema.d.ts +7 -0
  238. package/dist/hub/mcp/door-schema.js +20 -0
  239. package/dist/hub/mcp/door-schema.js.map +1 -0
  240. package/dist/hub/mcp/http.d.ts +25 -0
  241. package/dist/hub/mcp/http.js +259 -0
  242. package/dist/hub/mcp/http.js.map +1 -0
  243. package/dist/hub/mcp/policy.d.ts +65 -0
  244. package/dist/hub/mcp/policy.js +153 -0
  245. package/dist/hub/mcp/policy.js.map +1 -0
  246. package/dist/hub/mcp/server.d.ts +3 -0
  247. package/dist/hub/mcp/server.js +32 -0
  248. package/dist/hub/mcp/server.js.map +1 -0
  249. package/dist/hub/mcp/tools.d.ts +31 -0
  250. package/dist/hub/mcp/tools.js +176 -0
  251. package/dist/hub/mcp/tools.js.map +1 -0
  252. package/dist/hub/member/display-name.d.ts +9 -0
  253. package/dist/hub/member/display-name.js +71 -0
  254. package/dist/hub/member/display-name.js.map +1 -0
  255. package/dist/hub/member/exposure-api.d.ts +6 -0
  256. package/dist/hub/member/exposure-api.js +13 -6
  257. package/dist/hub/member/exposure-api.js.map +1 -1
  258. package/dist/hub/member/exposures.d.ts +4 -0
  259. package/dist/hub/member/exposures.js +20 -0
  260. package/dist/hub/member/exposures.js.map +1 -1
  261. package/dist/hub/member/pairing-api.js +3 -2
  262. package/dist/hub/member/pairing-api.js.map +1 -1
  263. package/dist/hub/member/recommendations.d.ts +37 -0
  264. package/dist/hub/member/recommendations.js +129 -0
  265. package/dist/hub/member/recommendations.js.map +1 -0
  266. package/dist/hub/member/room-ask.d.ts +65 -5
  267. package/dist/hub/member/room-ask.js +269 -24
  268. package/dist/hub/member/room-ask.js.map +1 -1
  269. package/dist/hub/member/room-mention-feedback.d.ts +44 -0
  270. package/dist/hub/member/room-mention-feedback.js +121 -0
  271. package/dist/hub/member/room-mention-feedback.js.map +1 -0
  272. package/dist/hub/member/room-notification.d.ts +9 -0
  273. package/dist/hub/member/room-notification.js +2 -0
  274. package/dist/hub/member/room-notification.js.map +1 -0
  275. package/dist/hub/member/room-post-answers.d.ts +46 -0
  276. package/dist/hub/member/room-post-answers.js +152 -0
  277. package/dist/hub/member/room-post-answers.js.map +1 -0
  278. package/dist/hub/member/room-post-receipt.d.ts +21 -0
  279. package/dist/hub/member/room-post-receipt.js +49 -0
  280. package/dist/hub/member/room-post-receipt.js.map +1 -0
  281. package/dist/hub/member/room-post.d.ts +103 -0
  282. package/dist/hub/member/room-post.js +231 -0
  283. package/dist/hub/member/room-post.js.map +1 -0
  284. package/dist/hub/member/updates.d.ts +92 -0
  285. package/dist/hub/member/updates.js +316 -0
  286. package/dist/hub/member/updates.js.map +1 -0
  287. package/dist/hub/pairing.d.ts +15 -1
  288. package/dist/hub/pairing.js +33 -2
  289. package/dist/hub/pairing.js.map +1 -1
  290. package/dist/hub/person-prefs.d.ts +22 -0
  291. package/dist/hub/person-prefs.js +34 -0
  292. package/dist/hub/person-prefs.js.map +1 -0
  293. package/dist/hub/personal/owner-host.d.ts +140 -0
  294. package/dist/hub/personal/owner-host.js +287 -0
  295. package/dist/hub/personal/owner-host.js.map +1 -0
  296. package/dist/hub/personal/refusals.d.ts +11 -0
  297. package/dist/hub/personal/refusals.js +33 -0
  298. package/dist/hub/personal/refusals.js.map +1 -0
  299. package/dist/hub/personal/runtime-host.d.ts +26 -0
  300. package/dist/hub/personal/runtime-host.js +51 -0
  301. package/dist/hub/personal/runtime-host.js.map +1 -0
  302. package/dist/hub/personal/schema.d.ts +4 -0
  303. package/dist/hub/personal/schema.js +54 -0
  304. package/dist/hub/personal/schema.js.map +1 -0
  305. package/dist/hub/personal/turns.d.ts +39 -0
  306. package/dist/hub/personal/turns.js +221 -0
  307. package/dist/hub/personal/turns.js.map +1 -0
  308. package/dist/hub/personal/types.d.ts +42 -0
  309. package/dist/hub/personal/types.js +2 -0
  310. package/dist/hub/personal/types.js.map +1 -0
  311. package/dist/hub/policy.d.ts +1 -1
  312. package/dist/hub/policy.js +2 -0
  313. package/dist/hub/policy.js.map +1 -1
  314. package/dist/hub/protocol.d.ts +701 -1
  315. package/dist/hub/protocol.js +103 -14
  316. package/dist/hub/protocol.js.map +1 -1
  317. package/dist/hub/published-version.d.ts +3 -0
  318. package/dist/hub/published-version.js +35 -0
  319. package/dist/hub/published-version.js.map +1 -0
  320. package/dist/hub/quota.js +3 -1
  321. package/dist/hub/quota.js.map +1 -1
  322. package/dist/hub/recommendation-model.d.ts +36 -0
  323. package/dist/hub/recommendation-model.js +9 -0
  324. package/dist/hub/recommendation-model.js.map +1 -0
  325. package/dist/hub/recommendations.d.ts +58 -0
  326. package/dist/hub/recommendations.js +211 -0
  327. package/dist/hub/recommendations.js.map +1 -0
  328. package/dist/hub/representative.d.ts +5 -0
  329. package/dist/hub/representative.js +6 -1
  330. package/dist/hub/representative.js.map +1 -1
  331. package/dist/hub/roles/admin-control.d.ts +29 -0
  332. package/dist/hub/roles/admin-control.js +187 -0
  333. package/dist/hub/roles/admin-control.js.map +1 -0
  334. package/dist/hub/roles/admin-types.d.ts +72 -0
  335. package/dist/hub/roles/admin-types.js +2 -0
  336. package/dist/hub/roles/admin-types.js.map +1 -0
  337. package/dist/hub/roles/allowed-list-control.d.ts +34 -0
  338. package/dist/hub/roles/allowed-list-control.js +179 -0
  339. package/dist/hub/roles/allowed-list-control.js.map +1 -0
  340. package/dist/hub/roles/allowed-list.d.ts +8 -0
  341. package/dist/hub/roles/allowed-list.js +49 -0
  342. package/dist/hub/roles/allowed-list.js.map +1 -0
  343. package/dist/hub/roles/audit-details.d.ts +144 -0
  344. package/dist/hub/roles/audit-details.js +26 -0
  345. package/dist/hub/roles/audit-details.js.map +1 -0
  346. package/dist/hub/roles/authority.d.ts +12 -0
  347. package/dist/hub/roles/authority.js +39 -3
  348. package/dist/hub/roles/authority.js.map +1 -1
  349. package/dist/hub/roles/change.d.ts +3 -1
  350. package/dist/hub/roles/change.js +7 -2
  351. package/dist/hub/roles/change.js.map +1 -1
  352. package/dist/hub/roles/clock.d.ts +3 -0
  353. package/dist/hub/roles/clock.js +1 -1
  354. package/dist/hub/roles/clock.js.map +1 -1
  355. package/dist/hub/roles/convert.js +1 -1
  356. package/dist/hub/roles/convert.js.map +1 -1
  357. package/dist/hub/roles/cutover-inventory.d.ts +2 -0
  358. package/dist/hub/roles/cutover-inventory.js +8 -1
  359. package/dist/hub/roles/cutover-inventory.js.map +1 -1
  360. package/dist/hub/roles/cutover.d.ts +2 -2
  361. package/dist/hub/roles/cutover.js +3 -4
  362. package/dist/hub/roles/cutover.js.map +1 -1
  363. package/dist/hub/roles/delegation.d.ts +4 -1
  364. package/dist/hub/roles/delegation.js +7 -2
  365. package/dist/hub/roles/delegation.js.map +1 -1
  366. package/dist/hub/roles/evaluate.d.ts +2 -1
  367. package/dist/hub/roles/evaluate.js +14 -0
  368. package/dist/hub/roles/evaluate.js.map +1 -1
  369. package/dist/hub/roles/expiry-effects.d.ts +8 -0
  370. package/dist/hub/roles/expiry-effects.js +50 -0
  371. package/dist/hub/roles/expiry-effects.js.map +1 -0
  372. package/dist/hub/roles/migrations.d.ts +7 -0
  373. package/dist/hub/roles/migrations.js +44 -0
  374. package/dist/hub/roles/migrations.js.map +1 -0
  375. package/dist/hub/roles/model.d.ts +25 -0
  376. package/dist/hub/roles/model.js +9 -3
  377. package/dist/hub/roles/model.js.map +1 -1
  378. package/dist/hub/roles/overview.d.ts +8 -0
  379. package/dist/hub/roles/overview.js +15 -0
  380. package/dist/hub/roles/overview.js.map +1 -0
  381. package/dist/hub/roles/resource-effects.d.ts +17 -0
  382. package/dist/hub/roles/resource-effects.js +62 -0
  383. package/dist/hub/roles/resource-effects.js.map +1 -0
  384. package/dist/hub/roles/review.d.ts +16 -0
  385. package/dist/hub/roles/review.js +42 -0
  386. package/dist/hub/roles/review.js.map +1 -0
  387. package/dist/hub/roles/writer.d.ts +14 -3
  388. package/dist/hub/roles/writer.js +64 -16
  389. package/dist/hub/roles/writer.js.map +1 -1
  390. package/dist/hub/room-context-model.d.ts +43 -0
  391. package/dist/hub/room-context-model.js +12 -0
  392. package/dist/hub/room-context-model.js.map +1 -0
  393. package/dist/hub/room-mention-feedback-model.d.ts +12 -0
  394. package/dist/hub/room-mention-feedback-model.js +12 -0
  395. package/dist/hub/room-mention-feedback-model.js.map +1 -0
  396. package/dist/hub/rooms/agents.d.ts +44 -10
  397. package/dist/hub/rooms/agents.js +277 -30
  398. package/dist/hub/rooms/agents.js.map +1 -1
  399. package/dist/hub/rooms/assistant.d.ts +1 -6
  400. package/dist/hub/rooms/assistant.js +7 -2
  401. package/dist/hub/rooms/assistant.js.map +1 -1
  402. package/dist/hub/rooms/automation.d.ts +24 -0
  403. package/dist/hub/rooms/automation.js +66 -0
  404. package/dist/hub/rooms/automation.js.map +1 -0
  405. package/dist/hub/rooms/buttons.d.ts +85 -0
  406. package/dist/hub/rooms/buttons.js +62 -0
  407. package/dist/hub/rooms/buttons.js.map +1 -0
  408. package/dist/hub/rooms/context-cursor.d.ts +18 -0
  409. package/dist/hub/rooms/context-cursor.js +61 -0
  410. package/dist/hub/rooms/context-cursor.js.map +1 -0
  411. package/dist/hub/rooms/context.d.ts +1 -1
  412. package/dist/hub/rooms/context.js +4 -4
  413. package/dist/hub/rooms/context.js.map +1 -1
  414. package/dist/hub/rooms/direct-view.d.ts +6 -2
  415. package/dist/hub/rooms/direct-view.js +3 -3
  416. package/dist/hub/rooms/direct-view.js.map +1 -1
  417. package/dist/hub/rooms/mentions.d.ts +15 -0
  418. package/dist/hub/rooms/mentions.js +43 -0
  419. package/dist/hub/rooms/mentions.js.map +1 -0
  420. package/dist/hub/rooms/post-replies.d.ts +23 -0
  421. package/dist/hub/rooms/post-replies.js +114 -0
  422. package/dist/hub/rooms/post-replies.js.map +1 -0
  423. package/dist/hub/rooms/schema.d.ts +9 -0
  424. package/dist/hub/rooms/schema.js +43 -0
  425. package/dist/hub/rooms/schema.js.map +1 -1
  426. package/dist/hub/rooms/service.d.ts +163 -4
  427. package/dist/hub/rooms/service.js +795 -25
  428. package/dist/hub/rooms/service.js.map +1 -1
  429. package/dist/hub/rooms/types.d.ts +29 -3
  430. package/dist/hub/rooms.d.ts +12 -2
  431. package/dist/hub/rooms.js +88 -18
  432. package/dist/hub/rooms.js.map +1 -1
  433. package/dist/hub/runtime.d.ts +1 -1
  434. package/dist/hub/runtime.js +17 -4
  435. package/dist/hub/runtime.js.map +1 -1
  436. package/dist/hub/server.d.ts +8 -1
  437. package/dist/hub/server.js +93 -7
  438. package/dist/hub/server.js.map +1 -1
  439. package/dist/hub/session-directory-transition.d.ts +2 -1
  440. package/dist/hub/session-directory-transition.js +10 -3
  441. package/dist/hub/session-directory-transition.js.map +1 -1
  442. package/dist/hub/sessions.d.ts +1 -1
  443. package/dist/hub/sessions.js +26 -4
  444. package/dist/hub/sessions.js.map +1 -1
  445. package/dist/hub/settings-commit.d.ts +32 -1
  446. package/dist/hub/settings-commit.js +11 -4
  447. package/dist/hub/settings-commit.js.map +1 -1
  448. package/dist/hub/settings-directory-ca.js +1 -1
  449. package/dist/hub/settings-directory-ca.js.map +1 -1
  450. package/dist/hub/settings-directory-control.js +7 -7
  451. package/dist/hub/settings-directory-control.js.map +1 -1
  452. package/dist/hub/settings-directory-http.d.ts +2 -0
  453. package/dist/hub/settings-directory-http.js +21 -6
  454. package/dist/hub/settings-directory-http.js.map +1 -1
  455. package/dist/hub/settings-directory-proof.d.ts +5 -1
  456. package/dist/hub/settings-directory-proof.js +49 -10
  457. package/dist/hub/settings-directory-proof.js.map +1 -1
  458. package/dist/hub/settings-directory-recovery.js +2 -1
  459. package/dist/hub/settings-directory-recovery.js.map +1 -1
  460. package/dist/hub/settings-directory-save.d.ts +2 -0
  461. package/dist/hub/settings-directory-save.js +9 -6
  462. package/dist/hub/settings-directory-save.js.map +1 -1
  463. package/dist/hub/sharing.js +2 -2
  464. package/dist/hub/sharing.js.map +1 -1
  465. package/dist/hub/socket.d.ts +1 -0
  466. package/dist/hub/socket.js +39 -2
  467. package/dist/hub/socket.js.map +1 -1
  468. package/dist/hub/teams/index.d.ts +8 -3
  469. package/dist/hub/teams/index.js +106 -31
  470. package/dist/hub/teams/index.js.map +1 -1
  471. package/dist/hub/teams/store.d.ts +5 -1
  472. package/dist/hub/teams/store.js +25 -2
  473. package/dist/hub/teams/store.js.map +1 -1
  474. package/dist/hub/teams/types.d.ts +19 -2
  475. package/dist/hub/types.d.ts +159 -5
  476. package/dist/hub-classic-private.d.ts +19 -0
  477. package/dist/hub-classic-private.js +64 -0
  478. package/dist/hub-classic-private.js.map +1 -0
  479. package/dist/hub-contact-windows.d.ts +11 -0
  480. package/dist/hub-contact-windows.js +56 -0
  481. package/dist/hub-contact-windows.js.map +1 -0
  482. package/dist/hub-pairing-summary.d.ts +1 -1
  483. package/dist/hub-room-conversation.d.ts +14 -0
  484. package/dist/hub-room-conversation.js +60 -0
  485. package/dist/hub-room-conversation.js.map +1 -0
  486. package/dist/hub-update-notice.d.ts +12 -0
  487. package/dist/hub-update-notice.js +35 -0
  488. package/dist/hub-update-notice.js.map +1 -0
  489. package/dist/human-delivery-receipts.js +8 -0
  490. package/dist/human-delivery-receipts.js.map +1 -1
  491. package/dist/instance-config-impact.js +3 -0
  492. package/dist/instance-config-impact.js.map +1 -1
  493. package/dist/instructions.js +3 -0
  494. package/dist/instructions.js.map +1 -1
  495. package/dist/locale.js +137 -24
  496. package/dist/locale.js.map +1 -1
  497. package/dist/login-controller.d.ts +19 -2
  498. package/dist/login-controller.js +26 -8
  499. package/dist/login-controller.js.map +1 -1
  500. package/dist/native-mcp.js +7 -5
  501. package/dist/native-mcp.js.map +1 -1
  502. package/dist/native-model-catalog.d.ts +15 -0
  503. package/dist/native-model-catalog.js +43 -3
  504. package/dist/native-model-catalog.js.map +1 -1
  505. package/dist/native-pane-lifecycle.js +3 -2
  506. package/dist/native-pane-lifecycle.js.map +1 -1
  507. package/dist/native-pane-tools.js +3 -0
  508. package/dist/native-pane-tools.js.map +1 -1
  509. package/dist/office-share-page.js +1 -1
  510. package/dist/office-share-page.js.map +1 -1
  511. package/dist/outbound-handlers.d.ts +14 -4
  512. package/dist/outbound-handlers.js +54 -1
  513. package/dist/outbound-handlers.js.map +1 -1
  514. package/dist/outbound-schemas.d.ts +17 -0
  515. package/dist/outbound-schemas.js +14 -0
  516. package/dist/outbound-schemas.js.map +1 -1
  517. package/dist/pane-port.d.ts +2 -0
  518. package/dist/public-web-gateway.js +152 -4
  519. package/dist/public-web-gateway.js.map +1 -1
  520. package/dist/queued-handoffs.d.ts +16 -4
  521. package/dist/queued-handoffs.js +18 -1
  522. package/dist/queued-handoffs.js.map +1 -1
  523. package/dist/quickstart-api.d.ts +0 -1
  524. package/dist/quickstart-api.js +8 -1
  525. package/dist/quickstart-api.js.map +1 -1
  526. package/dist/reply-dedup.js +3 -1
  527. package/dist/reply-dedup.js.map +1 -1
  528. package/dist/reply-preview-files.d.ts +38 -0
  529. package/dist/reply-preview-files.js +142 -0
  530. package/dist/reply-preview-files.js.map +1 -0
  531. package/dist/reply-preview-spec.d.ts +18 -0
  532. package/dist/reply-preview-spec.js +27 -0
  533. package/dist/reply-preview-spec.js.map +1 -0
  534. package/dist/runtime-api.js +10 -2
  535. package/dist/runtime-api.js.map +1 -1
  536. package/dist/runtime-build-info.js +1 -0
  537. package/dist/runtime-build-info.js.map +1 -1
  538. package/dist/runtime-cli-install.js +13 -10
  539. package/dist/runtime-cli-install.js.map +1 -1
  540. package/dist/runtime-cli.js +31 -5
  541. package/dist/runtime-cli.js.map +1 -1
  542. package/dist/runtime-client-store.d.ts +5 -0
  543. package/dist/runtime-client-store.js +28 -0
  544. package/dist/runtime-client-store.js.map +1 -1
  545. package/dist/runtime-client.d.ts +4 -0
  546. package/dist/runtime-client.js +33 -10
  547. package/dist/runtime-client.js.map +1 -1
  548. package/dist/runtime-coordinator.d.ts +4 -2
  549. package/dist/runtime-coordinator.js +33 -6
  550. package/dist/runtime-coordinator.js.map +1 -1
  551. package/dist/runtime-install.d.ts +6 -1
  552. package/dist/runtime-install.js +12 -4
  553. package/dist/runtime-install.js.map +1 -1
  554. package/dist/runtime-pane-native.js +3 -1
  555. package/dist/runtime-pane-native.js.map +1 -1
  556. package/dist/runtime-personal-answer-only-probe.d.ts +3 -0
  557. package/dist/runtime-personal-answer-only-probe.js +134 -0
  558. package/dist/runtime-personal-answer-only-probe.js.map +1 -0
  559. package/dist/runtime-personal-answer-only.d.ts +16 -0
  560. package/dist/runtime-personal-answer-only.js +54 -0
  561. package/dist/runtime-personal-answer-only.js.map +1 -0
  562. package/dist/runtime-personal-answer.d.ts +30 -0
  563. package/dist/runtime-personal-answer.js +124 -0
  564. package/dist/runtime-personal-answer.js.map +1 -0
  565. package/dist/runtime-personal-preflight.d.ts +8 -0
  566. package/dist/runtime-personal-preflight.js +103 -0
  567. package/dist/runtime-personal-preflight.js.map +1 -0
  568. package/dist/runtime-personal-profile.d.ts +40 -0
  569. package/dist/runtime-personal-profile.js +81 -0
  570. package/dist/runtime-personal-profile.js.map +1 -0
  571. package/dist/runtime-personal-protocol.d.ts +10 -0
  572. package/dist/runtime-personal-protocol.js +15 -0
  573. package/dist/runtime-personal-protocol.js.map +1 -0
  574. package/dist/runtime-personal-stage.d.ts +37 -0
  575. package/dist/runtime-personal-stage.js +167 -0
  576. package/dist/runtime-personal-stage.js.map +1 -0
  577. package/dist/runtime-protocol.d.ts +2 -0
  578. package/dist/settings-api.d.ts +15 -0
  579. package/dist/settings-api.js +210 -76
  580. package/dist/settings-api.js.map +1 -1
  581. package/dist/settings-change.js +32 -5
  582. package/dist/settings-change.js.map +1 -1
  583. package/dist/settings-effect.js +13 -2
  584. package/dist/settings-effect.js.map +1 -1
  585. package/dist/settings-http-confirmation.js +18 -44
  586. package/dist/settings-http-confirmation.js.map +1 -1
  587. package/dist/setup-form.js +10 -0
  588. package/dist/setup-form.js.map +1 -1
  589. package/dist/setup-i18n.js +2 -2
  590. package/dist/setup-i18n.js.map +1 -1
  591. package/dist/subagent-records.js +53 -11
  592. package/dist/subagent-records.js.map +1 -1
  593. package/dist/subagent-service.js +3 -1
  594. package/dist/subagent-service.js.map +1 -1
  595. package/dist/tmux-manager.d.ts +2 -0
  596. package/dist/tmux-manager.js +2 -0
  597. package/dist/tmux-manager.js.map +1 -1
  598. package/dist/tool-permissions.js +3 -0
  599. package/dist/tool-permissions.js.map +1 -1
  600. package/dist/tool-progress.d.ts +9 -0
  601. package/dist/tool-progress.js +141 -32
  602. package/dist/tool-progress.js.map +1 -1
  603. package/dist/transcript-needles.d.ts +4 -2
  604. package/dist/transcript-needles.js +35 -4
  605. package/dist/transcript-needles.js.map +1 -1
  606. package/dist/tunnel/lease.d.ts +14 -0
  607. package/dist/tunnel/lease.js +23 -0
  608. package/dist/tunnel/lease.js.map +1 -1
  609. package/dist/turn-reply-guard.d.ts +2 -2
  610. package/dist/turn-reply-guard.js +3 -3
  611. package/dist/turn-reply-guard.js.map +1 -1
  612. package/dist/types.d.ts +12 -2
  613. package/dist/ui/backend-signin.js +91 -22
  614. package/dist/ui/chat-activity-groups.js +41 -8
  615. package/dist/ui/chat-activity.js +5 -3
  616. package/dist/ui/chat-mentions.js +13 -0
  617. package/dist/ui/chat-msg-actions.js +3 -222
  618. package/dist/ui/chat-pins.js +106 -0
  619. package/dist/ui/chat-popout-header.js +2 -2
  620. package/dist/ui/chat-store.js +143 -7
  621. package/dist/ui/chat-tour.js +1 -1
  622. package/dist/ui/chat-workspace.js +3 -3
  623. package/dist/ui/fleet-canvas.js +14 -5
  624. package/dist/ui/fleet-office-carousel.d.ts +14 -0
  625. package/dist/ui/fleet-office-carousel.js +95 -0
  626. package/dist/ui/fleet-office-editor.js +6 -1
  627. package/dist/ui/fleet-office-model.js +2 -1
  628. package/dist/ui/fleet-office-skin.js +1 -1
  629. package/dist/ui/fleet-office-store.js +14 -2
  630. package/dist/ui/fleet-office-zones.js +50 -9
  631. package/dist/ui/fleet-office.js +203 -24
  632. package/dist/ui/fleet-tasks.js +1 -1
  633. package/dist/ui/host-install.js +5 -2
  634. package/dist/ui/hub-admin-overview.js +189 -0
  635. package/dist/ui/hub-admin-rooms.js +1 -1
  636. package/dist/ui/hub-agent-copy.js +6 -2
  637. package/dist/ui/hub-ai-apps-strings.js +6 -0
  638. package/dist/ui/hub-ai-apps.js +83 -0
  639. package/dist/ui/hub-chat-strings.js +7 -0
  640. package/dist/ui/hub-client.js +76 -5
  641. package/dist/ui/hub-directory-editor-strings.js +2 -2
  642. package/dist/ui/hub-directory-editor.js +1 -0
  643. package/dist/ui/hub-fleet-versions.js +393 -0
  644. package/dist/ui/hub-grant-picker.js +3 -37
  645. package/dist/ui/hub-group-policy.js +26 -13
  646. package/dist/ui/hub-group-strings.js +26 -17
  647. package/dist/ui/hub-join-steps.js +27 -15
  648. package/dist/ui/hub-owner-strings.js +2 -2
  649. package/dist/ui/hub-personal-agent-strings.js +246 -0
  650. package/dist/ui/hub-personal-agent.js +117 -0
  651. package/dist/ui/hub-policy-subjects.js +35 -0
  652. package/dist/ui/hub-quick-pairing.js +7 -2
  653. package/dist/ui/hub-role-audit.js +39 -0
  654. package/dist/ui/hub-role-forms.js +99 -0
  655. package/dist/ui/hub-role-notices.js +11 -0
  656. package/dist/ui/hub-role-view.js +86 -0
  657. package/dist/ui/hub-roles-strings.js +439 -0
  658. package/dist/ui/hub-roles.js +83 -0
  659. package/dist/ui/hub-room-agent-strings.js +28 -0
  660. package/dist/ui/hub-room-composer.js +19 -10
  661. package/dist/ui/hub-room-favorites.js +63 -5
  662. package/dist/ui/hub-room-list.js +4 -3
  663. package/dist/ui/hub-room-members-strings.js +2 -2
  664. package/dist/ui/hub-room-members.js +7 -4
  665. package/dist/ui/hub-room-notify.js +161 -0
  666. package/dist/ui/hub-room-search.js +126 -0
  667. package/dist/ui/hub-room-settings.js +6 -0
  668. package/dist/ui/hub-room-source-strings.js +17 -0
  669. package/dist/ui/hub-room-source.js +34 -0
  670. package/dist/ui/hub-room-strings.js +47 -1
  671. package/dist/ui/hub-room-thread.js +266 -41
  672. package/dist/ui/hub-room-unread.js +2 -1
  673. package/dist/ui/hub-strings.js +8 -0
  674. package/dist/ui/hub-subject-picker.js +58 -0
  675. package/dist/ui/hub-switcher.js +2 -2
  676. package/dist/ui/hub-teams-strings.js +10 -6
  677. package/dist/ui/hub-teams.js +56 -28
  678. package/dist/ui/hub-this-hub.js +2 -2
  679. package/dist/ui/hub-welcome.js +122 -75
  680. package/dist/ui/image-annotate.js +2 -283
  681. package/dist/ui/image-lightbox.js +2 -176
  682. package/dist/ui/image-zoom.js +2 -242
  683. package/dist/ui/model-picker.js +4 -1
  684. package/dist/ui/notice-hub-update.js +94 -0
  685. package/dist/ui/office-share-dialog.js +2 -2
  686. package/dist/ui/panel-chat.js +327 -28
  687. package/dist/ui/panel-details.js +3 -1
  688. package/dist/ui/panel-fleet.js +28 -7
  689. package/dist/ui/panel-hub.js +294 -99
  690. package/dist/ui/panel-log.js +4 -4
  691. package/dist/ui/panel-notices.js +3 -1
  692. package/dist/ui/panel-settings.js +45 -34
  693. package/dist/ui/preview-panel.js +3 -1
  694. package/dist/ui/reply-file-preview.js +64 -0
  695. package/dist/ui/runtime-commands.d.ts +2 -2
  696. package/dist/ui/runtime-commands.js +7 -4
  697. package/dist/ui/settings-access-overview.js +3 -3
  698. package/dist/ui/settings-appearance.js +7 -10
  699. package/dist/ui/settings-archive-files.js +109 -0
  700. package/dist/ui/settings-build-version.js +2 -2
  701. package/dist/ui/settings-catalog.js +22 -0
  702. package/dist/ui/settings-connector-strings.js +23 -0
  703. package/dist/ui/settings-connector.js +39 -0
  704. package/dist/ui/settings-guests-entries.js +16 -0
  705. package/dist/ui/settings-guests.js +57 -15
  706. package/dist/ui/settings-hub-connection.js +4 -5
  707. package/dist/ui/settings-hub-membership.js +6 -7
  708. package/dist/ui/settings-hub-section.js +2 -4
  709. package/dist/ui/settings-hub-setup.js +2 -1
  710. package/dist/ui/settings-hub-updates.js +67 -0
  711. package/dist/ui/settings-hub.js +30 -4
  712. package/dist/ui/settings-layout.js +10 -12
  713. package/dist/ui/settings-registry.js +18 -3
  714. package/dist/ui/settings-shared-strings.js +2 -0
  715. package/dist/ui/settings-strings.js +13 -2
  716. package/dist/ui/settings-update.js +11 -5
  717. package/dist/ui/settings-web-authority.js +7 -5
  718. package/dist/ui/shared/access-overview.css +1 -1
  719. package/dist/ui/shared/accounts-keepalive.css +1 -1
  720. package/dist/ui/shared/accounts.css +1 -1
  721. package/dist/ui/shared/agent-sheet.js +116 -0
  722. package/dist/ui/shared/agent-widget.js +1 -2
  723. package/dist/ui/shared/app-i18n.js +4 -0
  724. package/dist/ui/shared/app-nav.js +9 -5
  725. package/dist/ui/shared/app-prefs.js +9 -3
  726. package/dist/ui/shared/app-route.js +4 -2
  727. package/dist/ui/shared/app-shell.js +176 -21
  728. package/dist/ui/shared/app-store.js +1 -1
  729. package/dist/ui/shared/app-stream.js +6 -2
  730. package/dist/ui/shared/app-swipe.js +3 -1
  731. package/dist/ui/shared/app-themes.js +3 -5
  732. package/dist/ui/shared/app-update.js +90 -8
  733. package/dist/ui/shared/app.css +469 -203
  734. package/dist/ui/shared/app.js +1 -1
  735. package/dist/ui/shared/chat-composer.js +29 -5
  736. package/dist/ui/shared/chat-msg-actions.js +231 -0
  737. package/dist/ui/shared/chat-strings.js +19 -4
  738. package/dist/ui/shared/chat-thread.js +120 -17
  739. package/dist/ui/shared/chat-work-bar.css +118 -0
  740. package/dist/ui/shared/connector-prompt.d.ts +3 -0
  741. package/dist/ui/shared/connector-prompt.js +20 -0
  742. package/dist/ui/shared/hub-ai-apps.css +12 -0
  743. package/dist/ui/shared/hub-chat.css +58 -4
  744. package/dist/ui/shared/hub-groups.css +19 -15
  745. package/dist/ui/shared/hub-owner.css +118 -3
  746. package/dist/ui/shared/hub-roles.css +99 -0
  747. package/dist/ui/shared/hub-rooms-u2.css +34 -0
  748. package/dist/ui/shared/hub.css +23 -5
  749. package/dist/ui/shared/image-annotate.css +22 -3
  750. package/dist/ui/shared/image-annotate.js +415 -0
  751. package/dist/ui/shared/image-lightbox.js +218 -0
  752. package/dist/ui/shared/image-zoom.js +316 -0
  753. package/dist/ui/shared/instance-nav.js +120 -15
  754. package/dist/ui/shared/loading.css +1 -1
  755. package/dist/ui/shared/model-picker.css +32 -4
  756. package/dist/ui/shared/owner-css.js +1 -1
  757. package/dist/ui/shared/panel-view.js +7 -1
  758. package/dist/ui/shared/preview-panel-actions.js +1 -1
  759. package/dist/ui/shared/preview-panel.js +6 -2
  760. package/dist/ui/shared/reply-previews.css +4 -0
  761. package/dist/ui/shared/runtime-install.css +5 -0
  762. package/dist/ui/shared/settings-connector.css +7 -0
  763. package/dist/ui/shared/signin.js +27 -12
  764. package/dist/ui/shared/task-board.css +2 -2
  765. package/dist/ui/shared/theme.js +52 -0
  766. package/dist/ui/shared/tokens.css +27 -10
  767. package/dist/ui/shared/ui-icons.js +2 -0
  768. package/dist/ui/shared/ui-toast.js +4 -4
  769. package/dist/ui/shared/usage-dialog.js +113 -17
  770. package/dist/ui/shared/view-strings.js +26 -4
  771. package/dist/ui/shared/web-authorize.js +3 -3
  772. package/dist/ui/signin.html +4 -2
  773. package/dist/ui/structured-signin.js +64 -12
  774. package/dist/ui/web-terminal/terminal.css +1 -1
  775. package/dist/ui/workspace-panel.js +4 -3
  776. package/dist/update-dispatch.d.ts +8 -1
  777. package/dist/update-dispatch.js +16 -1
  778. package/dist/update-dispatch.js.map +1 -1
  779. package/dist/update-idle.d.ts +65 -0
  780. package/dist/update-idle.js +190 -0
  781. package/dist/update-idle.js.map +1 -0
  782. package/dist/update-launch.d.ts +1 -1
  783. package/dist/update-launch.js +9 -2
  784. package/dist/update-launch.js.map +1 -1
  785. package/dist/usage/i18n-keys.d.ts +1 -1
  786. package/dist/usage/i18n-keys.js +1 -1
  787. package/dist/usage/i18n-keys.js.map +1 -1
  788. package/dist/usage/profile-timeline.d.ts +2 -0
  789. package/dist/usage/profile-timeline.js +4 -0
  790. package/dist/usage/profile-timeline.js.map +1 -1
  791. package/dist/usage/providers.js +6 -6
  792. package/dist/usage/providers.js.map +1 -1
  793. package/dist/usage/quota-history.d.ts +1 -1
  794. package/dist/view-api.js +1 -1
  795. package/dist/view-api.js.map +1 -1
  796. package/dist/web-api.d.ts +9 -0
  797. package/dist/web-api.js +434 -188
  798. package/dist/web-api.js.map +1 -1
  799. package/dist/web-backend-login.d.ts +5 -1
  800. package/dist/web-backend-login.js +8 -2
  801. package/dist/web-backend-login.js.map +1 -1
  802. package/dist/web-chat-archive.d.ts +147 -0
  803. package/dist/web-chat-archive.js +530 -0
  804. package/dist/web-chat-archive.js.map +1 -0
  805. package/dist/web-chat-history.d.ts +76 -0
  806. package/dist/web-chat-history.js +145 -1
  807. package/dist/web-chat-history.js.map +1 -1
  808. package/dist/web-commands.d.ts +4 -3
  809. package/dist/web-commands.js +3 -2
  810. package/dist/web-commands.js.map +1 -1
  811. package/dist/web-guest-access.d.ts +3 -0
  812. package/dist/web-guest-access.js +6 -2
  813. package/dist/web-guest-access.js.map +1 -1
  814. package/dist/web-icons.js +3 -3
  815. package/dist/web-icons.js.map +1 -1
  816. package/dist/web-login.d.ts +7 -0
  817. package/dist/web-login.js +8 -1
  818. package/dist/web-login.js.map +1 -1
  819. package/dist/web-mentions.d.ts +2 -0
  820. package/dist/web-mentions.js +20 -0
  821. package/dist/web-mentions.js.map +1 -1
  822. package/dist/web-notices.d.ts +3 -0
  823. package/dist/web-notices.js +17 -2
  824. package/dist/web-notices.js.map +1 -1
  825. package/dist/web-office-store.d.ts +2 -0
  826. package/dist/web-office-store.js +15 -3
  827. package/dist/web-office-store.js.map +1 -1
  828. package/dist/web-pin-store.d.ts +58 -0
  829. package/dist/web-pin-store.js +170 -0
  830. package/dist/web-pin-store.js.map +1 -0
  831. package/dist/web-prefs.js +5 -1
  832. package/dist/web-prefs.js.map +1 -1
  833. package/dist/web-session-authorization.d.ts +24 -0
  834. package/dist/web-session-authorization.js +32 -0
  835. package/dist/web-session-authorization.js.map +1 -1
  836. package/dist/web-session.d.ts +6 -4
  837. package/dist/web-session.js +5 -3
  838. package/dist/web-session.js.map +1 -1
  839. package/dist/web-settings-patch.d.ts +24 -3
  840. package/dist/web-settings-patch.js +57 -1
  841. package/dist/web-settings-patch.js.map +1 -1
  842. package/dist/web-shell-routes.d.ts +1 -1
  843. package/dist/web-shell-routes.js +1 -1
  844. package/dist/web-shell-routes.js.map +1 -1
  845. package/dist/web-theme.js +2 -2
  846. package/dist/web-update.d.ts +15 -1
  847. package/dist/web-upload.d.ts +36 -0
  848. package/dist/web-upload.js +105 -5
  849. package/dist/web-upload.js.map +1 -1
  850. package/dist/windows-cli-api.d.ts +10 -7
  851. package/dist/windows-cli-api.js +13 -12
  852. package/dist/windows-cli-api.js.map +1 -1
  853. package/dist/windows-cli-worker.d.ts +10 -0
  854. package/dist/windows-cli-worker.js +109 -14
  855. package/dist/windows-cli-worker.js.map +1 -1
  856. package/dist/windows-cli.d.ts +10 -1
  857. package/dist/windows-cli.js +47 -13
  858. package/dist/windows-cli.js.map +1 -1
  859. package/package.json +1 -1
  860. package/templates/runtime-install/install.ps1 +24 -4
@@ -1,3 +1,4 @@
1
+ import { replyPreviews } from "./reply-preview-spec.js";
1
2
  import { settingsSummary, translatedSummary } from "./settings-summary.js";
2
3
  import { readInstalledBuild } from "./build-provenance.js";
3
4
  import { buildNativeFleetInstructions } from "./instructions.js";
@@ -63,6 +64,7 @@ import { measureSyncWork } from "./sync-work-attribution.js";
63
64
  import { RuntimeCpuProfiler, ProfileBusyError, profileDuration } from "./runtime-cpu-profile.js";
64
65
  import { ProfileControlServer } from "./profile-control.js";
65
66
  import { existsSync, readFileSync, mkdirSync, writeFileSync, unlinkSync, rmSync, readdirSync, renameSync, copyFileSync, chmodSync, statSync, realpathSync, lstatSync, constants as fsConstants, openSync, closeSync, fsyncSync } from "node:fs";
67
+ import { HubContactWindows } from "./hub-contact-windows.js";
66
68
  import { atomicWriteFileSync } from "./atomic-write.js";
67
69
  import { createHash, randomBytes, randomUUID } from "node:crypto";
68
70
  import { freemem, totalmem, homedir, hostname } from "node:os";
@@ -105,7 +107,7 @@ import { getEffectiveInstanceDefaults, loadFleetConfig, loadRawFleetConfig, load
105
107
  import { EventLog } from "./event-log.js";
106
108
  import { binaryProbe } from "./binary-probe.js";
107
109
  import { deletePlannedTopic, planInstanceTopicDelete, topicDestination, topicMustStay } from "./instance-topic-delete.js";
108
- import { AVAILABILITY_STALE_MS, BackendAvailabilityStore, versionAtLeast, hostAvailabilityProbes, findExecutableIn, resolveBackendBinary } from "./backend-availability.js";
110
+ import { AVAILABILITY_STALE_MS, BackendAvailabilityStore, structuredSignInReady, hostAvailabilityProbes, findExecutableIn, resolveBackendBinary } from "./backend-availability.js";
109
111
  import { classifySqliteOpenError } from "./sqlite-open-errors.js";
110
112
  import { OutboxOpenError } from "./outbox-open-error.js";
111
113
  import { AdapterWorld } from "./adapter-world.js";
@@ -134,7 +136,7 @@ import { routeToolCall } from "./channel/tool-router.js";
134
136
  import { Scheduler } from "./scheduler/index.js";
135
137
  import { boardActivity, boardCardLimit, boardToolAction } from "./task-board-tool.js";
136
138
  import { TaskBoardWaker, namesCard } from "./task-board-waker.js";
137
- import { DispatcherLiveness, LIVENESS_STARTUP_GRACE_MS, livenessSettings } from "./dispatcher-liveness.js";
139
+ import { DispatcherLiveness, LIVENESS_STARTUP_GRACE_MS, livenessSettings, questionNotices, turnQuestion } from "./dispatcher-liveness.js";
138
140
  import { TaskBoardError, waitsForPerson, wrapUpGap } from "./scheduler/task-board.js";
139
141
  import { escapeTelegramHtml, scheduleClock, scheduleRetryLabel } from "./scheduler/retry-label.js";
140
142
  import { DEFAULT_SCHEDULER_CONFIG } from "./scheduler/index.js";
@@ -228,7 +230,7 @@ import { RuntimeWindowsBridge } from "./runtime-windows-bridge.js";
228
230
  import { FleetWindowsRuntime } from "./fleet-windows-runtime.js";
229
231
  import { NativeMcpSessions } from "./native-mcp.js";
230
232
  import { nativeProviderMcpSupported } from "./windows-cli-providers.js";
231
- import { cachedNativeModelCatalog } from "./native-model-catalog.js";
233
+ import { cachedNativeModelCatalog, refreshNativeModelCatalogAfterSignIn } from "./native-model-catalog.js";
232
234
  import { shapeWebModelCatalog } from "./web-model-groups.js";
233
235
  import { isWindowsInstance, isNativePaneInstance, isNativeExecInstance, WINDOWS_CONFIG_REFUSED, nativeCredentialProfile } from "./native-instance-registry.js";
234
236
  import { createNativeWindowsInstance, updateNativeWindowsInstance } from "./native-instance-api.js";
@@ -238,12 +240,14 @@ import { viewHistory } from "./view-history.js";
238
240
  import { WebChatHistory, WEB_CHAT_TEXT_MAX, isWebMessageId, newWebMessageId, webChatFrom } from "./web-chat-history.js";
239
241
  import { WEB_ECHO_COPIES_MAX, WEB_MIRROR_TIMEOUT_MS, webReactionEmoji, webReactionProblem } from "./web-reactions.js";
240
242
  import { WebChatDiskStore, isSafeInstanceDirName } from "./web-chat-store.js";
243
+ import { WebChatArchive } from "./web-chat-archive.js";
241
244
  import { SeenUsers, resolveMentions } from "./web-mentions.js";
242
245
  import { OPERATOR, WebPrefsStore } from "./web-prefs.js";
243
246
  import { agendVersion } from "./agent-whats-new.js";
244
247
  import { OwnerCssStore } from "./web-owner-css-store.js";
245
248
  import { ThemeStore } from "./web-theme-store.js";
246
249
  import { OfficeStore, OfficeWriteLimiter } from "./web-office-store.js";
250
+ import { WebPinStore } from "./web-pin-store.js";
247
251
  import { OfficeSkinStore } from "./web-office-skins.js";
248
252
  import { OfficeActs } from "./web-office-acts.js";
249
253
  import { OFFICE_PACK_TOOLS, OfficePackTools } from "./web-office-pack-tools.js";
@@ -285,7 +289,8 @@ import { GUEST_COMMAND_RUNS, GUEST_PREF_WRITES, GUEST_SEARCHES, bindGuestRequest
285
289
  import { GUEST_ROOM_TICK_MS, GuestRoomMembership, guestGroupRooms } from "./web-guest-rooms.js";
286
290
  import { Delegations, TrafficLog, trafficItem } from "./fleet-traffic.js";
287
291
  import { installedChannel, updateNoticeKey } from "./update-check.js";
288
- import { resolveInstalledAgend } from "./update-dispatch.js";
292
+ import { resolveInstalledAgend, npmForRunningInstall } from "./update-dispatch.js";
293
+ import { HUB_UPDATE_NOTICE_FILE, HUB_UPDATE_REMIND_MS, hubNoticeDue, hubNoticeKey, readHubNoticeState, writeHubNoticeState } from "./hub-update-notice.js";
289
294
  import { resolveUpdateLaunch, openUpdateLog, updateLogPath, watchUpdateLaunch } from "./update-launch.js";
290
295
  import { isWebUpdateTarget, readLogTail, RUNNING_AGEND_VERSION, updateOffer, webProgressOf, webUpdateTarget } from "./web-update.js";
291
296
  import { admitProfileLogin, LoginController, LOGIN_TOKEN_RESEND_PREFIX, POST_LOGIN_RECOVERY_DEADLINE_MS } from "./login-controller.js";
@@ -307,6 +312,7 @@ import { handleAgentRequest, ToolNotPermittedError } from "./agent-endpoint.js";
307
312
  import { AgentCredentials, agentCredentialPolicy } from "./agent-credentials.js";
308
313
  import { writeSecretFile } from "./secret-file.js";
309
314
  import { ConfigHistory, ConfigSyntaxError, configIssueText } from "./config-history.js";
315
+ import { HubClassicPrivateTurns } from "./hub-classic-private.js";
310
316
  import { ClassicChannelManager, classicWebEchoOn, getClassicBackendChoices, inferClassicChannelType, isSelectableClassicBackend, readClassicLastActivityAt, readClassicRoomNames } from "./classic-channel-manager.js";
311
317
  import { assertExplicitInstanceRemoval } from "./instance-removal.js";
312
318
  import { KNOWN_BACKENDS, validateFleetConfig } from "./config-validator.js";
@@ -317,6 +323,9 @@ import { assertNoSessionOomStop, readSessionOomStop, captureSessionOomRetry, cle
317
323
  import { redactSecrets } from "./tool-progress.js";
318
324
  import { idleGateTimeoutLog } from "./idle-gate-log.js";
319
325
  import { DEFAULT_STUCK_TIMEOUT_MS, readLastInboundAt } from "./daemon.js";
326
+ import { CODEX_INLINE_MODEL_MIN, codexModelCommand } from "./backend/codex-model-switch.js";
327
+ import { CLI_RUNTIME_SWITCH } from "./backend/cli-runtime-switch.js";
328
+ import { readKiroLedger } from "./backend/kiro-engine-ledger.js";
320
329
  import { clearPausedMarker, readPausedAt, readPauseReason, writePausedMarker } from "./pause-marker.js";
321
330
  import { readBackgroundWorkEndedMarker } from "./background-work-ended.js";
322
331
  import { DEFAULT_WARM_OVERFLOW, WakeCoordinator } from "./wake-coordinator.js";
@@ -324,7 +333,7 @@ import { TargetQueueWorker } from "./target-queue-worker.js";
324
333
  import { resolveDeliveryWorkerMode } from "./types.js";
325
334
  import { isFleetStartCommandLine, readProcessCommandLine, releaseProcessFleetLock } from "./fleet-lock.js";
326
335
  import { isSetupComplete, markSetupComplete } from "./setup-marker.js";
327
- import { manualCleanupMessage, reapStaleTunnel } from "./tunnel/lease.js";
336
+ import { reapLeftoverTunnels } from "./tunnel/lease.js";
328
337
  import { buildToolPermissionsNotice } from "./tool-permissions-notice.js";
329
338
  import { NeedsYouHub } from "./needs-you-hub.js";
330
339
  import { SignInKeepAlive, isKeepAliveBackend } from "./signin-keepalive.js";
@@ -352,7 +361,7 @@ import { findSigninKnownEntry, addSigninKnownDevice } from "./web-signin-device.
352
361
  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
362
  import { evaluateSettingsRole } from "./authority/settings-role.js";
354
363
  import { authorityNow, evaluateWebAuthority, HOST_OPERATOR, VERIFIED_SESSION_HOURS, webAuthorityPolicy } from "./authority/web-authority.js";
355
- import { AuthorityStateStore } from "./authority/authority-state.js";
364
+ import { AuthorityStateStore, namedLinkLastTurnedOff } from "./authority/authority-state.js";
356
365
  import { SessionAuthorizations } from "./authority/session-authorizations.js";
357
366
  import { SessionAuthorizationRequests } from "./web-session-authorization.js";
358
367
  import { GuestLoginCodes, WebLoginCodes, LOGIN_CODE_TTL_MS } from "./web-login.js";
@@ -612,6 +621,9 @@ const HANG_CALLBACK_PREFIX = "hang:";
612
621
  const CLEAR_CONFIRM_CALLBACK_PREFIX = "clear-confirm:";
613
622
  /** #2598 B2: a kiro classic → TUI move's Confirm in General. "kiro-migrate:" (13) + 32 hex + ":confirm" (8) = 53 bytes. */
614
623
  const KIRO_MIGRATE_CALLBACK_PREFIX = "kiro-migrate:";
624
+ /** M-3140: Update now on a Hub-recommended-version notice in General ("hub-update:" + 32 hex + ":update" = 50 bytes). */
625
+ const HUB_UPDATE_CALLBACK_PREFIX = "hub-update:";
626
+ const HUB_FLEET_UPDATE_CALLBACK_PREFIX = "hub-fleet-update:";
615
627
  const KIRO_RECONCILE_CALLBACK_PREFIX = "kiro-reconcile:";
616
628
  /** #2692: a fleet admin's Approve / Reject on an agent's pending skin-pack change, in General. */
617
629
  const OFFICE_PACK_CALLBACK_PREFIX = "office-pack:";
@@ -685,6 +697,13 @@ const NONCE_RETIRE_BUDGET_MS = 5_000;
685
697
  * so nothing re-probed and `/model` kept serving a list up to 24h old.
686
698
  */
687
699
  const CLI_ENV_FRESH_MS = 60 * 60 * 1000;
700
+ /**
701
+ * How long a menu that opens on an empty model list waits for its one discovery, and how long an attempt that
702
+ * found nothing (a CLI not signed in, offline) is not repeated by the next open. Shorter than CLI_ENV_PROBE_DEADLINE_MS: a
703
+ * slower probe finishes behind the menu and the page reads again (the `models` event).
704
+ */
705
+ const MODEL_OPEN_PROBE_WAIT_MS = 12_000;
706
+ const MODEL_OPEN_PROBE_COOLDOWN_MS = 60_000;
688
707
  /**
689
708
  * Upper bound on a live probe driven by `/model`.
690
709
  *
@@ -708,6 +727,8 @@ const CLI_ENV_FRESH_MS = 60 * 60 * 1000;
708
727
  */
709
728
  /** #1690: how long `/model` waits for the daemon's word on our own runtime switch (its dialog wait plus settling). */
710
729
  export const RUNTIME_SWITCH_RESULT_MS = 12_000;
730
+ /** 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. */
731
+ export const CODEX_RUNTIME_SWITCH_RESULT_MS = 80_000;
711
732
  export const CLI_ENV_PROBE_DEADLINE_MS = 16_000;
712
733
  /**
713
734
  * How many CLIs may cold-start at once, from BOTH memory and cores.
@@ -1440,14 +1461,14 @@ export class FleetManager {
1440
1461
  return { result: null, error: "Native panes can only read Windows runtime model inventories" };
1441
1462
  return { result: await this.listModelCatalog({ instanceName: target }) };
1442
1463
  }
1443
- const ops = { list_instances: "list", describe_instance: "describe", task: "task", send_to_instance: "send",
1464
+ 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
1465
  delegate_task: "delegate", request_information: "ask", report_result: "report", delivery_status: "delivery-status" };
1445
1466
  const { nativeAgentAdmissionContext } = await import("./native-agent-admission.js");
1446
1467
  const { dispatchAgentOperation } = await import("./agent-endpoint.js");
1447
1468
  return daemon.handlePaneToolCall(input, { current, allowed: tool => allowed(name, tool),
1448
1469
  dispatch: (tool, args) => ops[tool] ? dispatchAgentOperation(nativeAgentAdmissionContext(this, {
1449
1470
  instance: name, current: () => current() && allowed(name, tool), taskAllowed: () => current() && allowed(name, "task"),
1450
- }), name, ops[tool], args, input.operationId) : undefined });
1471
+ }), name, ops[tool], args, input.operationId, () => current() && allowed(name, tool)) : undefined });
1451
1472
  },
1452
1473
  });
1453
1474
  }
@@ -1671,6 +1692,276 @@ export class FleetManager {
1671
1692
  }
1672
1693
  invalidateHubCompanyJoin() { this.companyJoinController?.invalidate(); }
1673
1694
  hubMemberPairingApi = null;
1695
+ hubRecommendationRead = null;
1696
+ hubRecommendationListeners = new Set();
1697
+ hubRecommendedUpdate() { return this.hubRecommendationRead?.() ?? null; }
1698
+ /**
1699
+ * M-3140: the Hub's advice the asker was shown, if it is still this Fleet's current verified advice and still newer
1700
+ * than what runs (same Hub, version and revision) — else null. What a pinned Update installs comes only from here.
1701
+ */
1702
+ hubRecommendationFor(pin) {
1703
+ const advice = this.hubRecommendedUpdate();
1704
+ if (!advice || advice.version !== pin.version || advice.revision !== pin.revision)
1705
+ return null;
1706
+ let current;
1707
+ try {
1708
+ current = this.runningAgendVersion();
1709
+ }
1710
+ catch {
1711
+ return null;
1712
+ }
1713
+ return this.semverGt(advice.version, current) ? advice : null;
1714
+ }
1715
+ onHubRecommendation(listener) { this.hubRecommendationListeners.add(listener); return () => { this.hubRecommendationListeners.delete(listener); }; }
1716
+ hubRecommendationChanged() {
1717
+ for (const listener of this.hubRecommendationListeners) {
1718
+ try {
1719
+ listener();
1720
+ }
1721
+ catch { /* local presentation observer */ }
1722
+ }
1723
+ void this.maybeNotifyHubRecommendation(); // M-3140: the first notice need not wait for the daily check
1724
+ }
1725
+ /**
1726
+ * M-3140 (spec §3.3, chat): the Hub's recommended version in General, with Update now — when it first applies to this
1727
+ * Fleet, then every 7 days while still behind (hub-update-notice.ts). A web-only fleet has no chat: its banner says it.
1728
+ * Asked on every change of the advice and on the daily update check.
1729
+ */
1730
+ async maybeNotifyHubRecommendation() {
1731
+ if (this.hubUpdateNoticeBusy || this.shuttingDown)
1732
+ return;
1733
+ this.hubUpdateNoticeBusy = true;
1734
+ try {
1735
+ const advice = this.hubRecommendedUpdate();
1736
+ let current = null;
1737
+ try {
1738
+ current = this.runningAgendVersion();
1739
+ }
1740
+ catch {
1741
+ return;
1742
+ }
1743
+ const path = join(this.dataDir, HUB_UPDATE_NOTICE_FILE), now = Date.now();
1744
+ if (!hubNoticeDue(readHubNoticeState(path), advice, current, now, (a, b) => this.semverGt(a, b)) || !advice)
1745
+ return;
1746
+ if (this.webOnlyPromptPlace())
1747
+ return;
1748
+ const general = this.findGeneralInstance();
1749
+ const adapterId = general ? this.getInstanceAdapterId(general) : undefined;
1750
+ const adapter = general ? this.getAdapterForInstance(general) : undefined;
1751
+ const chatId = general ? this.getGroupIdForInstance(general) : undefined;
1752
+ const topic = general ? String(this.fleetConfig?.instances[general]?.topic_id ?? "") : "";
1753
+ if (!general || !adapterId || !adapter || !chatId)
1754
+ return;
1755
+ const nonce = await this.postNonceButtonPromptOrThrow({
1756
+ prefix: HUB_UPDATE_CALLBACK_PREFIX, alertType: "tip", instanceName: general, adapter, adapterId, chatId,
1757
+ ...(topic ? { threadId: topic } : {}),
1758
+ message: t("hub_update.notice", advice.hubName, `v${advice.version}`, `v${current}`),
1759
+ choices: [{ action: "update", label: t("hub_update.button") }],
1760
+ expiredText: t("hub_update.expired"),
1761
+ timeoutMs: HUB_UPDATE_REMIND_MS,
1762
+ });
1763
+ this.pendingHubUpdates.set(nonce, { version: advice.version, revision: advice.revision });
1764
+ const expiry = setTimeout(() => this.pendingHubUpdates.delete(nonce), HUB_UPDATE_REMIND_MS + 60_000);
1765
+ expiry.unref?.();
1766
+ writeHubNoticeState(path, { key: hubNoticeKey(advice), at: now });
1767
+ }
1768
+ catch (err) {
1769
+ this.logger.warn({ err: err.message }, "Hub recommended-version notice not posted");
1770
+ }
1771
+ finally {
1772
+ this.hubUpdateNoticeBusy = false;
1773
+ }
1774
+ }
1775
+ /**
1776
+ * M-3140: Update now on that notice — what chat /update does (a fleet admin's, the installed agend launched
1777
+ * independently, its progress on the message), pinned to the advice the notice named, re-read now and at the launch.
1778
+ */
1779
+ async handleHubUpdateCallback(data, adapterId, adapter) {
1780
+ // Fable #3955: a fleet admin's press only. Anyone else in General is told privately, and the nonce and the button stay
1781
+ // for an admin (consumeNonceCallback's authorize: refused before anything is consumed or retired).
1782
+ 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");
1783
+ if (claimed === null)
1784
+ return false;
1785
+ if (claimed === "consumed")
1786
+ return true;
1787
+ const { entry } = claimed;
1788
+ const nonce = data.callbackData.slice(HUB_UPDATE_CALLBACK_PREFIX.length, HUB_UPDATE_CALLBACK_PREFIX.length + 32);
1789
+ const pin = this.pendingHubUpdates.get(nonce);
1790
+ this.pendingHubUpdates.delete(nonce);
1791
+ const messageId = entry.messageId ?? data.messageId;
1792
+ const advice = pin ? this.hubRecommendationFor(pin) : null;
1793
+ if (!pin || !advice) {
1794
+ await this.retireNonceButtons(entry, messageId, t("hub_update.changed"));
1795
+ return true;
1796
+ }
1797
+ const by = data.userId ?? "";
1798
+ await this.retireNonceButtons(entry, messageId, t("update.progress.preparing", 0));
1799
+ if (messageId && entry.adapter)
1800
+ this.beginUpdateProgress(entry.adapter, entry.chatId, entry.threadId, messageId);
1801
+ await this.launchInstalledUpdate(`hub-recommended /update by ${adapterId}:${by}`, () => this.fleetAdminGate(by, adapterId) === "ok" && !this.shuttingDown && this.hubRecommendationFor(pin) !== null, advice.version);
1802
+ return true;
1803
+ }
1804
+ hubUpdates = null;
1805
+ hubUpdateOwned = null;
1806
+ hubUpdateBootProgress = null;
1807
+ pendingHubFleetUpdates = new Map();
1808
+ hubFleetUpdates() { return this.hubUpdates; }
1809
+ hubUpdateIdle() {
1810
+ if (!this.startupComplete || this.shuttingDown || this.reconcileInFlight || this.topicCleanupInFlight
1811
+ || this.deliveryPumpRunning || (this.webUpdateOwned && this.webUpdateOwned !== this.hubUpdateOwned?.claim))
1812
+ return false;
1813
+ for (const name of Object.keys(this.fleetConfig?.instances ?? {})) {
1814
+ if (this.restartsInFlight.has(name) || this.stopsInFlight.has(name) || this.handOffsInFlight.has(name)
1815
+ || this.ipcConnectInFlight.has(name) || this.ipcReconnectInFlight.has(name) || this.hasPendingIdleGatedDelivery(name)
1816
+ || this.webChannelEchoTails.has(name))
1817
+ return false;
1818
+ const worker = this.queueWorkers.get(name);
1819
+ if (worker?.busy || worker?.inFlight)
1820
+ return false;
1821
+ const process = this.getInstanceStatus(name);
1822
+ if (process === "stopped" || process === "crashed")
1823
+ continue;
1824
+ if (process === "paused" && ["stopped", "crashed"].includes(this.daemons.get(name)?.getProcessStatus?.() ?? "unknown"))
1825
+ continue;
1826
+ if (process !== "running" || this.getInstanceExecutionState(name) !== "idle")
1827
+ return false;
1828
+ if (this.getInstanceInteraction(name)?.phase === "waiting")
1829
+ return false;
1830
+ }
1831
+ return true;
1832
+ }
1833
+ async hubUpdateCanInstall() {
1834
+ const found = await npmForRunningInstall();
1835
+ if ("reason" in found)
1836
+ return false;
1837
+ const { access } = await import("node:fs/promises"), { constants } = await import("node:fs");
1838
+ try {
1839
+ await access(found.root, constants.W_OK);
1840
+ await access(found.prefix, constants.W_OK);
1841
+ return true;
1842
+ }
1843
+ catch {
1844
+ return false;
1845
+ }
1846
+ }
1847
+ async launchHubUpdate(row, control) {
1848
+ if (this.shuttingDown || this.webUpdateOwned || isUpdateInProgress(this.dataDir) || !control.current())
1849
+ return false;
1850
+ const claim = { startedAt: Date.now() }, owned = { id: row.id, claim };
1851
+ this.hubUpdateOwned = owned;
1852
+ this.webUpdateOwned = claim;
1853
+ const release = () => { if (this.hubUpdateOwned === owned)
1854
+ this.hubUpdateOwned = null; if (this.webUpdateOwned === claim)
1855
+ this.webUpdateOwned = null; };
1856
+ if (!persistUpdateProgress(this.dataDir, { ...webUpdateTarget(claim.startedAt), messageId: `hub-fleet-update:${row.id}` }, claim.startedAt)
1857
+ || !setUpdateProgressStage(this.dataDir, "preparing", { version: row.version })) {
1858
+ release();
1859
+ return false;
1860
+ }
1861
+ try {
1862
+ const child = await this.launchInstalledUpdate(`Hub-requested update ${row.id}`, () => !this.shuttingDown && this.hubUpdateOwned === owned && control.current() && control.claim(), row.version);
1863
+ if (!child) {
1864
+ release();
1865
+ return false;
1866
+ }
1867
+ let endedOnce = false;
1868
+ const ended = () => {
1869
+ if (endedOnce)
1870
+ return;
1871
+ endedOnce = true;
1872
+ const settle = () => {
1873
+ if (this.shuttingDown || this.hubUpdateOwned !== owned)
1874
+ return;
1875
+ // systemd-run may exit before its independent updater. Keep the claim while its bounded marker is active.
1876
+ const marker = readUpdateProgress(this.dataDir)?.progress;
1877
+ if (marker?.target.messageId === `hub-fleet-update:${row.id}` && isUpdateInProgress(this.dataDir)) {
1878
+ const timer = setTimeout(settle, 5000);
1879
+ timer.unref();
1880
+ return;
1881
+ }
1882
+ release();
1883
+ const outcome = this.hubUpdateOutcome(row);
1884
+ if (outcome)
1885
+ this.hubUpdates?.complete(row.id, outcome.state, outcome.currentVersion, "interrupted");
1886
+ };
1887
+ settle();
1888
+ };
1889
+ child.once("exit", ended);
1890
+ child.once("error", ended);
1891
+ return true;
1892
+ }
1893
+ catch {
1894
+ release();
1895
+ return false;
1896
+ }
1897
+ }
1898
+ hubUpdateOutcome(row) {
1899
+ if (!this.startupComplete || this.hubUpdateOwned?.id === row.id)
1900
+ return null;
1901
+ const currentVersion = this.runningAgendVersion();
1902
+ if (currentVersion.replace(/^v/, "") === row.version.replace(/^v/, ""))
1903
+ return { state: "done", currentVersion };
1904
+ const matches = (m) => m?.progress.target.messageId === `hub-fleet-update:${row.id}` && m.progress.version === row.version;
1905
+ const saved = readUpdateProgress(this.dataDir);
1906
+ // Startup may clear the ordinary progress marker before the optional Hub mount finishes.
1907
+ const marker = (matches(saved) ? saved : matches(this.hubUpdateBootProgress) ? this.hubUpdateBootProgress : null)?.progress;
1908
+ const reachedRestart = marker && (["installed", "stopping", "starting", "complete"].includes(marker.stage)
1909
+ || marker.stage === "failed" && (marker.failedStage === "starting" || marker.failedStage === "stopping"));
1910
+ return { state: reachedRestart ? "rolled-back" : "failed", currentVersion };
1911
+ }
1912
+ recordHubUpdateNotice(n) {
1913
+ const store = this.webNoticeStore();
1914
+ if (!store)
1915
+ return false;
1916
+ const text = t(`hub_fleet_update.${n.state}`, n.hubName, n.requestedBy, n.version, n.currentVersion ?? "");
1917
+ const prior = store.view().items.some(i => i.hubUpdate?.requestId === n.requestId && i.hubUpdate.state === n.state);
1918
+ const notice = store.addDurable({ kind: "update", text, hubUpdate: n });
1919
+ if (!notice)
1920
+ return false;
1921
+ this.emitSseEvent("notice", { notice, unread: store.unread() });
1922
+ if (!prior && !this.webOnlyPromptPlace())
1923
+ void this.postHubUpdateChat(n, text).catch(() => this.logger.warn("Hub update owner chat notice could not be posted"));
1924
+ return true;
1925
+ }
1926
+ async postHubUpdateChat(n, text) {
1927
+ const general = this.findGeneralInstance();
1928
+ if (!general)
1929
+ return;
1930
+ if (n.state !== "waiting" && n.state !== "expired") {
1931
+ this.notifyInstanceTopic(general, text);
1932
+ return;
1933
+ }
1934
+ const adapter = this.getAdapterForInstance(general), adapterId = this.getInstanceAdapterId(general), chatId = this.getGroupIdForInstance(general);
1935
+ if (!adapter || !adapterId || !chatId)
1936
+ return;
1937
+ const threadId = String(this.fleetConfig?.instances[general]?.topic_id ?? "");
1938
+ const nonce = await this.postNonceButtonPromptOrThrow({ prefix: HUB_FLEET_UPDATE_CALLBACK_PREFIX, alertType: "tip", instanceName: general,
1939
+ adapter, adapterId, chatId, ...(threadId ? { threadId } : {}), message: text,
1940
+ choices: [{ action: "update", label: t("hub_update.button") }, ...(n.state === "waiting" ? [{ action: "cancel", label: t("hub_fleet_update.cancel") }] : [])],
1941
+ expiredText: t("hub_update.expired"), timeoutMs: 24 * 60 * 60_000 });
1942
+ this.pendingHubFleetUpdates.set(nonce, n.requestId);
1943
+ const timer = setTimeout(() => this.pendingHubFleetUpdates.delete(nonce), 24 * 60 * 60_000 + 60_000);
1944
+ timer.unref();
1945
+ }
1946
+ async handleHubFleetUpdateCallback(data, adapterId, adapter) {
1947
+ 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");
1948
+ if (claimed === null)
1949
+ return false;
1950
+ if (claimed === "consumed")
1951
+ return true;
1952
+ const nonce = data.callbackData.slice(HUB_FLEET_UPDATE_CALLBACK_PREFIX.length, HUB_FLEET_UPDATE_CALLBACK_PREFIX.length + 32);
1953
+ const id = this.pendingHubFleetUpdates.get(nonce);
1954
+ this.pendingHubFleetUpdates.delete(nonce);
1955
+ const owner = this.hubUpdates, value = id ? owner?.view(id) : null;
1956
+ await this.retireNonceButtons(claimed.entry, claimed.entry.messageId ?? data.messageId, t("hub_update.expired"));
1957
+ if (!id || !owner || !value)
1958
+ return true;
1959
+ if (claimed.action === "cancel")
1960
+ owner.cancel({ id, version: value.version });
1961
+ else
1962
+ await this.startHubRequestedUpdateOnce(`chat:${nonce}`, `${adapterId}:${data.userId}`, () => this.fleetAdminGate(data.userId ?? "", adapterId) === "ok" && !this.shuttingDown, id);
1963
+ return true;
1964
+ }
1674
1965
  hubPairingNotices = null;
1675
1966
  hubMemberPairing() { return this.hubMemberPairingApi; }
1676
1967
  /** Explicit owner Settings read only. A paused binding is not permission to mount or connect a member. */
@@ -2194,6 +2485,7 @@ export class FleetManager {
2194
2485
  hubRuntimeCreated() {
2195
2486
  this.hubRuntimeInit ??= (async () => {
2196
2487
  const { HubRuntime } = await import("./hub/runtime.js");
2488
+ const { verifyRoomReceipt } = await import("./hub/member/room-post-receipt.js");
2197
2489
  // M-2682: the one writer for sealed Hub settings (a rename from Hub Administration). It saves hub.* through this
2198
2490
  // fleet's own synchronous writer, so nothing else here runs between its commit point and the new pair in force.
2199
2491
  const { createHubSettingsWriter } = await import("./hub/settings-commit.js");
@@ -2262,9 +2554,34 @@ export class FleetManager {
2262
2554
  inboxDir: agent => isSafeInstanceDirName(agent) ? join(this.dataDir, "workspaces", agent, "inbox") : null,
2263
2555
  scratchDir: agent => isSafeInstanceDirName(agent) ? join(this.dataDir, "workspaces", agent, "hub-files") : null },
2264
2556
  attachReports: (handler, failed) => { this.hubReports = handler; this.hubDeliveryFailed = failed; },
2557
+ attachPrivateQuestions: read => { this.hubPrivateQuestions = read; },
2558
+ attachReacts: handler => { this.hubReacts = handler; },
2265
2559
  },
2560
+ attachAgentRooms: port => { this.hubAgentRooms = port; this.notifyHubRoomTools(); },
2561
+ roomToolsChanged: () => this.notifyHubRoomTools(),
2562
+ roomConversationGeneration: agent => this.daemons.get(agent)?.roomConversationGeneration() ?? null,
2563
+ attachRoomInputs: handler => { this.hubRoomInput = handler; },
2564
+ roomNotify: input => this.deliverHubRoomNotification(input),
2565
+ roomReceipt: (caller, receiptId) => verifyRoomReceipt({
2566
+ lookup: (agent, id) => {
2567
+ const item = this.queryDurableDeliveryStatus(agent, { messageId: id }).items[0];
2568
+ if (item?.message_id !== id || !item.authority)
2569
+ return null;
2570
+ const row = this.deliveryOutbox?.getHumanReceipt(id.slice(5));
2571
+ return row ? { row, authority: item.authority } : null;
2572
+ },
2573
+ admin: (agent, actor) => actor.adapter_id === HOST_OPERATOR.adapterId && actor.user_id === HOST_OPERATOR.userId
2574
+ ? this.isWebOnlyFleet()
2575
+ : this.getInstanceAdapterId(agent) === actor.adapter_id && this.isFleetAdmin(actor.user_id, actor.adapter_id),
2576
+ }, caller.agent, receiptId),
2266
2577
  attachExposures: api => this.attachHubMemberExposures(api),
2267
2578
  attachAttention: read => this.attachHubExecutionAttention(read),
2579
+ updates: { idle: () => this.hubUpdateIdle(), busy: () => !!this.webUpdateOwned || isUpdateInProgress(this.dataDir),
2580
+ canInstall: () => this.hubUpdateCanInstall(), launch: (row, control) => this.launchHubUpdate(row, control),
2581
+ active: id => this.hubUpdateOwned?.id === id, outcome: row => this.hubUpdateOutcome(row), notify: n => this.recordHubUpdateNotice(n) },
2582
+ attachUpdates: updates => { this.hubUpdates = updates; },
2583
+ attachRecommendations: read => { this.hubRecommendationRead = read; },
2584
+ recommendationChanged: () => this.hubRecommendationChanged(),
2268
2585
  attachPairingNotices: read => { this.hubPairingNotices = read; },
2269
2586
  pokeAttention: () => this.needsYou?.poke(),
2270
2587
  linkState: (state, digest) => { this.hubMemberLink = state; this.hubMemberLinkBinding = digest ?? null; },
@@ -2340,12 +2657,70 @@ export class FleetManager {
2340
2657
  * delivery addresses, General included, shown by its display name. The dedicated Hub daemon is not a fleet instance.
2341
2658
  */
2342
2659
  hubMemberAgents() {
2343
- return Object.keys(this.fleetConfig?.instances ?? {}).map(name => ({ name, display: this.shownInstanceName(name) }));
2660
+ const classicNames = new Set((this.classicChannels?.getAll() ?? []).map(ch => ch.instanceName));
2661
+ const fleet = Object.keys(this.fleetConfig?.instances ?? {}).filter(name => !classicNames.has(name)).map(name => ({ name, display: this.shownInstanceName(name) }));
2662
+ return [...fleet, ...(this.classicChannels?.getAll() ?? []).filter(ch => !Object.hasOwn(this.fleetConfig?.instances ?? {}, ch.instanceName))
2663
+ .map(ch => ({ name: ch.instanceName, display: ch.displayName || ch.name, kind: "classic-room" }))];
2664
+ }
2665
+ /** The actual launch target, including Classic's own effective backend/folder; never aliases a room to a Fleet topic. */
2666
+ hubAgentConfig(agent) {
2667
+ const instances = this.fleetConfig?.instances ?? {};
2668
+ const room = this.classicChannels?.getAll().find(ch => ch.instanceName === agent);
2669
+ if (Object.hasOwn(instances, agent))
2670
+ return room ? null : instances[agent];
2671
+ return room ? { ...DEFAULT_INSTANCE_CONFIG, ...this.fleetConfig?.defaults,
2672
+ backend: this.classicChannels.getBackendByInstance(agent, this.fleetConfig?.defaults?.backend), working_directory: this.classicWorkspaceDir(agent),
2673
+ hubClassicIdentity: JSON.stringify([room.adapterId ?? "", room.channelId]) } : null;
2674
+ }
2675
+ hubClassicPrivacy = null;
2676
+ classicPrivacy() { return this.hubClassicPrivacy ??= new HubClassicPrivateTurns(join(this.dataDir, "hub-classic-private.json")); }
2677
+ /** The mark outlives registration: a late tool from a removed room must not fall through to General. */
2678
+ classicHubPrivateBlocked(agent) { return !!this.dataDir && this.classicPrivacy().blocked(agent); }
2679
+ classicHubSerialized(agent) {
2680
+ if (this.classicHubPrivateBlocked(agent))
2681
+ return true;
2682
+ if (!this.isClassicInstance(agent))
2683
+ return false;
2684
+ try {
2685
+ return this.hubMemberExposureApi?.list().some(row => row.agent === agent && row.state !== "withdrawn") ?? false;
2686
+ }
2687
+ catch {
2688
+ return true;
2689
+ }
2690
+ }
2691
+ hubPrivateQuestions = null;
2692
+ classicRoomPersonInput(agent, payload) {
2693
+ const meta = payload.meta;
2694
+ return (this.isClassicInstance(agent) || this.classicHubPrivateBlocked(agent)) && payload.type === "fleet_inbound" && !!meta && typeof meta.chat_id === "string" && !!meta.chat_id
2695
+ && typeof meta.user_id === "string" && !!meta.user_id && !meta.from_instance && !meta.is_cross_instance;
2696
+ }
2697
+ /** Prepare a public handoff without opening output until IPC accepts that exact input. */
2698
+ async prepareClassicForPerson(agent, payload, epoch, current) {
2699
+ if (!this.classicRoomPersonInput(agent, payload))
2700
+ return null;
2701
+ while (this.classicHubPrivateBlocked(agent)) {
2702
+ if (this.shuttingDown || !this.deliveryCurrent(agent, epoch, current))
2703
+ return false;
2704
+ const row = this.classicPrivacy().read(agent);
2705
+ if (!row)
2706
+ return false;
2707
+ const idle = await this.waitForInstanceIdle(agent, 60_000, Math.max(row.since + 1, Date.now()), () => !this.deliveryCurrent(agent, epoch, current));
2708
+ if (!this.deliveryCurrent(agent, epoch, current))
2709
+ return false;
2710
+ let pending = true;
2711
+ try {
2712
+ pending = this.hubPrivateQuestions?.(agent) ?? false;
2713
+ }
2714
+ catch { /* An unreadable journal never grants public output. */ }
2715
+ if (idle && !pending && this.classicPrivacy().read(agent)?.token === row.token)
2716
+ return row.token;
2717
+ }
2718
+ return null;
2344
2719
  }
2345
2720
  /** Same cached usage source as the owner's rail, scoped to the representative's CLI and credential profile. */
2346
2721
  async hubAgentQuota(agent) {
2347
2722
  const binding = () => {
2348
- const config = this.fleetConfig?.instances[agent];
2723
+ const config = this.hubAgentConfig(agent);
2349
2724
  if (!config || isWindowsInstance(config))
2350
2725
  return null; // runner usage never belongs to a Linux login
2351
2726
  const backend = this.backendNameForInstance(agent), provider = usageProviderIdForBackend(backend);
@@ -2377,15 +2752,15 @@ export class FleetManager {
2377
2752
  * earlier consent never matches again without an explicit republish. Stopping or pausing changes nothing.
2378
2753
  */
2379
2754
  hubAgentToken(agent) {
2380
- const instances = this.fleetConfig?.instances ?? {};
2381
- if (!Object.prototype.hasOwnProperty.call(instances, agent))
2755
+ const config = this.hubAgentConfig(agent);
2756
+ if (!config)
2382
2757
  return null;
2383
2758
  if (this.hubIncarnationsBroken)
2384
2759
  return null;
2385
2760
  let id;
2386
2761
  try {
2387
2762
  this.settleHubIncarnations();
2388
- id = this.hubIncarnationsBroken ? null : this.hubAgentIncarnation(agent, instances[agent], true);
2763
+ id = this.hubIncarnationsBroken ? null : this.hubAgentIncarnation(agent, config, true);
2389
2764
  }
2390
2765
  catch (err) {
2391
2766
  this.logger.warn({ err: err?.message, agent }, "Hub agent incarnation could not be saved; the agent is not a deliverable representative");
@@ -2486,13 +2861,13 @@ export class FleetManager {
2486
2861
  }
2487
2862
  /** The agent's durable incarnation id (create: make one if none; else null). A changed fingerprint rotates it. */
2488
2863
  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");
2864
+ 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
2865
  const map = this.readHubIncarnations(), entry = Object.prototype.hasOwnProperty.call(map, agent) ? map[agent] : undefined;
2491
2866
  if (entry && entry.fp === fp && typeof entry.id === "string")
2492
2867
  return entry.id;
2493
2868
  if (!entry && !create)
2494
2869
  return null;
2495
- map[agent] = { id: randomUUID(), fp };
2870
+ map[agent] = { id: randomUUID(), fp, ...(cfg.hubClassicIdentity ? { classic: true } : {}) };
2496
2871
  // A rotation that could only clear the file still invalidated the old id durably; the new one is made next time.
2497
2872
  return this.writeHubIncarnations(map) === "written" ? map[agent].id : null;
2498
2873
  }
@@ -2512,12 +2887,12 @@ export class FleetManager {
2512
2887
  throw new Error("Hub agent incarnations cannot be written here");
2513
2888
  if (!existsSync(this.hubIncarnationsPath()))
2514
2889
  return;
2515
- const instances = this.fleetConfig.instances;
2516
2890
  for (const agent of Object.keys(this.readHubIncarnations())) {
2517
2891
  // 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
2892
+ const config = this.hubAgentConfig(agent);
2893
+ if (config)
2894
+ this.hubAgentIncarnation(agent, config, false);
2895
+ else if (this.classicChannels || this.readHubIncarnations()[agent]?.classic !== true)
2521
2896
  this.forgetHubAgentIncarnation(agent, true);
2522
2897
  }
2523
2898
  }
@@ -2544,16 +2919,22 @@ export class FleetManager {
2544
2919
  throw new Error(`Hub consent for ${agent} could not be invalidated durably; refusing the change (${err?.message})`);
2545
2920
  }
2546
2921
  }
2922
+ hubContactWindows = null;
2923
+ contactWindows() {
2924
+ return this.hubContactWindows ??= new HubContactWindows(join(this.dataDir, "hub-contact-windows.json"));
2925
+ }
2926
+ hubContactRestricted(agent) { return this.contactWindows().restricted(agent); }
2547
2927
  /**
2548
2928
  * A Hub question to its representative agent: ordinary cross-instance delivery (idle gate, wake, retries), from the
2549
2929
  * reserved Hub sender with the Hub-issued correlation id. beforeInput runs immediately before the IPC hand-off.
2550
2930
  */
2551
2931
  async deliverHubQuestion(input) {
2552
2932
  const { HUB_REPORT_TARGET } = await import("./hub/representative.js");
2553
- if (this.shuttingDown || !this.fleetConfig?.instances[input.agent])
2933
+ const config = this.hubAgentConfig(input.agent);
2934
+ if (this.shuttingDown || !config)
2554
2935
  return false;
2555
2936
  // 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]))
2937
+ if (isNativeExecInstance(config))
2557
2938
  return false;
2558
2939
  const ipcMeta = {
2559
2940
  chat_id: "",
@@ -2569,7 +2950,37 @@ export class FleetManager {
2569
2950
  requires_reply: "true",
2570
2951
  task_summary: "A question from the Hub",
2571
2952
  };
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 });
2953
+ if (input.roomContextGeneration)
2954
+ ipcMeta.hub_room_context_generation = input.roomContextGeneration;
2955
+ 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 () => {
2956
+ const classic = this.isClassicInstance(input.agent);
2957
+ // A busy Classic room must finish its public turn first; never force a private question into that turn's queue.
2958
+ const idle = () => this.waitForInstanceIdle(input.agent, 0, this.lastDeliveryAt.get(input.agent) ?? 0, () => !input.stillCurrent());
2959
+ if (classic && !await idle())
2960
+ return false;
2961
+ if (!(await input.beforeInput()))
2962
+ return false;
2963
+ if (classic) {
2964
+ if (!await idle())
2965
+ return false;
2966
+ this.classicPrivacy().begin(input.agent, input.correlationId);
2967
+ }
2968
+ // Before any possible IPC exposure. An uncertain write retains the window, never replays the question.
2969
+ if (input.contactLimit !== false)
2970
+ this.contactWindows().begin(input.agent, input.correlationId);
2971
+ return input.stillCurrent();
2972
+ } });
2973
+ return result !== false;
2974
+ }
2975
+ async deliverHubRoomNotification(input) {
2976
+ const { HUB_REPORT_TARGET } = await import("./hub/representative.js");
2977
+ if (this.shuttingDown || !this.fleetConfig?.instances[input.agent] || isNativeExecInstance(this.fleetConfig.instances[input.agent]))
2978
+ return false;
2979
+ const prefix = input.kind === "mention-feedback" ? "hub-room-mention-feedback" : "hub-room-post-answer";
2980
+ const result = await this.deliverToInstance(input.agent, { type: "fleet_inbound", targetSession: input.agent, content: input.text,
2981
+ meta: { chat_id: "", message_id: `${prefix}-${input.id}`, user: `instance:${HUB_REPORT_TARGET}`, user_id: `instance:${HUB_REPORT_TARGET}`,
2982
+ ts: new Date().toISOString(), thread_id: "", from_instance: HUB_REPORT_TARGET, from_display: "Hub", correlation_id: `${prefix}-${input.id}`,
2983
+ 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
2984
  return result !== false;
2574
2985
  }
2575
2986
  /** 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 +2989,11 @@ export class FleetManager {
2578
2989
  }
2579
2990
  hubBrowserCertificate() { return this.hubRuntime?.browserCertificateSettings() ?? null; }
2580
2991
  hubRetention() { return this.hubRuntime?.retentionSettings() ?? null; }
2992
+ /** M-3281: the archived chat files, for Settings (their size limit: what is kept, what a lower one removes). */
2993
+ chatArchiveFiles() {
2994
+ const archive = this.webChatArchive;
2995
+ return archive ? { usage: (capBytes) => archive.filesUsage(capBytes), enforce: () => archive.enforceFilesCap({ exact: true }) } : null;
2996
+ }
2581
2997
  /** M-2682: an unfinished sealed-settings commit; Hub setting saves wait until recover() has run. */
2582
2998
  hubSettingsBusy() { return this.hubSettingsWriter?.pending() === true || this.hubSetupController?.pending() === true; }
2583
2999
  /** #3298 S-89: this fleet's own Hub offers group permissions (the page mark that shows Settings → Hub's Group permissions row). */
@@ -2673,10 +3089,48 @@ export class FleetManager {
2673
3089
  hubMemberLinkBinding = null;
2674
3090
  /** OutboundContext: the Hub representative's answer hook (null: no member service running, or not a Hub answer). */
2675
3091
  hubReport(input) {
2676
- return this.hubReports?.(input) ?? null;
3092
+ const result = this.hubReports?.(input) ?? null;
3093
+ if (!result)
3094
+ return null;
3095
+ return result.then(outcome => {
3096
+ if (outcome.ok) {
3097
+ try {
3098
+ this.contactWindows().answered(input.caller, input.correlationId);
3099
+ }
3100
+ catch (err) {
3101
+ this.logger.warn({ err }, "Hub contact window could not be closed; it will expire");
3102
+ }
3103
+ }
3104
+ return outcome;
3105
+ });
3106
+ }
3107
+ /** M-3127 OutboundContext: an agent's `react` on a Hub room question (its correlation id as message_id); null: not one. */
3108
+ hubReact(input) {
3109
+ return this.hubReacts?.(input) ?? null;
2677
3110
  }
3111
+ hubReacts = null;
2678
3112
  /** The member side's pane-failure hook for a Hub-issued correlation id (else null). */
3113
+ hubRoomInput = null;
2679
3114
  hubDeliveryFailed = null;
3115
+ /** The connected member adapter; never an agent-selectable identity. */
3116
+ hubAgentRooms = null;
3117
+ hubRoomToolsAvailable() { return this.hubAgentRooms?.available() === true; }
3118
+ hubRoomList(caller) {
3119
+ return this.hubAgentRooms?.rooms(caller) ?? Promise.resolve({ ok: false, code: "unavailable" });
3120
+ }
3121
+ hubRoomMembers(caller, room) {
3122
+ return this.hubAgentRooms?.members(caller, room) ?? Promise.resolve({ ok: false, code: "unavailable" });
3123
+ }
3124
+ hubPeopleSearch(caller, q) {
3125
+ return this.hubAgentRooms?.people(caller, q) ?? Promise.resolve({ ok: false, code: "unavailable" });
3126
+ }
3127
+ hubRoomPost(caller, value) {
3128
+ return this.hubAgentRooms?.post(caller, value) ?? Promise.resolve({ ok: false, code: "unavailable" });
3129
+ }
3130
+ notifyHubRoomTools() {
3131
+ for (const ipc of this.instanceIpcClients.values())
3132
+ ipc.send({ type: "hub_room_tools_changed" });
3133
+ }
2680
3134
  /** The member side's report_result hook for HUB_REPORT_TARGET while a representative service runs (else null). */
2681
3135
  hubReports = null;
2682
3136
  /** The one in-flight creation (single flight): overlapping first observations share it, Stop waits for it. */
@@ -2770,6 +3224,8 @@ export class FleetManager {
2770
3224
  livenessGone = new Map();
2771
3225
  /** #3647: when each instance last showed working (after the startup grace): activity for "quiet". */
2772
3226
  lastWorkingAt = new Map();
3227
+ /** M-3239: the instances whose progress is read from their transcript (see cacheInstanceExecutionState). */
3228
+ livenessTurnEvidence = new Set();
2773
3229
  dispatcherLiveness = null;
2774
3230
  /** Adapters whose last slash command registration failed and General was told (#1131). */
2775
3231
  slashRegistrationFailed = new Set();
@@ -2867,6 +3323,9 @@ export class FleetManager {
2867
3323
  pendingNonceButtons = new Map();
2868
3324
  /** #2598 B2: the kiro moves waiting on a fleet admin's Confirm in General, by prompt nonce. */
2869
3325
  pendingKiroMigrations = new Map();
3326
+ /** M-3140: a posted Hub-update notice's advice (by its nonce) — which advice the button was offered for. */
3327
+ pendingHubUpdates = new Map();
3328
+ hubUpdateNoticeBusy = false;
2870
3329
  pendingKiroReconciliations = new Map();
2871
3330
  kiroMigrationRuns = new Map();
2872
3331
  /** #1386 "Needs you": the list, its live chat messages and Acknowledge. Started with the fleet (finishStartup). */
@@ -3040,6 +3499,8 @@ export class FleetManager {
3040
3499
  webChatHistory = new WebChatHistory();
3041
3500
  /** #1565: the web chat history's files (set at fleet start, once the home and the instances are known). */
3042
3501
  webChatStore = null;
3502
+ /** M-3272: the archive past each agent's 500-message web chat window (web-chat-archive.ts). */
3503
+ webChatArchive = null;
3043
3504
  /** #2293: the dashboard's global search (null: web.search.enabled is false, or the fleet has not started). */
3044
3505
  searchIndex = null;
3045
3506
  /** Uploaded files and the files the dashboard may fetch back (uploads, reply attachments). */
@@ -3188,6 +3649,9 @@ export class FleetManager {
3188
3649
  officeStoreInstance;
3189
3650
  /** Fleet → Org chart → Office: the offices people made (web-offices.json, beside web-themes.json). */
3190
3651
  get officeStore() { return (this.officeStoreInstance ??= new OfficeStore(this.dataDir, id => this.officeSkins.pack(id))); }
3652
+ pinStoreInstance;
3653
+ /** M-3271: pinned chat messages per agent (web-pins.json, beside web-themes.json). */
3654
+ get pinStore() { return (this.pinStoreInstance ??= new WebPinStore(this.dataDir)); }
3191
3655
  officeSkinsInstance;
3192
3656
  /** #2513: the Office view's uploaded skin packs (<AGEND_HOME>/web-office-skins/). */
3193
3657
  get officeSkins() { return (this.officeSkinsInstance ??= new OfficeSkinStore(this.dataDir)); }
@@ -3521,6 +3985,7 @@ export class FleetManager {
3521
3985
  settingsRuntimeRevision = 0;
3522
3986
  settingsConfirmation = null;
3523
3987
  settingsControl = null;
3988
+ ownerAppControl = null;
3524
3989
  settingsJobSettlements = new Map();
3525
3990
  classicSettingsOwners = new WeakMap();
3526
3991
  queueSettingsOperation(job, resources, execution, run) {
@@ -3637,7 +4102,9 @@ export class FleetManager {
3637
4102
  return null;
3638
4103
  const record = auth.session, sessions = this.webSessions, exposure = gatewayRequestContext(req);
3639
4104
  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,
4105
+ // M-3278 (decision 7933bf90): an admin session on any listener, the public link's too (its exposure still
4106
+ // current: `current` below; a closed link's sessions are revoked with it).
4107
+ localAdmin: () => record.tier === "admin" && (!exposure || exposure.isCurrent()),
3641
4108
  current: () => current() && sessions === this.webSessions && !!this.webToken
3642
4109
  && sessions.isCurrent(record, tokenEpoch(this.webToken)) && (!exposure || exposure.isCurrent()) };
3643
4110
  }, baseline: () => baselines.read(), snapshot: () => baselines.snapshot(),
@@ -3892,8 +4359,8 @@ export class FleetManager {
3892
4359
  return null;
3893
4360
  if (role.account && !this.settingsAccountMayConfirm(store, id, role.actor))
3894
4361
  return null;
3895
- if (store.opensLink(id) && gatewayRequestContext(req))
3896
- return null;
4362
+ // M-3278 (decision 7933bf90, the leader's (a)): a verified admin over a link confirms a change that opens a link too, as
4363
+ // by Apply now; the role decides (its link option, Only this computer, the strict switch), and a Notice is posted.
3897
4364
  return { handle, actor: role.actor, account: role.account };
3898
4365
  };
3899
4366
  const first = check(true);
@@ -3943,8 +4410,6 @@ export class FleetManager {
3943
4410
  return null;
3944
4411
  if (role.account && !this.settingsAccountMayConfirm(store, id, role.actor))
3945
4412
  return null;
3946
- if (store.opensLink(id) && gatewayRequestContext(req))
3947
- return "on_host";
3948
4413
  return this.webRemoteAccess()?.isEnrolled(adminKey(role.actor.adapter_id, role.actor.user_id)) ? "ready" : "not_set_up";
3949
4414
  }
3950
4415
  /**
@@ -4775,6 +5240,45 @@ export class FleetManager {
4775
5240
  throw err;
4776
5241
  }
4777
5242
  }
5243
+ /** A person's local app gets a private, read/chat-only surface, never an instance's tool permissions. */
5244
+ async startOwnerAppControl() {
5245
+ if (this.shuttingDown || this.ownerAppControl)
5246
+ return;
5247
+ const [{ OwnerAppControl }, { createOwnerAppService }] = await Promise.all([import("./connect/control.js"), import("./connect/service.js")]);
5248
+ if (this.shuttingDown || this.ownerAppControl)
5249
+ return;
5250
+ const service = createOwnerAppService({
5251
+ current: () => !this.shuttingDown && !!this.fleetConfig,
5252
+ agents: () => Object.entries(this.fleetConfig?.instances ?? {}).map(([name, config]) => ({ name,
5253
+ display_name: config.display_name, backend: config.backend ?? "claude-code", status: this.getInstanceStatus(name) })),
5254
+ identity: name => this.fleetConfig?.instances[name],
5255
+ history: this.webChatHistory,
5256
+ board: () => this.scheduler?.db.board ?? null,
5257
+ deliver: async (name, text, messageId, current) => {
5258
+ if (!current())
5259
+ return false;
5260
+ const config = this.fleetConfig.instances[name];
5261
+ const adapter = this.getAdapterForInstance(name);
5262
+ const result = await this.deliverHumanToInstance(name, { type: "fleet_inbound", targetSession: name, content: text,
5263
+ meta: { chat_id: String(this.getGroupIdForInstance(name) ?? ""), thread_id: String(config.topic_id ?? ""),
5264
+ message_id: messageId, user: "Local app", user_id: "local-connector", source: "app", adapter_id: adapter?.id,
5265
+ ts: new Date().toISOString() } }, undefined, text, { stillCurrent: current, authorityCurrent: () => !this.shuttingDown && this.fleetConfig?.instances[name] === config });
5266
+ // No web-verified origin or human receipt authority is manufactured for an external app.
5267
+ if (result !== false)
5268
+ this.emitSseEvent("message", { instance: name, sender: "Local app", role: "user", text, messageId, ts: new Date().toISOString() });
5269
+ return result;
5270
+ },
5271
+ });
5272
+ const control = this.ownerAppControl = new OwnerAppControl(this.dataDir, service);
5273
+ try {
5274
+ await control.listen();
5275
+ }
5276
+ catch (error) {
5277
+ if (this.ownerAppControl === control)
5278
+ this.ownerAppControl = null;
5279
+ throw error;
5280
+ }
5281
+ }
4778
5282
  get webToken() { return readWebToken(this.dataDir); }
4779
5283
  /**
4780
5284
  * Server-side web sessions (see web-session.ts). Created with the token, not per
@@ -5398,6 +5902,39 @@ export class FleetManager {
5398
5902
  claimedAt: Math.max(ms(board.lastChangeAt(c.uuid)), ms(c.startedAt)), updatedAt: ms(c.updatedAt),
5399
5903
  }));
5400
5904
  }
5905
+ /**
5906
+ * 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
5907
+ * (the boot shows working; a transcript line is real work, and the monitor starts at the transcript's end).
5908
+ */
5909
+ noteTurnActivity(name, at) {
5910
+ if (!Number.isFinite(at) || at > Date.now() + 60_000 || at < this.startedAt)
5911
+ return;
5912
+ if (at > (this.lastWorkingAt.get(name) ?? 0))
5913
+ this.lastWorkingAt.set(name, at);
5914
+ }
5915
+ /**
5916
+ * M-3239: an agent ended a turn without messaging anyone. If its final text asks a question and it holds a card
5917
+ * another agent handed it, that dispatcher is told, quoting the question — otherwise the question sits on the agent's
5918
+ * own screen and the card stalls (a beta.7 rehearsal waited 1.5 h on one).
5919
+ */
5920
+ onTurnEndedQuietly(name, startedAt, text) {
5921
+ if (this.shuttingDown || this.isPlannedRestart() || !livenessSettings(this.fleetConfig).enabled)
5922
+ return;
5923
+ const question = turnQuestion(text);
5924
+ if (!question)
5925
+ return;
5926
+ const outbox = this.deliveryOutbox;
5927
+ if (!outbox?.isOpen)
5928
+ return;
5929
+ const sent = outbox.latestSentAt(name);
5930
+ if (sent !== null && sent >= startedAt)
5931
+ return; // it did tell someone during the turn
5932
+ const isAgent = (d) => (this.fleetConfig?.instances?.[d] != null || this.isClassicInstance(d)) && !taskBoardOffIn(this.fleetConfig, d);
5933
+ for (const n of questionNotices(this.livenessCards(), name, question, startedAt, isAgent)) {
5934
+ this.admitTaskBoardNotice(n.dispatcher, n.message, n.key);
5935
+ this.logger.info({ assignee: name, dispatcher: n.dispatcher }, "Dispatcher told: assignee ended its turn on a question it sent no one");
5936
+ }
5937
+ }
5401
5938
  /** #3647: what the fleet knows about an assignee now; null when it is not an instance here. */
5402
5939
  livenessFacts(name) {
5403
5940
  if (this.fleetConfig?.instances?.[name] == null)
@@ -5427,6 +5964,9 @@ export class FleetManager {
5427
5964
  usageHold: this.daemons.get(name)?.usageHold?.() ?? null,
5428
5965
  execution: exec ? { state: exec.state, since: exec.stateChangedAt } : null,
5429
5966
  lastWorkingAt: this.lastWorkingAt.get(name) ?? null,
5967
+ turnEvidence: this.livenessTurnEvidence.has(name),
5968
+ // M-3239 (Fable F1): a restart forgets the transcript's progress; its quiet clock starts no earlier than the fleet.
5969
+ quietFloor: this.livenessTurnEvidence.has(name) ? this.startedAt : null,
5430
5970
  prompt: p.state === "awaiting_input" && p.interaction?.since ? { since: p.interaction.since } : null,
5431
5971
  waitingOn,
5432
5972
  // Asked only when it could be quiet (one indexed read per idle assignee).
@@ -6025,16 +6565,9 @@ export class FleetManager {
6025
6565
  this.tightenInstanceDirectories();
6026
6566
  // #1723: the public link's preview tunnel keeps its own lease beside it; a leftover one is reaped the same way (and
6027
6567
  // #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
- }
6568
+ // M-3247: this runs after auto_open (and a /web click) may already have opened this run's own tunnels; the sweep
6569
+ // spares leases this process wrote — it once killed the named link it had opened 10 s earlier.
6570
+ 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
6571
  // An existing installation has never written the setup marker — it predates
6039
6572
  // it — so `agend setup` would open a pre-fleet form for a fleet that plainly
6040
6573
  // exists. A fleet that just came up on a config with agents in it is proof
@@ -6444,7 +6977,7 @@ export class FleetManager {
6444
6977
  * independently with its log — or a failure in the progress marker. `stillAllowed` is asked again once the awaits
6445
6978
  * are done (the asker may have lost the right, or the fleet begun stopping, meanwhile).
6446
6979
  */
6447
- async launchInstalledUpdate(origin, stillAllowed) {
6980
+ async launchInstalledUpdate(origin, stillAllowed, pin) {
6448
6981
  const { spawn } = await import("./child-process.js");
6449
6982
  const installed = await resolveInstalledAgend();
6450
6983
  if (!installed.ok) {
@@ -6452,7 +6985,8 @@ export class FleetManager {
6452
6985
  return null;
6453
6986
  }
6454
6987
  recordInternalRequest(this.dataDir, "update", origin);
6455
- const launch = await resolveUpdateLaunch(installed.agend, undefined, installed.npmDir);
6988
+ // M-3140: `pin` — this exact version (a Hub's recommendation, re-resolved by the caller), not the install's channel.
6989
+ const launch = await resolveUpdateLaunch(installed.agend, undefined, installed.npmDir, pin);
6456
6990
  if (!launch.ok) {
6457
6991
  this.failUpdateProgress(`${t("update.failure.shell")} ${t("update.failure.independent", launch.reason)}`);
6458
6992
  return null;
@@ -7102,8 +7636,16 @@ export class FleetManager {
7102
7636
  // asks "is anyone still reporting", which only the receiver can date.
7103
7637
  receivedAt: now,
7104
7638
  });
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)
7639
+ // #3647: activity, for "quiet" — not the boot itself (every agent shows working while it starts). M-3239: an agent
7640
+ // whose transcript tells its turns (Claude, Codex) shows progress by its tool calls and answers, not by its pane's
7641
+ // spinner — Claude compacting its context on its own, idle, held off a stalled card's notice.
7642
+ if (msg.turnEvidence === true)
7643
+ this.livenessTurnEvidence.add(name);
7644
+ else if (msg.turnEvidence === false)
7645
+ this.livenessTurnEvidence.delete(name);
7646
+ if (typeof msg.turnActivityAt === "number")
7647
+ this.noteTurnActivity(name, msg.turnActivityAt);
7648
+ if (state === "working" && !this.livenessTurnEvidence.has(name) && now - this.startedAt >= LIVENESS_STARTUP_GRACE_MS)
7107
7649
  this.lastWorkingAt.set(name, now);
7108
7650
  // The dashboard's "working" line and its Stop button follow the edges, not the heartbeat.
7109
7651
  if (previous?.state !== state)
@@ -7348,7 +7890,8 @@ export class FleetManager {
7348
7890
  this.logger[log.level](log.fields, log.message);
7349
7891
  }
7350
7892
  // 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);
7893
+ const sent = await this.sendWhenConnected(instanceName, payload, deliveryEpoch, stillCurrent, onStartRetryHold, beforeInput ?? (this.classicHubPrivateBlocked(instanceName) && this.classicRoomPersonInput(instanceName, payload)
7894
+ ? async () => true : undefined));
7352
7895
  if (!sent)
7353
7896
  return false;
7354
7897
  if (this.deliveryCurrent(instanceName, deliveryEpoch, stillCurrent)) {
@@ -7424,10 +7967,26 @@ export class FleetManager {
7424
7967
  async handOffAfterBeforeInput(instanceName, payload, deliveryEpoch, stillCurrent, beforeInput) {
7425
7968
  if (!(await beforeInput()))
7426
7969
  return false;
7427
- if (this.shuttingDown || !this.deliveryCurrent(instanceName, deliveryEpoch, stillCurrent))
7970
+ const privateToken = await this.prepareClassicForPerson(instanceName, payload, deliveryEpoch, stillCurrent);
7971
+ if (privateToken === false || this.shuttingDown || !this.deliveryCurrent(instanceName, deliveryEpoch, stillCurrent))
7428
7972
  return false;
7429
7973
  const ipc = this.instanceIpcClients.get(instanceName);
7430
- return !!ipc?.connected && ipc.send(this.bindHumanReceiptPayload(instanceName, payload));
7974
+ if (!ipc?.connected || (privateToken && this.classicPrivacy().read(instanceName)?.token !== privateToken))
7975
+ return false;
7976
+ const sent = ipc.send(this.bindHumanReceiptPayload(instanceName, payload));
7977
+ if (sent && privateToken) {
7978
+ try {
7979
+ if (this.classicPrivacy().resume(instanceName, privateToken)) {
7980
+ this.instanceProgress.delete(instanceName);
7981
+ this.instanceActivity.delete(instanceName);
7982
+ }
7983
+ }
7984
+ catch (err) {
7985
+ // Input was accepted: never invite a duplicate. Keep output closed if its durable release fails.
7986
+ this.logger.warn({ err, instanceName }, "Classic room output remains private after the person input");
7987
+ }
7988
+ }
7989
+ return sent;
7431
7990
  }
7432
7991
  /** Poll for the instance's IPC to come back, then send. Throws if it does not. */
7433
7992
  async sendAfterIpcReturns(instanceName, payload, deliveryEpoch = this.getDeliveryEpoch(instanceName), stillCurrent, onStartRetryHold, beforeInput) {
@@ -7912,8 +8471,8 @@ export class FleetManager {
7912
8471
  const inferredCrossInstance = (typeof meta?.from_instance === "string" && meta.from_instance.length > 0)
7913
8472
  || meta?.is_cross_instance === true
7914
8473
  || payload.is_cross_instance === true;
7915
- const waitForIdle = options.waitForIdle
7916
- ?? ((options.isCrossInstance ?? inferredCrossInstance) || payload.type === "fleet_schedule_trigger");
8474
+ const waitForIdle = (this.classicHubSerialized(instanceName) && this.classicRoomPersonInput(instanceName, payload)) || (options.waitForIdle
8475
+ ?? ((options.isCrossInstance ?? inferredCrossInstance) || payload.type === "fleet_schedule_trigger"));
7917
8476
  if (!waitForIdle) {
7918
8477
  if (this.lifecycle.isPaused(instanceName)) {
7919
8478
  if (options.noInlineWake) {
@@ -8598,6 +9157,7 @@ export class FleetManager {
8598
9157
  const hasDaemon = this.daemons.has(instanceName);
8599
9158
  const wasRunning = hasDaemon || opts?.startIfStopped === true;
8600
9159
  this.classicChannels.reloadFromDisk();
9160
+ this.observeHubAgentIncarnations(true);
8601
9161
  this.reportClassicUnrecoverableIds();
8602
9162
  this.reregisterClassicChannels();
8603
9163
  const channel = this.classicChannels.getAll().find(item => item.instanceName === instanceName);
@@ -9895,6 +10455,22 @@ export class FleetManager {
9895
10455
  && this.getInstanceAdapterId(name) === owner.adapterId && String(this.getGroupIdForInstance(name) ?? "") === owner.chatId
9896
10456
  && cfg.topic_id?.toString() === owner.threadId);
9897
10457
  }
10458
+ /**
10459
+ * M-3163: the one General of `adapterId` (its group and topic) as `userId`'s code owner — where a returning device's new code is
10460
+ * meant for (#1570; requestReturningCode still checks it all again, with the live binding, before anything is sent). Null when
10461
+ * that connection has no General with a topic, or more than one.
10462
+ */
10463
+ generalOwnerOf(adapterId, userId) {
10464
+ const found = [];
10465
+ for (const [name, cfg] of Object.entries(this.fleetConfig?.instances ?? {})) {
10466
+ if (!cfg.general_topic || this.getInstanceAdapterId(name) !== adapterId)
10467
+ continue;
10468
+ const group = String(this.getGroupIdForInstance(name) ?? ""), topic = cfg.topic_id?.toString();
10469
+ if (group && topic)
10470
+ found.push({ adapterId, userId, chatId: group, threadId: topic });
10471
+ }
10472
+ return found.length === 1 ? found[0] : null;
10473
+ }
9898
10474
  /** Exact owning General. No primary-adapter or name fallback participates in authorization. */
9899
10475
  dashboardOwner(userId, adapterId, address, threadId, username) {
9900
10476
  const world = this.worlds.get(adapterId);
@@ -10141,7 +10717,8 @@ export class FleetManager {
10141
10717
  this.initializeWebSessions();
10142
10718
  // #1827: the code goes privately to this account (a DM, or else this slash command's ephemeral answer): whoever
10143
10719
  // 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 } : {}) } });
10720
+ // M-3277: private — a DM, else this slash command's ephemeral answer, else withdrawn (below): the session starts verified.
10721
+ const login = this.webLoginCodes.issue({ epoch: tokenEpoch(token), recipient: { adapterId, userId: data.userId, ...(data.username ? { username: data.username } : {}) }, private: true });
10145
10722
  const current = () => !this.shuttingDown && this.adapters.get(adapterId) === adapter
10146
10723
  && this.webToken === token && this.hasFleetAdmins(adapterId) && this.isFleetAdmin(data.userId, adapterId);
10147
10724
  const privateText = `${text}\n${t("dashboard.code", login.display, Math.round(LOGIN_CODE_TTL_MS / 60_000))}`;
@@ -10336,7 +10913,8 @@ export class FleetManager {
10336
10913
  if (!token || !current())
10337
10914
  return false;
10338
10915
  this.initializeWebSessions();
10339
- const issued = this.webLoginCodes.issue({ epoch: tokenEpoch(token), audience: exposureId, owner });
10916
+ // M-3277: private — the owner's DM, else (Discord) the click's ephemeral answer, else withdrawn below; never the menu itself.
10917
+ const issued = this.webLoginCodes.issue({ epoch: tokenEpoch(token), audience: exposureId, owner, private: true });
10340
10918
  // Only a public link has a link expiry (null: none — a named tunnel's ttl_minutes 0); the code's five-minute
10341
10919
  // lifetime applies to either packet.
10342
10920
  const minutes = Math.round(LOGIN_CODE_TTL_MS / 60_000);
@@ -10871,7 +11449,8 @@ export class FleetManager {
10871
11449
  }
10872
11450
  else if (input.exposureId !== undefined)
10873
11451
  return { kind: "refused" };
10874
- const issued = this.webLoginCodes.issue({ epoch: tokenEpoch(token), audience: input.exposureId ?? "local", owner });
11452
+ // M-3277: private — by DM only (withdrawn when that is not confirmed).
11453
+ const issued = this.webLoginCodes.issue({ epoch: tokenEpoch(token), audience: input.exposureId ?? "local", owner, private: true });
10875
11454
  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
11455
  try {
10877
11456
  await withinBudget(adapter.sendDirect(userId, text, { disablePreview: true }), performance.now() + 5_000);
@@ -11429,6 +12008,7 @@ export class FleetManager {
11429
12008
  // #1737 review: the marker this boot adopts — the startup clear may only ever clear this one.
11430
12009
  const bootUpdateMarker = updateMarkerIdentity(this.dataDir);
11431
12010
  const savedUpdateProgress = readUpdateProgress(this.dataDir);
12011
+ this.hubUpdateBootProgress = savedUpdateProgress;
11432
12012
  const pendingUpdateProgress = savedUpdateProgress
11433
12013
  && savedUpdateProgress.progress.stage !== "failed"
11434
12014
  && savedUpdateProgress.progress.stage !== "complete"
@@ -11559,6 +12139,7 @@ export class FleetManager {
11559
12139
  this.classicChannels = new ClassicChannelManager(this.dataDir, this.logger, this.getConfigHistory());
11560
12140
  const classicAdapters = fleet.channels?.length ? fleet.channels : (fleet.channel ? [fleet.channel] : []);
11561
12141
  this.classicChannels.configureAdapters(classicAdapters);
12142
+ this.observeHubAgentIncarnations();
11562
12143
  // The unrecoverable-id report is deliberately NOT sent here: no adapter
11563
12144
  // exists yet at this point in startAll(), so notifyFleetError would find
11564
12145
  // nothing to deliver through, drop the message silently, AND burn its
@@ -12118,7 +12699,7 @@ export class FleetManager {
12118
12699
  /**
12119
12700
  * #3066 §1: estimate each account's weekly 100% from the quota history (§1d) and the usage ledger's hours — both read
12120
12701
  * 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
12702
+ * "claude:work", "codex:team"): its hours are the ledger sources of that backend under that credential profile
12122
12703
  * (Codex's "unrecorded" hours are no account's). A per-model weekly ("Sonnet (weekly)") counts only that model's tokens.
12123
12704
  *
12124
12705
  * Prism #3073: no estimate rather than a wrong one —
@@ -12340,10 +12921,12 @@ export class FleetManager {
12340
12921
  * Delete inbox files older than retentionDays (by mtime). Cleans the shared
12341
12922
  * inbox (`<dataDir>/inbox`) and every workspace inbox
12342
12923
  * (`<agendHome>/workspaces/*\/inbox`). Piggybacks on the daily summary timer,
12343
- * mirroring classic chat-log rotation (same 7-day retention).
12924
+ * mirroring classic chat-log rotation (same 7-day retention). M-3281: never a file the web chat still shows.
12344
12925
  */
12345
12926
  rotateInboxes(retentionDays = 7) {
12346
12927
  const cutoff = Date.now() - retentionDays * 86400_000;
12928
+ // M-3281: a file the web chat still shows stays (device + inode), so it is there to keep when its message is archived.
12929
+ const shown = this.webFiles.shownFiles();
12347
12930
  const dirs = [join(this.dataDir, "inbox")];
12348
12931
  const workspacesDir = join(getAgendHome(), "workspaces");
12349
12932
  if (existsSync(workspacesDir)) {
@@ -12359,7 +12942,7 @@ export class FleetManager {
12359
12942
  const full = join(dir, file);
12360
12943
  try {
12361
12944
  const st = statSync(full);
12362
- if (st.isFile() && st.mtimeMs < cutoff) {
12945
+ if (st.isFile() && st.mtimeMs < cutoff && !shown.has(`${st.dev}:${st.ino}`)) {
12363
12946
  unlinkSync(full);
12364
12947
  deleted++;
12365
12948
  }
@@ -13060,6 +13643,10 @@ export class FleetManager {
13060
13643
  else if (msg.type === "instance_progress") {
13061
13644
  this.cacheInstanceProgress(name, msg.progress || null);
13062
13645
  }
13646
+ else if (msg.type === "hub_room_input") {
13647
+ if (this.instanceIpcClients.get(name) === ipc && typeof msg.correlationId === "string" && typeof msg.generation === "string")
13648
+ this.hubRoomInput?.(msg.correlationId, name, msg.generation);
13649
+ }
13063
13650
  else if (msg.type === "cross_instance_delivery_failed") {
13064
13651
  const senderSession = String(msg.senderSession ?? "");
13065
13652
  const targetInstance = String(msg.targetInstance ?? name);
@@ -13115,6 +13702,14 @@ export class FleetManager {
13115
13702
  waiter(msg);
13116
13703
  }
13117
13704
  }
13705
+ else if (msg.type === "turn_activity") {
13706
+ if (typeof msg.at === "number")
13707
+ this.noteTurnActivity(name, msg.at);
13708
+ }
13709
+ else if (msg.type === "turn_ended") {
13710
+ if (typeof msg.startedAt === "number" && typeof msg.text === "string")
13711
+ this.onTurnEndedQuietly(name, msg.startedAt, msg.text);
13712
+ }
13118
13713
  else if (msg.type === "instance_state" || msg.type === "instance_state_response") {
13119
13714
  this.cacheInstanceExecutionState(name, msg);
13120
13715
  if (msg.type === "instance_state_response") {
@@ -13387,7 +13982,7 @@ export class FleetManager {
13387
13982
  * A reaction is context, not a message (#432, reworking #413): it never triggers
13388
13983
  * an agent turn and never wakes anything. It is queued in the event log and rides
13389
13984
  * into the instance's NEXT real message as one compact leading line —
13390
- * `[Recent reactions: 👍×2 from hanhanv]` — after which it is marked consumed.
13985
+ * `[Recent reactions: 👍×2 from user1]` — after which it is marked consumed.
13391
13986
  * No pending reactions → no line → zero context spent, which is the common case.
13392
13987
  */
13393
13988
  async handleInboundReaction(r) {
@@ -13656,7 +14251,27 @@ export class FleetManager {
13656
14251
  }
13657
14252
  return true;
13658
14253
  }
13659
- /** File a Telegram update that was too old to inject; Needs you lists it until Acknowledge. */
14254
+ /**
14255
+ * Who a Telegram update that was too old to inject would have gone to live (handleInboundMessageCore), or null when live
14256
+ * delivery would not have taken it — then it is not "missed". A topic of the fleet group: its instance (an unbound topic
14257
+ * only gets the bind prompt live, so nobody). The fleet group's root: general ("" when none is configured). Any other chat
14258
+ * is a ClassicBot candidate: its registered room — in a group only when the message @mentions the bot — and otherwise
14259
+ * nobody (live, an unregistered chat is ignored, and an @mention there only gets the no-agent reply).
14260
+ */
14261
+ missedOfflineInstance(ev, stub) {
14262
+ const threadId = this.inboundRouteThreadId(stub);
14263
+ if (threadId)
14264
+ return this.resolveInboundTarget(stub, threadId)?.name ?? null;
14265
+ if (ev.chatId !== String(this.getChannelConfig(ev.adapterId)?.group_id ?? "")) {
14266
+ const room = this.classicChannels?.getInstanceByChannel(ev.chatId, ev.adapterId);
14267
+ if (!room)
14268
+ return null;
14269
+ const isPrivateChat = !ev.chatId.startsWith("-");
14270
+ return isPrivateChat || ev.mentionsBot ? room : null;
14271
+ }
14272
+ return Object.entries(this.fleetConfig?.instances ?? {}).find(([name, cfg]) => cfg.general_topic && this.getInstanceAdapterId(name) === ev.adapterId)?.[0] ?? "";
14273
+ }
14274
+ /** File a Telegram update that was too old to inject, where live delivery would have taken it; Needs you lists it until Acknowledge. */
13660
14275
  recordMissedOffline(ev) {
13661
14276
  if (!this.missedOfflineStore)
13662
14277
  this.missedOfflineStore = new MissedOfflineStore(this.dataDir);
@@ -13665,11 +14280,10 @@ export class FleetManager {
13665
14280
  messageId: ev.messageId, userId: ev.userId, username: ev.username, text: ev.preview,
13666
14281
  timestamp: ev.timestamp, isBotMessage: false,
13667
14282
  };
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] ?? "";
14283
+ const instance = this.missedOfflineInstance(ev, stub);
14284
+ if (instance === null) {
14285
+ 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");
14286
+ return;
13673
14287
  }
13674
14288
  const place = [ev.chatTitle, ev.threadId ? `#${ev.threadId}` : ""].filter(Boolean).join(" · ") || ev.chatId;
13675
14289
  this.missedOfflineStore.add({
@@ -14501,7 +15115,7 @@ export class FleetManager {
14501
15115
  // Above the adapter check on purpose: "retry shortly" is the wrong answer
14502
15116
  // to a call that will never be allowed, and an agent that believes it is a
14503
15117
  // timing problem will keep trying.
14504
- const permitted = this.checkToolPermission("ipc-outbound", instanceName, tool);
15118
+ const permitted = this.checkToolPermission("ipc-outbound", instanceName, tool === "hub_room_status" ? "hub_room_list" : tool);
14505
15119
  if (!permitted.allowed) {
14506
15120
  respond(null, permitted.message);
14507
15121
  return;
@@ -14516,6 +15130,31 @@ export class FleetManager {
14516
15130
  });
14517
15131
  return;
14518
15132
  }
15133
+ // M-3127: a reaction to a Hub room question (message_id = the correlation id it came with) goes to that room, under
15134
+ // the question — never to a chat. Only that question's agent; the same source-daemon fence as its Hub answer.
15135
+ if (tool === "react" && typeof args.message_id === "string" && /^hub-room-[0-9a-f-]{36}$/.test(args.message_id)) {
15136
+ const bootNow = this.getDaemonBootId(instanceName), bootSent = sourceDaemonBootId ?? bootNow;
15137
+ if (!bootNow || bootSent !== bootNow) {
15138
+ respond(null, "Source daemon generation is no longer current; outcome is unknown");
15139
+ return;
15140
+ }
15141
+ const claimed = this.hubReact({ correlationId: args.message_id, caller: instanceName, emoji: typeof args.emoji === "string" ? args.emoji : "",
15142
+ callerCurrent: () => this.getDaemonBootId(instanceName) === bootSent });
15143
+ if (!claimed) {
15144
+ respond(null, "That message_id is not a Hub room question you were asked.");
15145
+ return;
15146
+ }
15147
+ const outcome = await claimed;
15148
+ if (outcome.ok)
15149
+ respond("ok");
15150
+ else
15151
+ respond(null, outcome.message);
15152
+ return;
15153
+ }
15154
+ if (this.classicHubPrivateBlocked(instanceName) && usesChannelAddress(tool)) {
15155
+ respond(null, "This ClassicBot agent is handling private Hub input. Room output is blocked; answer the Hub with report_result.");
15156
+ return;
15157
+ }
14519
15158
  // #2305: a reaction to a web chat message is the web chat's own (any fleet, web-only included): never an adapter's.
14520
15159
  if (tool === "react" && typeof args.message_id === "string" && isWebMessageId(args.message_id)) {
14521
15160
  // The socket's own instance, never a session name the caller wrote itself (as checkToolPermission: it was not
@@ -14592,6 +15231,10 @@ export class FleetManager {
14592
15231
  // still in flight and about to succeed. One real send, everyone gets its
14593
15232
  // outcome; a genuinely failed send clears the entry so a retry passes.
14594
15233
  if (tool === "reply") {
15234
+ if (!replyPreviews(args.previews)) {
15235
+ respond(null, "reply: invalid previews");
15236
+ return;
15237
+ }
14595
15238
  // Registered synchronously before a web message is handed to this CLI.
14596
15239
  // This waits only on display ordering, never on the web delivery itself.
14597
15240
  const echoTail = this.webChannelEchoTails.get(instanceName)?.tail;
@@ -14637,6 +15280,11 @@ export class FleetManager {
14637
15280
  respond(null, stickerProblem);
14638
15281
  return;
14639
15282
  }
15283
+ // Echo ordering and sticker validation await external work; a Hub turn may have begun meanwhile.
15284
+ if (this.classicHubPrivateBlocked(instanceName)) {
15285
+ respond(null, "This ClassicBot agent is handling private Hub input. Room output is blocked; answer the Hub with report_result.");
15286
+ return;
15287
+ }
14640
15288
  const ticket = this.replyDeduper.begin(instanceName, replyDedupText(args), Array.isArray(args.files) ? args.files : []);
14641
15289
  if (ticket.duplicate) {
14642
15290
  this.logger.info({ instanceName }, "Concurrent duplicate reply joined — awaiting the original send's outcome");
@@ -14778,6 +15426,12 @@ export class FleetManager {
14778
15426
  return false;
14779
15427
  }
14780
15428
  }
15429
+ captureReplyPreview(instance, args) {
15430
+ if (!replyPreviews(args.previews)?.length)
15431
+ return undefined;
15432
+ const identity = this.webChatIdentity(instance);
15433
+ return result => { void this.afterReplyRouted(instance, args, instance, null, false, undefined, identity, result); };
15434
+ }
14781
15435
  afterReplyRouted(instanceName, args, senderSessionName, buttons = null, inChannel = false, sentAs, identity = this.webChatIdentity(instanceName), replyResult = sentAs?.result) {
14782
15436
  // AGEND-181: the id the reply call returned (also on a fleet with no adapter: web-only), the row's anchor.
14783
15437
  const returned = replyResult && typeof replyResult === "object" ? replyResult.messageId : undefined;
@@ -14830,6 +15484,7 @@ export class FleetManager {
14830
15484
  ts,
14831
15485
  ...(attachments.length ? { attachments } : {}),
14832
15486
  ...(buttons ? { buttons } : {}), // #1266
15487
+ ...(replyPreviews(args.previews)?.length ? { previews: replyPreviews(args.previews) } : {}),
14833
15488
  ...(inChannel ? { channel: true } : {}), // #1920 §5.2
14834
15489
  ...(post ? { posts: [post] } : {}), // #2281
14835
15490
  ...(typeof returned === "string" && returned ? { anchor: returned } : {}), // AGEND-181: what the reply call returned
@@ -16729,6 +17384,8 @@ export class FleetManager {
16729
17384
  clean("files", () => this.webFiles.forget(name));
16730
17385
  clean("compact", () => this.compactWatchService?.forget(name));
16731
17386
  clean("preferences", () => this.webPrefs.forgetInstance(name));
17387
+ clean("pins", () => { if (this.pinStore.forget(name))
17388
+ this.emitSseEvent("pins", { instance: name, rev: this.pinStore.rev() }); });
16732
17389
  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
17390
  }
16734
17391
  async removeInstanceOwned(name, authorization, execution, transition) {
@@ -16817,6 +17474,14 @@ export class FleetManager {
16817
17474
  catch (err) {
16818
17475
  this.logger.warn({ err: err.message, name }, "Dropping a removed instance from web favorites failed");
16819
17476
  }
17477
+ // M-3271: and its pinned messages (a later instance of the same name starts with none).
17478
+ try {
17479
+ if (this.pinStore.forget(name))
17480
+ this.emitSseEvent("pins", { instance: name, rev: this.pinStore.rev() });
17481
+ }
17482
+ catch (err) {
17483
+ this.logger.warn({ err: err.message, name }, "Dropping a removed instance's pins failed");
17484
+ }
16820
17485
  try {
16821
17486
  this.themeStore.forget(name);
16822
17487
  this.webAppearance.forget(name);
@@ -17215,6 +17880,15 @@ export class FleetManager {
17215
17880
  const caches = [...this.adapters.values()].filter(a => typeof a.mentionNames === "function").map(a => (q) => a.mentionNames(q));
17216
17881
  return resolveMentions(query, [bots, seen, ...caches]);
17217
17882
  }
17883
+ /** Guest labels use the exact instance connection/channel, never Fleet-wide seen users or another bot. */
17884
+ guestMentionNames(owner, instance, query) {
17885
+ const adapterId = this.topicAdapterIdOf(instance), world = adapterId ? this.worlds.get(adapterId) : undefined;
17886
+ const cfg = this.fleetConfig?.instances[instance];
17887
+ const channel = cfg?.topic_id ?? this.classicChannels?.getChannelIdByInstance(instance) ?? this.getGroupIdForInstance(instance);
17888
+ if (this.worlds.get(owner.adapterId)?.type !== "discord" || world?.type !== "discord" || !channel || !world.adapter.mentionNamesInChannel)
17889
+ return { u: {}, r: {}, c: {} };
17890
+ return resolveMentions(query, [q => world.adapter.mentionNamesInChannel(q, String(channel), owner.userId)]);
17891
+ }
17218
17892
  /** GET /ui/emojis: the custom emoji of every server the fleet's Discord bots are in (the Settings picker's cache). */
17219
17893
  async webEmojiList() {
17220
17894
  const adopted = [];
@@ -18404,6 +19078,10 @@ export class FleetManager {
18404
19078
  * would have to make this async and change every caller.
18405
19079
  */
18406
19080
  notifyInstanceTopic(instanceName, text, extraOpts, ack) {
19081
+ if (this.classicHubPrivateBlocked(instanceName)) {
19082
+ ack?.(false);
19083
+ return false;
19084
+ }
18407
19085
  if (isNativeExecInstance(this.fleetConfig?.instances[instanceName])) {
18408
19086
  this.emitSseEvent("message", { instance: instanceName, role: "status", sender: "AgEnD", text, ts: new Date().toISOString() });
18409
19087
  return !ack; // an SSE event is no acknowledgement
@@ -18427,6 +19105,8 @@ export class FleetManager {
18427
19105
  * edit or delete the message later (#2897). Null when there is no adapter or no postable target (already logged).
18428
19106
  */
18429
19107
  sendToInstanceTopic(instanceName, text, extraOpts) {
19108
+ if (this.classicHubPrivateBlocked(instanceName))
19109
+ return null;
18430
19110
  const adapter = this.getAdapterForInstance(instanceName) ?? this.adapter;
18431
19111
  if (!adapter) {
18432
19112
  // Early startup: adapters are created well after the fleet object exists.
@@ -18792,6 +19472,10 @@ export class FleetManager {
18792
19472
  return true;
18793
19473
  if (await this.handleKiroMigrateCallback(data, adapterId, adapter))
18794
19474
  return true;
19475
+ if (await this.handleHubFleetUpdateCallback(data, adapterId, adapter))
19476
+ return true;
19477
+ if (await this.handleHubUpdateCallback(data, adapterId, adapter))
19478
+ return true;
18795
19479
  if (await this.handleKiroReconcileCallback(data, adapterId, adapter))
18796
19480
  return true;
18797
19481
  if (await this.handleOfficePackCallback(data, adapterId, adapter))
@@ -19789,6 +20473,25 @@ export class FleetManager {
19789
20473
  store.prune(a => a.epoch === state.epoch && now <= Math.min(a.until, a.authorizedAt + policy.maxSessionMs) && live.has(a.handle));
19790
20474
  return { ok: true, ...store.authorize(session.handle, session.owner, now, state.epoch, now + policy.maxSessionMs, peer) };
19791
20475
  }
20476
+ /**
20477
+ * M-3277 (decision 7933bf90; auth-api, at sign-in): an admin session that signed in with a code AgEnD delivered privately
20478
+ * to its account (a DM, or Discord's ephemeral reply) starts verified — that code went to the very DM a Confirm card
20479
+ * would. §3 is judged as at a Confirm (authorizeWebSession: the switch, loopback only, the named / quick link options,
20480
+ * still an admin, the namespace); a refusal leaves the session signed in and unverified, as before. The account is told
20481
+ * at once, with Not me (noteAuthorized). Re-verifying once that authorization has run out still takes the card.
20482
+ */
20483
+ authorizeSignedInSession(session, peer, gateway) {
20484
+ if (session.tier !== "admin" || !session.owner || session.host)
20485
+ return;
20486
+ const r = this.authorizeWebSession(session, peer, gateway);
20487
+ if (!r.ok) {
20488
+ this.logger.info({ handle: session.handle, refusal: r.refusal }, "Web session signed in with a private code, not verified");
20489
+ return;
20490
+ }
20491
+ this.logger.info({ handle: session.handle, durable: r.durable }, "Web session verified at sign-in (a private code)");
20492
+ void this.sessionAuthorizationRequests().noteAuthorized({ handle: session.handle, owner: session.owner, label: session.label, peer, until: Math.min(r.authorization.until, session.absoluteExpiry) })
20493
+ .catch(err => this.logger.warn({ err: err?.message }, "Web sign-in notice failed"));
20494
+ }
19792
20495
  /**
19793
20496
  * #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
20497
  * --code`) on this computer — is the host operator, authorized from now for max_session_hours (as an account's
@@ -19913,8 +20616,8 @@ export class FleetManager {
19913
20616
  * and their switch are another thing and stay a web-only fleet's, on its own computer (liveOwner).
19914
20617
  */
19915
20618
  authenticatorOwner(req) {
19916
- if (gatewayRequestContext(req))
19917
- return null;
20619
+ // M-3278 (decision 7933bf90): over a link too — the settings role decides (its link option, Only this computer), and an
20620
+ // app that exists asks its current code off this computer (authenticatorCodeAsked), as from the LAN.
19918
20621
  const first = this.settingsRole(req);
19919
20622
  if (!first.role.ok || !first.handle)
19920
20623
  return null;
@@ -20220,6 +20923,8 @@ export class FleetManager {
20220
20923
  kind: "ok",
20221
20924
  knownCookie: addSigninKnownDevice(webToken, input.knownCookie, who, enrollment, epoch, now),
20222
20925
  session: outside ? { remote: "totp" } : actor ? { owner: actor } : {},
20926
+ // M-3163: a chat admin's browser becomes their returning device, as a code DM'd to them makes it (#1570).
20927
+ ...(!outside && actor ? (() => { const o = this.generalOwnerOf(actor.adapterId, actor.userId); return o ? { returningOwner: o } : {}; })() : {}),
20223
20928
  // Asked again as the session is made: the same app, still an admin, still allowed here.
20224
20929
  commit: (record, label) => {
20225
20930
  if (!this.totpSignInOpen(exposureId, peer) || store.enrollmentOf(who) !== enrollment)
@@ -20318,6 +21023,36 @@ export class FleetManager {
20318
21023
  return true;
20319
21024
  }
20320
21025
  authorityStateStore = null;
21026
+ namedLinkDefaultChecked = false;
21027
+ /**
21028
+ * M-3277 (#4099 review, F1): the named link is on by default now, and before M-3277 the Settings card turned it off by
21029
+ * removing `named_link` from fleet.yaml. A fleet whose owner did that (the state file: seen, and off now) would read the
21030
+ * absent key as the new default — on again, and the epoch moved — against that owner's last choice. Once per process
21031
+ * (and again after a reload), before the state is read: such a fleet gets `named_link: false`, in memory at once and in
21032
+ * fleet.yaml (a backup first, as every upgrade migration). A fleet that never turned it on gets the default (nothing
21033
+ * was ever authorized over that link); an explicit value is never touched.
21034
+ */
21035
+ migrateNamedLinkDefault() {
21036
+ if (this.namedLinkDefaultChecked || !this.fleetConfig || !this.dataDir)
21037
+ return;
21038
+ this.namedLinkDefaultChecked = true;
21039
+ const va = this.fleetConfig.web?.verified_authority;
21040
+ if (va?.named_link !== undefined && va?.named_link !== null)
21041
+ return;
21042
+ if (!namedLinkLastTurnedOff(join(this.dataDir, "web-authority.json")))
21043
+ return;
21044
+ this.fleetConfig.web = { ...(this.fleetConfig.web ?? {}), verified_authority: { ...(va ?? {}), named_link: false } };
21045
+ 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)");
21046
+ if (!this.configPath || this.configHistory?.isFallback(this.configPath) || !validateFleetConfig(this.rawFleetConfig).valid)
21047
+ return;
21048
+ try {
21049
+ this.writeFleetConfigBackup(readFileSync(this.configPath, "utf8"));
21050
+ this.saveFleetConfig();
21051
+ }
21052
+ catch (err) {
21053
+ this.logger.warn({ err }, "Could not store named_link: false in fleet.yaml; it stays off for this run");
21054
+ }
21055
+ }
20321
21056
  /**
20322
21057
  * #1939 §10: the switch, "Only this computer can authorize" and the revocation epoch in force for the configuration as
20323
21058
  * it is now (a change since last seen moves the epoch first; authority-state.ts). No data directory: off.
@@ -20325,6 +21060,7 @@ export class FleetManager {
20325
21060
  webAuthorityState() {
20326
21061
  if (!this.dataDir)
20327
21062
  return { enabled: false, loopbackOnly: true, namedLink: false, quickLink: false, epoch: 0 };
21063
+ this.migrateNamedLinkDefault(); // M-3277 F1: before the first read of the state (it would move the epoch)
20328
21064
  this.authorityStateStore ??= new AuthorityStateStore(join(this.dataDir, "web-authority.json"), this.logger, undefined, undefined, () => { this.ensureDeliveryOutbox?.(); return this.deliveryOutbox?.maxWebAuthorityEpoch() ?? 0; });
20329
21065
  const state = this.authorityStateStore.current(this.fleetConfig?.web?.verified_authority);
20330
21066
  // #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 +21196,8 @@ export class FleetManager {
20460
21196
  text: {
20461
21197
  ask: (c) => t("web_auth.card_ask", c.label, where(c.peer), when(c.askedAt), when(c.until)),
20462
21198
  confirmed: (c) => t("web_auth.card_confirmed", c.label, where(c.peer), when(c.until)),
21199
+ signedIn: (c) => t("web_auth.signed_in", c.label, where(c.peer), when(c.until)),
21200
+ signedInHint: () => t("web_auth.signed_in_hint"),
20463
21201
  denied: (c) => t("web_auth.card_denied", c.label),
20464
21202
  expired: (c) => t("web_auth.card_expired", c.label),
20465
21203
  refused: (c) => t("web_auth.card_refused", c.label, t(`web_auth.refusal_${c.refusal}`)),
@@ -20574,7 +21312,7 @@ export class FleetManager {
20574
21312
  return null;
20575
21313
  return { handle, current: verified, revoke: () => { const session = live(); return this.revokeWebAuthority(session ? { session, peer, gateway: false } : undefined); } };
20576
21314
  }
20577
- /** #1269: an instance's chat command from the web chat (web-commands.ts); `publicLink`: a gateway request. */
21315
+ /** #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
21316
  /** #2855: the table scope of an instance the web chat may command (a fleet instance or a ClassicBot room), else null. */
20579
21317
  webCommandScope(instance) {
20580
21318
  // Own entries only: a name like "__proto__" or "constructor" must not be found on the prototype (#1476 review).
@@ -20602,6 +21340,9 @@ export class FleetManager {
20602
21340
  return { current: catalog.current_model, options: catalog.models.map(m => ({ id: m.id, label: m.label })), actions: ["refresh"] };
20603
21341
  }
20604
21342
  const backend = this.backendNameForInstance(instance);
21343
+ // Opened on an empty list, the menu waits for one bounded discovery ("loading") instead of showing nothing.
21344
+ if (!more)
21345
+ await this.ensureModelCatalog(backend, instance);
20605
21346
  const env = this.webModelEnv(backend, instance);
20606
21347
  const current = this.resolveInstanceModel(instance).model;
20607
21348
  const models = more ? this.modelCatalogFor(backend, instance) : env?.models ?? [];
@@ -20671,7 +21412,11 @@ export class FleetManager {
20671
21412
  const refusal = this.backendCommandRefusal(instance);
20672
21413
  if (refusal)
20673
21414
  return { error: refusal };
20674
- // The cached model lists only, as the web's /model: never a live probe on this path.
21415
+ // The cached model lists, as the web's /model; an empty one is discovered once, bounded (moving to a CLI
21416
+ // never signed in at startup, or probed before it was installed, must not offer an empty list).
21417
+ const wanted = backendArgs(args)[0];
21418
+ if (wanted && KNOWN_BACKENDS.includes(wanted))
21419
+ await this.ensureModelCatalog(wanted, instance);
20675
21420
  const step = await backendStep({ ...this.backendCommandDeps(instance, { live: false }), models: async (backend) => this.modelCatalogFor(backend, instance) }, instance, backendArgs(args));
20676
21421
  if (step.kind === "refuse")
20677
21422
  return step.noop ? { text: step.text } : { error: step.text };
@@ -20680,6 +21425,7 @@ export class FleetManager {
20680
21425
  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
21426
  // #2233: the web offers Sign in beside it, so its reason is no longer "use /login".
20682
21427
  // Not over the public link: Sign in is refused there, so the choice keeps its "(use /login)" (#2262 review).
21428
+ // M-3278 (decision 7933bf90): `publicLink` is set for a non-admin only, so the link's admin session gets Sign in.
20683
21429
  const signIn = c.signIn && !stepOpts?.publicLink && dashboardSignInSupported(c.signIn) ? c.signIn : null;
20684
21430
  const disabled = signIn ? t("backend.reason_not_signed_in_web") : c.disabled;
20685
21431
  return { id: id(c.token), label: signIn ? `${c.token} — ${disabled}` : c.label, ...(disabled ? { disabled } : {}), ...(signIn ? { signIn } : {}) };
@@ -20861,6 +21607,8 @@ export class FleetManager {
20861
21607
  await this.notifyNormalExit(instanceName, unclear ? "unclear" : true);
20862
21608
  }
20863
21609
  async notifyNormalExit(instanceName, oom = false) {
21610
+ if (this.classicHubPrivateBlocked(instanceName))
21611
+ return;
20864
21612
  const daemon = oom === "unclear" ? this.daemons.get(instanceName) : undefined;
20865
21613
  const owner = daemon ? { ...daemon.getInteractionSnapshot().owner } : undefined;
20866
21614
  const current = daemon && owner ? () => this.daemons.get(instanceName) === daemon
@@ -21633,7 +22381,7 @@ export class FleetManager {
21633
22381
  * so claiming every retained checkpoint is "completed" would be false. */
21634
22382
  composeRetiredBubbleText(entry) {
21635
22383
  const elapsed = FleetManager.formatProgressElapsed(Date.now() - (entry.startedAt ?? Date.now()));
21636
- return `🧾 工具歷程 (記錄至 ${elapsed})\n${entry.toolProgress}`;
22384
+ return `${t("progress.trace_title", elapsed)}\n${entry.toolProgress}`;
21637
22385
  }
21638
22386
  /**
21639
22387
  * Make a tool summary safe to paste into a channel message.
@@ -21663,6 +22411,8 @@ export class FleetManager {
21663
22411
  * never used to decide anything — purely what the user is shown.
21664
22412
  */
21665
22413
  cacheInstanceActivity(name, activity) {
22414
+ if (this.classicHubPrivateBlocked(name))
22415
+ return;
21666
22416
  if (activity)
21667
22417
  this.instanceActivity.set(name, activity);
21668
22418
  else
@@ -21675,6 +22425,8 @@ export class FleetManager {
21675
22425
  * rate-limited per bubble AND ride behind the daemon-side 3s coalescer).
21676
22426
  */
21677
22427
  cacheInstanceProgress(name, progress) {
22428
+ if (this.classicHubPrivateBlocked(name))
22429
+ return;
21678
22430
  if (progress)
21679
22431
  this.instanceProgress.set(name, progress);
21680
22432
  else
@@ -21726,6 +22478,8 @@ export class FleetManager {
21726
22478
  }
21727
22479
  /** Recompose and edit the bubble in place; skips when nothing changed. */
21728
22480
  refreshBubble(entry) {
22481
+ if (this.classicHubPrivateBlocked(entry.instanceName))
22482
+ return;
21729
22483
  if (entry.retiring || !this.cancelButtons.has(entry.messageId)) {
21730
22484
  clearInterval(entry.progressTimer);
21731
22485
  return;
@@ -22075,8 +22829,10 @@ export class FleetManager {
22075
22829
  // #2072: a sign-in just finished — the pickers learn it now, not at the next pass.
22076
22830
  if (!profile)
22077
22831
  void this.backendAvailability.refresh([backend], { force: true });
22832
+ this.modelsAfterSignIn(backend, profile ?? null); // Chat /login and the dashboard's terminal sign-in
22078
22833
  return this.recoverBackendInstances(backend, undefined, profile ?? null);
22079
22834
  },
22835
+ agentLabel: name => this.fleetConfig?.instances[name]?.display_name?.trim() || name, // M-3249: the outcome line names agents as people see them
22080
22836
  claimWindow: backend => this.loginWindow.tryClaim("web", backend),
22081
22837
  releaseWindow: claim => { this.loginWindow.release(claim); },
22082
22838
  isClaimCurrent: claim => this.loginWindow.isCurrent(claim),
@@ -22110,7 +22866,7 @@ export class FleetManager {
22110
22866
  reported: (id, profile, backend) => this.machineAccounts.profileState(id, profile, backend),
22111
22867
  reportedDefault: (id, backend) => this.machineAccounts.reportedDefault(id, backend),
22112
22868
  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; },
22869
+ actor: owner => this.machineSignInActor(owner),
22114
22870
  changed: (event, owner) => {
22115
22871
  // 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
22872
  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 +22874,44 @@ export class FleetManager {
22118
22874
  // 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
22875
  if (event.phase === "done" && event.profile === undefined)
22120
22876
  this.machineAccounts.noteDefaultLogin(event.machine, event.backend, true);
22877
+ // That computer's Runtime lists models in its own inventory (never a host probe): pages read it again now,
22878
+ // and the Runtime is asked once, for the admin who finished the sign-in, to list them as this account.
22879
+ if (event.phase === "done") {
22880
+ this.announceModels(event.backend);
22881
+ void this.nativeModelsAfterSignIn(event, owner);
22882
+ }
22121
22883
  broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed"));
22122
22884
  this.needsYou?.poke();
22123
22885
  },
22124
22886
  });
22125
22887
  }
22888
+ /**
22889
+ * A paired computer's sign-in ended — ask its Runtime once (`models.refresh`, as the admin who finished the
22890
+ * 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
22891
+ * Refresh button. Once per sign-in; never on a read (M-2239 P1-2). A Runtime without the capability, a refused account or any
22892
+ * failure is skipped quietly: the sign-in is done either way.
22893
+ */
22894
+ /** The name a paired computer's audit log records for the admin session that signed in on it (`admin:<handle>`); null refuses. */
22895
+ machineSignInActor(owner) {
22896
+ const handle = owner.handle;
22897
+ return typeof handle === "string" && /^[a-f0-9]{16}$/.test(handle) ? `admin:${handle}` : null;
22898
+ }
22899
+ async nativeModelsAfterSignIn(event, owner) {
22900
+ try {
22901
+ const actor = this.machineSignInActor(owner);
22902
+ if (!actor || this.shuttingDown || !this.browserSignInOwnerCurrent(owner))
22903
+ return;
22904
+ const refreshed = await refreshNativeModelCatalogAfterSignIn(this, {
22905
+ backend: event.backend, machineId: event.machine, ...(event.profile ? { profile: event.profile } : {}), actor,
22906
+ stillAdmin: () => !this.shuttingDown && this.browserSignInOwnerCurrent(owner),
22907
+ });
22908
+ if (refreshed)
22909
+ this.announceModels(event.backend);
22910
+ }
22911
+ catch (err) {
22912
+ this.logger.debug({ backend: event.backend, err }, "Model refresh after a computer's sign-in skipped");
22913
+ }
22914
+ }
22126
22915
  machineAccountsInstance = null;
22127
22916
  /** #3190 Part 3c: a paired computer's accounts in Settings → Accounts (machine-accounts.ts). */
22128
22917
  get machineAccounts() {
@@ -22171,6 +22960,7 @@ export class FleetManager {
22171
22960
  broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed"));
22172
22961
  if (event.phase === "done") {
22173
22962
  this.forgetSignInIdentities(); // a sign-in may be a different account now
22963
+ this.modelsAfterSignIn(event.backend, null); // The list read before this sign-in (a signed-out CLI answers none) is not this account's
22174
22964
  this.keepAliveAfterSignIn(event.backend, null); // its file changed, whoever is watching: a "needs sign-in" left from before is no longer the answer
22175
22965
  this.usageAfterSignIn(); // the usage read before this sign-in is not this account's
22176
22966
  }
@@ -22226,6 +23016,7 @@ export class FleetManager {
22226
23016
  broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed"));
22227
23017
  if (event.phase === "done") {
22228
23018
  this.forgetSignInIdentities(); // a sign-in may be a different account now
23019
+ this.modelsAfterSignIn(event.backend, event.profile);
22229
23020
  this.keepAliveAfterSignIn(event.backend, event.profile);
22230
23021
  this.usageAfterSignIn();
22231
23022
  }
@@ -22948,7 +23739,7 @@ export class FleetManager {
22948
23739
  if (!structuredSignInSupported(backend) || !STRUCTURED_PROFILE_BACKENDS.has(backend))
22949
23740
  return false;
22950
23741
  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);
23742
+ return !!row && row.state !== "not_installed" && row.state !== "too_old" && structuredSignInReady(row, hostFacts(backend, "structuredSignIn")?.minVersion);
22952
23743
  }
22953
23744
  backendSignInTargets() {
22954
23745
  const out = [];
@@ -22959,10 +23750,11 @@ export class FleetManager {
22959
23750
  // whether it is over, and then it is not signed in (never the other way: the file can't vouch for a login).
22960
23751
  const ended = row.state === "usable" && this.claudeSignInEnded(row.backend, null);
22961
23752
  // 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.
23753
+ // >= 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
23754
+ // 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
23755
  const structured = hostFacts(row.backend, "structuredSignIn");
22964
23756
  const viaStructured = !!structured && flow?.remoteLogin === "unsupported" && row.state !== "not_installed";
22965
- const structuredSignIn = viaStructured && versionAtLeast(row.version, structured.minVersion);
23757
+ const structuredSignIn = viaStructured && structuredSignInReady(row, structured.minVersion);
22966
23758
  // Told to update only when the version is KNOWN to be older: a version that was not read yet is not "too old".
22967
23759
  const structuredUpdate = viaStructured && !structuredSignIn && typeof row.version === "string" && /\d/.test(row.version);
22968
23760
  out.push({
@@ -22995,11 +23787,14 @@ export class FleetManager {
22995
23787
  }
22996
23788
  return out;
22997
23789
  }
22998
- /** #2233: the session with this handle is live, admin, local and of the current dashboard token. */
23790
+ /**
23791
+ * #2233: the session with this handle is live, admin and of the current dashboard token. M-3278 (decision 7933bf90): on
23792
+ * any listener — the public link's admin session too (closing the link revokes its sessions, so none outlives it).
23793
+ */
22999
23794
  isLocalAdminSession(handle) {
23000
23795
  const sessions = this.webSessions, token = this.webToken;
23001
23796
  const record = sessions?.findByHandle(handle);
23002
- return !!record && !!token && record.tier === "admin" && record.surface === "local" && sessions.isCurrent(record, tokenEpoch(token));
23797
+ return !!record && !!token && record.tier === "admin" && sessions.isCurrent(record, tokenEpoch(token));
23003
23798
  }
23004
23799
  /**
23005
23800
  * #2233: `/login` for a dashboard requester. The same controller and checks; a CLI that is not installed is refused
@@ -23982,6 +24777,9 @@ export class FleetManager {
23982
24777
  storablePath: (id) => this.webFiles.storablePath(id),
23983
24778
  restore: (entry, instance) => this.webFiles.restoreServed(entry, instance, join(getAgendHome(), "workspaces", instance, "inbox"), webFilesDir(getAgendHome(), instance) ?? undefined),
23984
24779
  drop: (ids) => this.webFiles.dropServed(ids),
24780
+ // M-3281: an archived message keeps its files (web-chat-archive.ts `files/`), served from there while it is read.
24781
+ keep: (id, dest) => this.webFiles.keepCopy(id, dest),
24782
+ restoreKept: (entry, instance, keptDir) => this.webFiles.restoreKept(entry, instance, keptDir),
23985
24783
  });
23986
24784
  let restored = 0;
23987
24785
  for (const name of names)
@@ -23998,6 +24796,21 @@ export class FleetManager {
23998
24796
  this.logger.info({ swept }, "Removed web reply snapshots no message holds");
23999
24797
  this.webChatStore = store;
24000
24798
  this.webChatHistory.setStore(store);
24799
+ // M-3272: messages leaving the 500-message window are archived per agent (owner-bound as web-chat.json is), kept
24800
+ // for web.chat_archive.retention_days (unset or 0: everything). M-3281: with their files, every agent's together
24801
+ // within web.chat_archive.files_max_gb (default 5 GiB; the oldest go first) — checked once soon after the start too.
24802
+ const archive = new WebChatArchive({ home: getAgendHome(), ownerOf: (name) => this.webChatOwner(name), logger: this.logger,
24803
+ retentionDays: () => this.fleetConfig?.web?.chat_archive?.retention_days,
24804
+ filesMaxGb: () => this.fleetConfig?.web?.chat_archive?.files_max_gb });
24805
+ this.webChatArchive = archive;
24806
+ this.webChatHistory.setArchive(archive);
24807
+ const capCheck = setTimeout(() => { try {
24808
+ archive.enforceFilesCap();
24809
+ }
24810
+ catch (err) {
24811
+ this.logger.warn({ err }, "Web chat archive: the files' size limit could not be checked");
24812
+ } }, 30_000);
24813
+ capCheck.unref?.();
24001
24814
  if (restored)
24002
24815
  this.logger.info({ restored, instances: names.size }, "Web chat history restored from disk");
24003
24816
  }
@@ -24033,6 +24846,7 @@ export class FleetManager {
24033
24846
  anchor: typeof m.anchor === "string" ? m.anchor : undefined,
24034
24847
  role: typeof m.role === "string" ? m.role : undefined,
24035
24848
  buttons: m.buttons,
24849
+ previews: m.previews,
24036
24850
  click: m.click,
24037
24851
  links: m.links,
24038
24852
  channel: m.channel,
@@ -24135,6 +24949,8 @@ export class FleetManager {
24135
24949
  }
24136
24950
  }
24137
24951
  async sendHangNotification(instanceName, unchangedForMs) {
24952
+ if (this.classicHubPrivateBlocked(instanceName))
24953
+ return;
24138
24954
  const web = this.webOnlyPromptPlace(); // no chat platform: asked on the dashboard (#1307 item 6)
24139
24955
  const adapter = web?.adapter ?? this.getAdapterForInstance(instanceName) ?? this.adapter;
24140
24956
  const adapterId = web?.adapterId ?? this.getInstanceAdapterId(instanceName);
@@ -25033,6 +25849,114 @@ export class FleetManager {
25033
25849
  this.logger.info({ instanceName, model }, "Runtime model switch sent");
25034
25850
  });
25035
25851
  }
25852
+ /**
25853
+ * M-3175: codex's `/model [NAME] --reasoning=LEVEL` in the running session. The daemon types it only into an idle pane of a
25854
+ * 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
25855
+ * the time allowed here.
25856
+ */
25857
+ runCodexRuntimeSwitch(instanceName, model, effort) {
25858
+ const ipc = this.instanceIpcClients.get(instanceName), line = codexModelCommand(model, effort);
25859
+ if (!ipc || !line)
25860
+ return Promise.resolve({ outcome: "not_sent" });
25861
+ const id = `switch-${randomUUID()}`;
25862
+ return new Promise(resolve => {
25863
+ const timer = setTimeout(() => { this.runtimeSwitchWaiters.delete(id); resolve({ outcome: "not_confirmed" }); }, CODEX_RUNTIME_SWITCH_RESULT_MS);
25864
+ timer.unref?.();
25865
+ this.runtimeSwitchWaiters.set(id, result => { clearTimeout(timer); resolve(result); });
25866
+ const sent = ipc.send({ type: "raw_paste", content: line, runtime_switch: { id, kind: "model", requested: model ?? "", codex: { model, effort } } });
25867
+ if (!sent) {
25868
+ clearTimeout(timer);
25869
+ this.runtimeSwitchWaiters.delete(id);
25870
+ resolve({ outcome: "not_sent" });
25871
+ return;
25872
+ }
25873
+ this.logger.info({ instanceName, model, effort }, "Codex runtime switch sent");
25874
+ });
25875
+ }
25876
+ /**
25877
+ * 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
25878
+ * 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
25879
+ * after it. The first step that did not switch ends it, with that step. A model the CLI cannot vouch for is not typed.
25880
+ */
25881
+ async runCliRuntimeSwitch(instanceName, backend, want) {
25882
+ const entry = CLI_RUNTIME_SWITCH[backend];
25883
+ let last = { result: { outcome: "not_sent" }, step: want };
25884
+ for (const step of entry.steps(want)) {
25885
+ if (step.model !== null && entry.knownModel && entry.knownModel(step.model) !== true)
25886
+ return { result: { outcome: "not_sent", reason: "unknown_model" }, step };
25887
+ const line = entry.command(step), ipc = this.instanceIpcClients.get(instanceName);
25888
+ if (!line)
25889
+ return { result: { outcome: "not_sent", reason: "command" }, step };
25890
+ if (!ipc)
25891
+ return { result: { outcome: "not_sent" }, step };
25892
+ const id = `switch-${randomUUID()}`;
25893
+ const result = await new Promise(resolve => {
25894
+ const timer = setTimeout(() => { this.runtimeSwitchWaiters.delete(id); resolve({ outcome: "not_confirmed" }); }, CODEX_RUNTIME_SWITCH_RESULT_MS);
25895
+ timer.unref?.();
25896
+ this.runtimeSwitchWaiters.set(id, r => { clearTimeout(timer); resolve(r); });
25897
+ 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 } } });
25898
+ if (!sent) {
25899
+ clearTimeout(timer);
25900
+ this.runtimeSwitchWaiters.delete(id);
25901
+ resolve({ outcome: "not_sent" });
25902
+ return;
25903
+ }
25904
+ this.logger.info({ instanceName, backend, step }, "CLI runtime switch sent");
25905
+ });
25906
+ last = { result, step };
25907
+ if (result.outcome !== "switched")
25908
+ return last;
25909
+ }
25910
+ return last;
25911
+ }
25912
+ /**
25913
+ * M-3180: whether this instance's `/model` / `/effort` try its CLI's in-session switch. kiro: only an instance last launched on the
25914
+ * TUI (the v2 engine; the engine ledger) — classic and V3 keep the restart.
25915
+ */
25916
+ cliSwitchRouted(instanceName, backend) {
25917
+ if (!Object.hasOwn(CLI_RUNTIME_SWITCH, backend))
25918
+ return false;
25919
+ if (backend === "kiro-cli")
25920
+ return readKiroLedger()[instanceName]?.lastLaunch.ui === "tui";
25921
+ return true;
25922
+ }
25923
+ /** M-3180: why a CLI_RUNTIME_SWITCH switch fell back to a restart, in the reply's words. */
25924
+ cliSwitchFallbackReason(backend, { result, step }) {
25925
+ const cli = BACKEND_LABELS[backend] ?? backend, entry = CLI_RUNTIME_SWITCH[backend];
25926
+ if (result.outcome === "not_sent" && result.reason === "busy")
25927
+ return t("codex_switch.busy");
25928
+ if (result.outcome === "not_sent" && result.reason === "version") {
25929
+ return t("cli_switch.version", cli, result.version ?? t("codex_switch.version_unknown"), step.model !== null ? entry.minVersion.model : entry.minVersion.effort);
25930
+ }
25931
+ if (result.outcome === "not_sent" && result.reason === "unknown_model")
25932
+ return t("cli_switch.unknown_model", cli, step.model ?? "");
25933
+ if (result.outcome === "not_sent" && result.reason === "command")
25934
+ return t("cli_switch.not_one_command", cli, step.model ?? step.effort ?? "");
25935
+ if (result.outcome === "mismatch")
25936
+ return t("cli_switch.mismatch", cli, result.shown);
25937
+ return t("cli_switch.unconfirmed", cli);
25938
+ }
25939
+ /** M-3175: why a codex switch fell back to a restart, in the reply's words. */
25940
+ codexSwitchFallbackReason(result) {
25941
+ if (result.outcome === "not_sent" && result.reason === "busy")
25942
+ return t("codex_switch.busy");
25943
+ if (result.outcome === "not_sent" && result.reason === "version")
25944
+ return t("codex_switch.version", result.version ?? t("codex_switch.version_unknown"), CODEX_INLINE_MODEL_MIN);
25945
+ if (result.outcome === "mismatch")
25946
+ return t("codex_switch.mismatch", result.shown);
25947
+ return t("codex_switch.unconfirmed");
25948
+ }
25949
+ /**
25950
+ * M-3175: the effort a codex model switch carries — the one a restart would launch with (configured, and listed by that
25951
+ * model's catalog, as the launch flag is gated); null when there is none, and codex then takes the model's default, as a
25952
+ * launch without an effort does.
25953
+ */
25954
+ codexSwitchEffort(instanceName, model) {
25955
+ const effort = this.resolveInstanceEffort(instanceName).effort;
25956
+ if (!effort)
25957
+ return null;
25958
+ return this.instanceEffortMetadata(instanceName, model).levels.includes(effort) ? effort : null;
25959
+ }
25036
25960
  /**
25037
25961
  * #1690: the names claude-code is known to accept, for checking `/model <name>` BEFORE it is typed — claude itself
25038
25962
  * accepts any string ("Set model to opsu"), and its "Switch model?" then names the typo. Static aliases (with [1m]),
@@ -25328,6 +26252,8 @@ export class FleetManager {
25328
26252
  /** Preserve the existing cache merge rules for worker probes. */
25329
26253
  persistCliEnvProbeResult(backend, probed, profile = null) {
25330
26254
  const env = { backend, probedAt: Date.now(), ...probed };
26255
+ const listed = (e) => (e?.models ?? []).map(m => m.id).join("\0");
26256
+ const before = listed(this.readCliEnv(backend, profile));
25331
26257
  // An empty result must never overwrite a catalog we already have. Some
25332
26258
  // probes hit the network (`agy models` fetches, 5s cap), so a slow moment
25333
26259
  // returns [] — and writing that would blank the list for the whole 24h
@@ -25358,6 +26284,8 @@ export class FleetManager {
25358
26284
  const path = this.cliEnvPath(backend, profile);
25359
26285
  mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
25360
26286
  writeFileSync(path, JSON.stringify(env, null, 2));
26287
+ if (listed(env) !== before)
26288
+ this.announceModels(backend); // An open /model or Settings page reads the new list
25361
26289
  return env;
25362
26290
  }
25363
26291
  /** Background-probe every distinct backend in use at startup (non-blocking). */
@@ -25379,6 +26307,105 @@ export class FleetManager {
25379
26307
  void this.probeBackendBounded(b);
25380
26308
  this.probeChangedCliEnvs(null);
25381
26309
  }
26310
+ /**
26311
+ * Whether a named account's catalog can be discovered without publishing another account's models under its name
26312
+ * (#3526 / D7). A CLI whose profile is a variable the probe inherits (codex, kiro, claude) is. A CLI told its account by an
26313
+ * argument (agy, `launch-argument`) is too, since AGEND-278: the probe is run with the account's own folder
26314
+ * (backend/antigravity.ts `listModels`), and it answers nothing for a folder with no sign-in. Never a profile on a
26315
+ * backend that has no credential home at all.
26316
+ */
26317
+ modelDiscoverable(backend, binding) {
26318
+ return !binding.profile || !!credentialHomeSpec(backend);
26319
+ }
26320
+ /** One model discovery for a binding — the scoped (own config) or the shared per-backend/profile cache — or null when fenced. */
26321
+ discoverModels(backend, name, binding = this.webModelBinding(backend, name), opts = {}) {
26322
+ if (!binding || !this.modelDiscoverable(backend, binding))
26323
+ return null;
26324
+ // A scoped read resolves its binding again (publication and current checks included), so it is handed the selection the
26325
+ // binding came from: without it the agent's saved/default account would be probed and populated instead.
26326
+ return binding.scoped
26327
+ ? this.refreshModelCatalogFor(backend, name, opts.selection, opts.afterSignIn ? { afterSignIn: true } : {})
26328
+ : this.probeBackendBounded(backend, { profile: binding.profile, ...(opts.refreshVendorCatalog ? { refreshVendorCatalog: true } : {}) });
26329
+ }
26330
+ /** The `models` stream event: a backend's model list changed — an open page reads it again (no details, as `backend_login`). */
26331
+ announceModels(backend) {
26332
+ try {
26333
+ broadcastSseEvent(this.sseClients, "models", { backend }, err => this.logger.debug({ err }, "models event failed"));
26334
+ }
26335
+ catch { /* best effort */ }
26336
+ }
26337
+ modelOpenProbes = new Map();
26338
+ /**
26339
+ * The list a menu opens on. Cached and fresh: nothing to do. Empty (never discovered: the CLI was signed out
26340
+ * at startup, or the agent just moved to this CLI): one bounded discovery that the caller waits for — so `/model` and
26341
+ * Settings show "loading" instead of an empty list. Stale: the list stands and is refreshed behind it. Both join a
26342
+ * discovery already running, and an attempt that found nothing is not repeated for MODEL_OPEN_PROBE_COOLDOWN_MS.
26343
+ * Never throws; a Windows Runtime's catalog is its inventory's and is not a host probe.
26344
+ */
26345
+ async ensureModelCatalog(backend, instance, selection) {
26346
+ try {
26347
+ const binding = this.webModelBinding(backend, instance, selection);
26348
+ if (!binding || this.shuttingDown)
26349
+ return;
26350
+ const env = this.webModelEnv(backend, instance, selection);
26351
+ const empty = !env?.models?.length;
26352
+ if (!empty && !this.cliEnvNeedsRefresh(env))
26353
+ return;
26354
+ this.modelOpenProbes ??= new Map();
26355
+ const last = this.modelOpenProbes.get(binding.key);
26356
+ if (last !== undefined && Date.now() - last < MODEL_OPEN_PROBE_COOLDOWN_MS)
26357
+ return;
26358
+ const work = this.discoverModels(backend, instance, binding, { selection });
26359
+ if (!work)
26360
+ return;
26361
+ const done = work.catch(err => { this.logger.debug({ backend, instance, err }, "Model discovery on open failed"); }).then(() => {
26362
+ const after = this.webModelEnv(backend, instance, selection);
26363
+ if (!after?.models?.length || this.cliEnvNeedsRefresh(after))
26364
+ this.modelOpenProbes.set(binding.key, Date.now());
26365
+ else
26366
+ this.modelOpenProbes.delete(binding.key);
26367
+ });
26368
+ if (!empty)
26369
+ return;
26370
+ let timer;
26371
+ await Promise.race([done, new Promise(resolve => { timer = setTimeout(resolve, MODEL_OPEN_PROBE_WAIT_MS); timer.unref?.(); })]);
26372
+ if (timer)
26373
+ clearTimeout(timer);
26374
+ }
26375
+ catch (err) {
26376
+ this.logger.debug({ backend, instance, err }, "Model discovery on open failed");
26377
+ }
26378
+ }
26379
+ /**
26380
+ * A sign-in just ended, so the CLI can now answer `models` as this account — whatever started the sign-in
26381
+ * (Settings → Accounts, a named account, chat `/login`, the dashboard's terminal). The account's list is read again now,
26382
+ * not at the next startup or by hand. The default account: the backend's shared cache. A named account: its own store
26383
+ * (claude's profile catalog), or each agent's scoped one (the other CLIs, agy included: its probe runs with the account's folder).
26384
+ * A provider-bound agent does not depend on the sign-in. Background; each page is told when the list changed.
26385
+ */
26386
+ modelsAfterSignIn(backend, profile) {
26387
+ if (this.shuttingDown || !KNOWN_BACKENDS.includes(backend) || backend === "mock")
26388
+ return;
26389
+ (this.modelOpenProbes ??= new Map()).clear(); // a cooldown from before the sign-in said "nothing to find": it no longer does
26390
+ const settle = (work) => {
26391
+ void work?.catch(err => this.logger.debug({ backend, profile, err }, "Model discovery after sign-in failed"));
26392
+ };
26393
+ if (profile === null) {
26394
+ settle(this.discoverModels(backend, null, undefined, { refreshVendorCatalog: true }));
26395
+ return;
26396
+ }
26397
+ if (backend === "claude-code") {
26398
+ settle(this.probeBackendBounded(backend, { profile, refreshVendorCatalog: true }));
26399
+ return;
26400
+ }
26401
+ for (const name of this.configuredBackendInstanceNames()) {
26402
+ if (this.backendNameOf(name) !== backend || this.credentialProfileOf(name, backend) !== profile)
26403
+ continue;
26404
+ const binding = this.webModelBinding(backend, name);
26405
+ if (binding?.scoped)
26406
+ settle(this.discoverModels(backend, name, binding, { afterSignIn: true }));
26407
+ }
26408
+ }
25382
26409
  /** Maintain discovery after committed config changes; a model-field read remains passive. */
25383
26410
  probeChangedCliEnvs(previous) {
25384
26411
  const signature = (fleet, name) => {
@@ -25393,11 +26420,7 @@ export class FleetManager {
25393
26420
  continue;
25394
26421
  const backend = this.backendNameForInstance(name);
25395
26422
  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")))
26423
+ if (!binding || !this.modelDiscoverable(backend, binding))
25401
26424
  continue;
25402
26425
  // A description/defaults save can retire a scoped answer's full binding even
25403
26426
  // though its account signature is unchanged. Keep the conservative fence and
@@ -25405,10 +26428,8 @@ export class FleetManager {
25405
26428
  if (previous && signature(previous, name) === signature(this.fleetConfig, name)
25406
26429
  && (!binding.scoped || this.webModelEnv(backend, name) || this.webModelRefreshes.has(binding.key)))
25407
26430
  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"));
26431
+ const work = this.discoverModels(backend, name, binding);
26432
+ void work?.catch(err => this.logger.debug({ backend, name, err }, "Background model discovery failed"));
25412
26433
  }
25413
26434
  }
25414
26435
  /** Best-effort model list for `/model`: cached CLI env first, else live probe. Never throws. */
@@ -26282,12 +27303,40 @@ export class FleetManager {
26282
27303
  this.fleetConfig.instances[instanceName].effort = applied;
26283
27304
  this.saveFleetConfig();
26284
27305
  }
27306
+ // M-3180: a CLI with a verified in-session switch (CLI_RUNTIME_SWITCH) — typed when it can be, confirmed, else restarted.
27307
+ // The effort is already saved above, so a restart launches with it.
27308
+ if (this.cliSwitchRouted(instanceName, backendName) && this.instanceIpcClients.get(instanceName)) {
27309
+ const done = await this.runCliRuntimeSwitch(instanceName, backendName, { model: null, effort: applied });
27310
+ if (opts?.current && !opts.current())
27311
+ return t("menu.instance_replaced", this.shownInstanceName(instanceName));
27312
+ if (done.result.outcome === "switched")
27313
+ return `${warn}${t("effort.codex_switched", instanceName, applied)}`;
27314
+ const why = this.cliSwitchFallbackReason(backendName, done);
27315
+ this.logger.info({ instanceName, backend: backendName, effort: applied, result: done.result }, "CLI runtime effort switch fell back to a restart");
27316
+ await this.restartSingleInstance(instanceName, { ownerCurrent: opts?.current });
27317
+ return `${warn}${t("effort.codex_restarted", instanceName, applied, why)}`;
27318
+ }
26285
27319
  if (strategy === "runtime") {
26286
27320
  if (!this.instanceIpcClients.get(instanceName))
26287
27321
  return `${warn}${t("effort.not_running", instanceName)}`;
26288
27322
  this.pasteRawToClassicInstance(instanceName, `/effort ${applied}`);
26289
27323
  return `${warn}${t("effort.runtime_success", instanceName, applied)}`;
26290
27324
  }
27325
+ // M-3175: codex 0.164+ takes the effort in the running session (`/model [MODEL] --reasoning=L`, its configured model named
27326
+ // when known); restarted when the switch was not typed or not confirmed. The effort is already saved above.
27327
+ if (backendName === "codex" && this.instanceIpcClients.get(instanceName)) {
27328
+ const resolved = this.resolveInstanceModel(instanceName);
27329
+ const model = resolved.source === "instance" || resolved.source === "fleet-default" ? resolved.model : null;
27330
+ const result = await this.runCodexRuntimeSwitch(instanceName, model, applied);
27331
+ if (opts?.current && !opts.current())
27332
+ return t("menu.instance_replaced", this.shownInstanceName(instanceName));
27333
+ if (result.outcome === "switched")
27334
+ return `${warn}${t("effort.codex_switched", instanceName, applied)}`;
27335
+ const why = this.codexSwitchFallbackReason(result);
27336
+ this.logger.info({ instanceName, effort: applied, result }, "Codex runtime effort switch fell back to a restart");
27337
+ await this.restartSingleInstance(instanceName, { ownerCurrent: opts?.current });
27338
+ return `${warn}${t("effort.codex_restarted", instanceName, applied, why)}`;
27339
+ }
26291
27340
  await this.restartSingleInstance(instanceName, { ownerCurrent: opts?.current });
26292
27341
  return `${warn}${t("effort.restart_success", instanceName, applied)}`;
26293
27342
  }
@@ -26349,6 +27398,40 @@ export class FleetManager {
26349
27398
  : t("model.switch_unconfirmed", instanceName, model, Math.round(RUNTIME_SWITCH_RESULT_MS / 1000));
26350
27399
  return `${warn}${head}${this.effortSuffix(instanceName)}`;
26351
27400
  }
27401
+ // M-3175: codex 0.164+ switches in the running session; saved first (a fallback restart launches from it), restarted when
27402
+ // the switch was not typed or not confirmed.
27403
+ if (backendName === "codex" && this.instanceIpcClients.get(instanceName)) {
27404
+ if (!this.persistInstanceModel(instanceName, model))
27405
+ return `${warn}${t("model.persist_failed", instanceName)}`;
27406
+ const effort = this.codexSwitchEffort(instanceName, model);
27407
+ const result = await this.runCodexRuntimeSwitch(instanceName, model, effort);
27408
+ if (opts?.current && !opts.current())
27409
+ return t("menu.instance_replaced", this.shownInstanceName(instanceName));
27410
+ if (result.outcome === "switched")
27411
+ return `${warn}${t("model.codex_switched", instanceName, model)}${this.effortSuffix(instanceName)}`;
27412
+ const why = this.codexSwitchFallbackReason(result);
27413
+ this.logger.info({ instanceName, model, result }, "Codex runtime model switch fell back to a restart");
27414
+ await this.restartSingleInstance(instanceName, { ownerCurrent: opts?.current });
27415
+ return `${warn}${t("model.codex_restarted", instanceName, model, why)}${this.effortSuffix(instanceName)}`;
27416
+ }
27417
+ // M-3180: the same for a CLI with a verified in-session switch (CLI_RUNTIME_SWITCH): saved first, switched in place when
27418
+ // it can be and confirmed, else restarted (as these CLIs always were).
27419
+ if (this.cliSwitchRouted(instanceName, backendName) && this.instanceIpcClients.get(instanceName)) {
27420
+ if (!this.persistInstanceModel(instanceName, model))
27421
+ return `${warn}${t("model.persist_failed", instanceName)}`;
27422
+ const entry = CLI_RUNTIME_SWITCH[backendName];
27423
+ const effort = this.codexSwitchEffort(instanceName, model); // configured level, only when the target model supports it
27424
+ const want = entry.modelWant?.(model, effort) ?? { model, effort: null };
27425
+ const done = await this.runCliRuntimeSwitch(instanceName, backendName, want);
27426
+ if (opts?.current && !opts.current())
27427
+ return t("menu.instance_replaced", this.shownInstanceName(instanceName));
27428
+ if (done.result.outcome === "switched")
27429
+ return `${warn}${t("model.codex_switched", instanceName, model)}${this.effortSuffix(instanceName)}`;
27430
+ const why = this.cliSwitchFallbackReason(backendName, done);
27431
+ this.logger.info({ instanceName, backend: backendName, model, result: done.result }, "CLI runtime model switch fell back to a restart");
27432
+ await this.restartSingleInstance(instanceName, { ownerCurrent: opts?.current });
27433
+ return `${warn}${t("model.codex_restarted", instanceName, model, why)}${this.effortSuffix(instanceName)}`;
27434
+ }
26352
27435
  // Persist either way: a runtime switch must survive the next respawn too,
26353
27436
  // or the instance silently reverts to the CLI default after a fleet restart.
26354
27437
  if (!this.persistInstanceModel(instanceName, model))
@@ -26560,11 +27643,22 @@ export class FleetManager {
26560
27643
  return shapeWebModelCatalog(backend, env?.models ?? [], env?.apiModels ?? []);
26561
27644
  }
26562
27645
  /** Explicit, bounded vendor rediscovery. Never publish an answer under a different account/config/instance. */
26563
- async refreshModelCatalogFor(backend, instance, selection) {
27646
+ async refreshModelCatalogFor(backend, instance, selection, opts = {}) {
26564
27647
  const binding = this.webModelBinding(backend, instance, selection);
26565
27648
  if (!binding || this.shuttingDown)
26566
27649
  return { models: [], refreshed: false };
26567
27650
  const pending = this.webModelRefreshes.get(binding.key);
27651
+ if (pending && opts.afterSignIn) {
27652
+ // A sign-in changes the credentials, not the binding key, so a flight started before it is answering as the signed-out
27653
+ // account. Join it for admission (the worker limit), then read once more as the signed-in one; sign-ins that land on the
27654
+ // same flight meet in that one read (the second finds the first's flight).
27655
+ return pending.catch(() => null).then(() => {
27656
+ const next = this.webModelBinding(backend, instance, selection);
27657
+ if (next?.key !== binding.key)
27658
+ return { models: [], refreshed: false };
27659
+ return this.refreshModelCatalogFor(backend, instance, selection);
27660
+ });
27661
+ }
26568
27662
  if (pending)
26569
27663
  return pending;
26570
27664
  const epoch = this.cliEnvProbeEpoch;
@@ -26582,7 +27676,11 @@ export class FleetManager {
26582
27676
  return { models: this.modelCatalogFor(backend, instance, selection), refreshed: false };
26583
27677
  if (this.webModelCatalogs.size >= 64)
26584
27678
  this.webModelCatalogs.delete(this.webModelCatalogs.keys().next().value);
27679
+ const listed = (models) => models.map(m => m.id).join("\0");
27680
+ const before = listed(this.webModelEnv(backend, instance, selection)?.models ?? []);
26585
27681
  this.webModelCatalogs.set(binding.key, { ...result, backend, probedAt: Date.now() });
27682
+ if (listed(result.models) !== before)
27683
+ this.announceModels(backend);
26586
27684
  return { models: this.modelCatalogFor(backend, instance, selection), refreshed: true };
26587
27685
  }).finally(() => { if (this.webModelRefreshes.get(binding.key) === work)
26588
27686
  this.webModelRefreshes.delete(binding.key); });
@@ -27241,6 +28339,9 @@ export class FleetManager {
27241
28339
  async handleClassicStop(channelId, adapterId) {
27242
28340
  if (!this.classicChannels)
27243
28341
  return t("classic.manager_unavailable");
28342
+ const previous = this.classicChannels.getInstanceByChannel(channelId, adapterId);
28343
+ if (previous)
28344
+ this.forgetHubAgentIncarnation(previous, true);
27244
28345
  const ch = this.classicChannels.unregister(channelId, adapterId);
27245
28346
  if (!ch)
27246
28347
  return t("classic.no_agent");
@@ -27413,6 +28514,9 @@ export class FleetManager {
27413
28514
  const settingsControl = this.settingsControl;
27414
28515
  this.settingsControl = null;
27415
28516
  const settingsControlStopped = settingsControl?.close();
28517
+ const ownerAppControl = this.ownerAppControl;
28518
+ this.ownerAppControl = null;
28519
+ const ownerAppStopped = ownerAppControl?.close();
27416
28520
  this.publicLinkAutoOpen?.stop();
27417
28521
  const publicStopped = this.publicWebLink?.close("fleet shutdown");
27418
28522
  this.webRemoteAccessState?.close(); // #3008: an unsaved switch gets its last write
@@ -27427,7 +28531,7 @@ export class FleetManager {
27427
28531
  // ledger flush completes before process.exit(0) in doStopAll's caller.
27428
28532
  const cacheStopped = this.cacheService?.stop() ?? Promise.resolve();
27429
28533
  // #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();
28534
+ 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
28535
  const profileStopped = this.runtimeCpuProfiler?.shutdown("fleet shutdown");
27432
28536
  // S-51: the Hub closes in the same drain, bounded so an unanswering listener does not hold the shutdown.
27433
28537
  const hubInit = this.hubRuntimeInit, hubNow = this.hubRuntime;
@@ -27479,6 +28583,7 @@ export class FleetManager {
27479
28583
  await hubStopped;
27480
28584
  await needsStopped;
27481
28585
  await settingsControlStopped;
28586
+ await ownerAppStopped;
27482
28587
  await cacheStopped;
27483
28588
  await quotaNoticesStopped;
27484
28589
  this.quotaNotices = null;
@@ -27845,6 +28950,8 @@ export class FleetManager {
27845
28950
  this.probeChangedCliEnvs(oldConfig);
27846
28951
  this.migrateOfficeStorage();
27847
28952
  this.migrateNoticeDeliveryStorage();
28953
+ this.namedLinkDefaultChecked = false;
28954
+ this.migrateNamedLinkDefault(); // M-3277 F1: a reloaded file is checked again
27848
28955
  // Classic behavior settings share the fleet defaults but are not entries
27849
28956
  // in fleet.yaml. Snapshot the old effective chain before reloading the
27850
28957
  // Classic file so SIGHUP can hot-apply either source without waiting for
@@ -27866,8 +28973,10 @@ export class FleetManager {
27866
28973
  ?? this.classicChannels.getReplyCompletionGuard(ch.channelId, ch.adapterId, oldConfig?.defaults?.reply_completion_guard),
27867
28974
  });
27868
28975
  }
27869
- if (this.classicChannels.checkReload())
28976
+ if (this.classicChannels.checkReload()) {
28977
+ this.observeHubAgentIncarnations();
27870
28978
  this.reportClassicUnrecoverableIds();
28979
+ }
27871
28980
  }
27872
28981
  this.routing.rebuild(this.fleetConfig);
27873
28982
  this.reregisterClassicChannels();
@@ -27923,10 +29032,21 @@ export class FleetManager {
27923
29032
  if (!this.daemons.has(name)) {
27924
29033
  // New instance — startInstance already calls connectIpcToInstance. #2482: a paused one is not started (startInstance
27925
29034
  // returns at its pause); say so, quietly, instead of "starting" on every reload.
27926
- if (this.lifecycle.isPaused(name))
29035
+ if (this.lifecycle.isPaused(name)) {
27927
29036
  this.logger.debug({ name }, "Paused instance in config — not started");
27928
- else
27929
- this.logger.info({ name }, "New instance in config — starting");
29037
+ continue;
29038
+ }
29039
+ const previous = oldConfig?.instances[name];
29040
+ const change = previous ? classifyInstanceChange(previous, config) : "restart";
29041
+ // A Settings apply (observe set) of an unrelated fleet field must not start or list every
29042
+ // stopped agent whose instance block did not change (M-3165). SIGHUP still recovers missing ones.
29043
+ if (observe && change === "none")
29044
+ continue;
29045
+ this.logger.info({ name }, !previous
29046
+ ? "New instance in config — starting"
29047
+ : change === "none"
29048
+ ? "Instance not running — starting"
29049
+ : "Instance config changed — starting");
27930
29050
  observe?.(name, "restart", "running");
27931
29051
  await this.startInstanceUnattended(name, config, topicMode, "new instance");
27932
29052
  observe?.(name, "restart", "done");
@@ -29420,13 +30540,15 @@ export class FleetManager {
29420
30540
  const classicNames = new Set(this.classicChannels?.getAll().map(ch => ch.instanceName) ?? []);
29421
30541
  for (const [name, config] of Object.entries(next)) {
29422
30542
  const daemon = this.daemons.get(name);
29423
- if (!daemon) {
29424
- rows.push({ target: name, kind: "restart" });
30543
+ // Compare the live snapshot when we have one; otherwise the in-memory instance
30544
+ // (last load). "No daemon" is not itself a change — parked / other-team agents
30545
+ // whose YAML block is untouched must not appear as "restart this agent" (M-3165).
30546
+ const runtime = daemon?.getConfigSnapshot?.() ?? this.fleetConfig?.instances[name];
30547
+ if (!runtime) {
30548
+ if (!this.lifecycle.isPaused(name))
30549
+ rows.push({ target: name, kind: "restart" });
29425
30550
  continue;
29426
30551
  }
29427
- const runtime = daemon.getConfigSnapshot?.();
29428
- if (!runtime)
29429
- continue;
29430
30552
  const change = classifyInstanceChange(runtime, config);
29431
30553
  if (change !== "none")
29432
30554
  rows.push({ target: name, kind: change === "restart" ? "restart" : "hot" });
@@ -29802,6 +30924,7 @@ export class FleetManager {
29802
30924
  catch {
29803
30925
  this.recordUpdateCheck(currentVersion, null); /* silent — network issues */
29804
30926
  }
30927
+ await this.maybeNotifyHubRecommendation(); // M-3140: the 7-day reminder rides the daily check
29805
30928
  }
29806
30929
  // ── M-2738: updating from the web (src/web-update.ts) ───────────────
29807
30930
  /** The web's update routes (web-api.ts handleWebUpdate) read and start through this. */
@@ -29814,11 +30937,12 @@ export class FleetManager {
29814
30937
  }
29815
30938
  catch { /* unknown: the page compares nothing */ }
29816
30939
  const s = this.updateCheckState;
29817
- return { current, offer: s?.offer ?? null, checkedAt: s?.checkedAt ?? null, checkFailed: s?.failed ?? false };
30940
+ return { current, offer: s?.offer ?? null, hubRecommendation: this.hubRecommendedUpdate(), checkedAt: s?.checkedAt ?? null, checkFailed: s?.failed ?? false };
29818
30941
  },
29819
30942
  checkUpdateNow: () => this.checkUpdateNow(),
29820
30943
  updateProgress: () => webProgressOf(readUpdateProgress(this.dataDir)),
29821
- startWebUpdate: (key, person, stillAllowed) => this.startWebUpdateOnce(key, person, stillAllowed),
30944
+ startWebUpdate: (key, person, stillAllowed, pin) => this.startWebUpdateOnce(key, person, stillAllowed, pin),
30945
+ startHubRequestedUpdate: (key, person, stillAllowed, id) => this.startHubRequestedUpdateOnce(key, person, stillAllowed, id),
29822
30946
  updateLog: () => ({ text: readLogTail(updateLogPath(this.dataDir)), error: readUpdateProgress(this.dataDir)?.progress.error ?? null }),
29823
30947
  };
29824
30948
  }
@@ -29860,14 +30984,32 @@ export class FleetManager {
29860
30984
  * last check offers as installable; the update itself is chat `/update`'s (launchInstalledUpdate). Its progress marker
29861
30985
  * targets no chat message (WEB_UPDATE_ADAPTER); the page reads the stages the updater writes into it.
29862
30986
  */
29863
- async startWebUpdate(person, stillAllowed) {
30987
+ async startWebUpdate(person, stillAllowed, pin, hubRequestId) {
29864
30988
  if (this.shuttingDown)
29865
30989
  return { ok: false, status: 409, error: "stopping" };
29866
30990
  // Synchronous from here to the claim: a second start cannot slip in between on the event loop.
29867
30991
  if (this.webUpdateOwned || isUpdateInProgress(this.dataDir))
29868
30992
  return { ok: false, status: 409, error: "update_running" };
29869
- const offer = this.updateCheckState?.offer;
29870
- if (!offer?.installable)
30993
+ // M-3140: Update pinned to the Hub's recommendation. The page only names which advice it was shown; the version is
30994
+ // this Fleet's own verified view, re-read now (and again at the launch) — a page's word never chooses what installs.
30995
+ let pinned;
30996
+ const requestOwner = this.hubUpdates;
30997
+ if (hubRequestId) {
30998
+ const version = requestOwner?.manualCandidate(hubRequestId);
30999
+ if (!version || !this.semverGt(version, this.runningAgendVersion()))
31000
+ return { ok: false, status: 409, error: "request_changed" };
31001
+ pinned = version;
31002
+ }
31003
+ if (pin) {
31004
+ const advice = this.hubRecommendationFor(pin);
31005
+ if (!advice)
31006
+ return { ok: false, status: 409, error: "recommendation_changed" };
31007
+ pinned = advice.version;
31008
+ }
31009
+ const offer = pinned ? { version: pinned } : this.updateCheckState?.offer;
31010
+ if (!pinned && !this.updateCheckState?.offer?.installable)
31011
+ return { ok: false, status: 409, error: "nothing_to_install" };
31012
+ if (!offer)
29871
31013
  return { ok: false, status: 409, error: "nothing_to_install" };
29872
31014
  const startedAt = Date.now();
29873
31015
  const claim = { startedAt };
@@ -29883,7 +31025,8 @@ export class FleetManager {
29883
31025
  }
29884
31026
  const origin = `web update by ${person}`;
29885
31027
  // 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 => {
31028
+ void this.launchInstalledUpdate(origin, () => !this.shuttingDown && stillAllowed() && (!pin || this.hubRecommendationFor(pin) !== null)
31029
+ && (!hubRequestId || this.hubUpdates === requestOwner && requestOwner?.manualCandidate(hubRequestId) === pinned), pinned).then(child => {
29887
31030
  if (!child) {
29888
31031
  release();
29889
31032
  return;
@@ -29898,17 +31041,44 @@ export class FleetManager {
29898
31041
  return { ok: true };
29899
31042
  }
29900
31043
  /** M-2738: a web start's answer for its key, the same on a retry (at most 32 kept). */
29901
- startWebUpdateOnce(key, person, stillAllowed) {
31044
+ startWebUpdateOnce(key, person, stillAllowed, pin) {
29902
31045
  // Prism #3505 P3: reserved before anything is awaited — a concurrent request with the same key shares this answer.
29903
31046
  const known = this.webUpdateStarts.get(key);
29904
31047
  if (known)
29905
31048
  return known;
29906
- const answer = this.startWebUpdate(person, stillAllowed);
31049
+ const answer = this.startWebUpdate(person, stillAllowed, pin);
29907
31050
  this.webUpdateStarts.set(key, answer);
29908
31051
  while (this.webUpdateStarts.size > 32)
29909
31052
  this.webUpdateStarts.delete(this.webUpdateStarts.keys().next().value);
29910
31053
  return answer;
29911
31054
  }
31055
+ startHubRequestedUpdateOnce(key, person, stillAllowed, id) {
31056
+ const cacheKey = JSON.stringify(["hub-request", person, id, key]);
31057
+ const known = this.webUpdateStarts.get(cacheKey);
31058
+ if (known)
31059
+ return known;
31060
+ const answer = (async () => {
31061
+ const owner = this.hubUpdates, request = owner?.view(id);
31062
+ if (!owner || !request || !owner.manualCandidate(id))
31063
+ return { ok: false, status: 404, error: "request_not_found" };
31064
+ const current = () => !this.shuttingDown && this.hubUpdates === owner && stillAllowed();
31065
+ if (!current())
31066
+ return { ok: false, status: 403, error: "not_authorized" };
31067
+ if (request.state === "waiting") {
31068
+ if (this.webUpdateOwned || isUpdateInProgress(this.dataDir))
31069
+ return { ok: false, status: 409, error: "update_running" };
31070
+ return await owner.updateNow(id, current) ? { ok: true } : { ok: false, status: 409, error: "update_not_started" };
31071
+ }
31072
+ // An expired request's button is a new, explicitly confirmed local update. Its old Hub result stays expired.
31073
+ if (request.state === "expired")
31074
+ return this.startWebUpdate(person, current, undefined, id);
31075
+ return { ok: false, status: 409, error: request.state === "updating" ? "update_running" : "request_changed" };
31076
+ })();
31077
+ this.webUpdateStarts.set(cacheKey, answer);
31078
+ while (this.webUpdateStarts.size > 32)
31079
+ this.webUpdateStarts.delete(this.webUpdateStarts.keys().next().value);
31080
+ return answer;
31081
+ }
29912
31082
  /**
29913
31083
  * Semver "a > b". Compares major.minor.patch numerically; a version without a
29914
31084
  * prerelease outranks the same core with one (2.0.8 > 2.0.8-beta.16); two
@@ -30275,6 +31445,7 @@ export class FleetManager {
30275
31445
  // §3.2: a stream that connects reads its rooms again (in the background; at most once a minute).
30276
31446
  streamOpened: () => { void this.refreshGuestRooms(owner, { mode: "force" }); },
30277
31447
  history: () => this.webChatHistory,
31448
+ mentionNames: (instance, query) => this.guestMentionNames(owner, instance, query),
30278
31449
  // #1920 §5.1: guests chat unless the host made them read-only (web.guests.chat: false).
30279
31450
  chat: () => this.fleetConfig?.web?.guests?.chat !== false,
30280
31451
  // #2855: the admin's level for this guest, read at each request (a change applies at once).