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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (298) hide show
  1. package/dist/accounts-view.d.ts +29 -0
  2. package/dist/accounts-view.js +2 -14
  3. package/dist/accounts-view.js.map +1 -1
  4. package/dist/agent-endpoint.d.ts +1 -0
  5. package/dist/agent-endpoint.js +4 -2
  6. package/dist/agent-endpoint.js.map +1 -1
  7. package/dist/auth-api.d.ts +2 -0
  8. package/dist/auth-api.js +29 -2
  9. package/dist/auth-api.js.map +1 -1
  10. package/dist/backend/claude-code.js +35 -9
  11. package/dist/backend/claude-code.js.map +1 -1
  12. package/dist/backend/codex-precaution.d.ts +7 -0
  13. package/dist/backend/codex-precaution.js +102 -0
  14. package/dist/backend/codex-precaution.js.map +1 -0
  15. package/dist/backend/codex.d.ts +1 -0
  16. package/dist/backend/codex.js +18 -0
  17. package/dist/backend/codex.js.map +1 -1
  18. package/dist/backend/grok.js +21 -6
  19. package/dist/backend/grok.js.map +1 -1
  20. package/dist/backend/types.d.ts +9 -1
  21. package/dist/backend/types.js.map +1 -1
  22. package/dist/build-provenance.json +1 -1
  23. package/dist/channel/mcp-server.js +1 -1
  24. package/dist/channel/mcp-server.js.map +1 -1
  25. package/dist/channel/mcp-tools.js +3 -1
  26. package/dist/channel/mcp-tools.js.map +1 -1
  27. package/dist/claude-install-kind.d.ts +19 -0
  28. package/dist/claude-install-kind.js +54 -0
  29. package/dist/claude-install-kind.js.map +1 -0
  30. package/dist/cli-audited.js +3 -3
  31. package/dist/cli-audited.js.map +1 -1
  32. package/dist/daemon.d.ts +5 -0
  33. package/dist/daemon.js +22 -4
  34. package/dist/daemon.js.map +1 -1
  35. package/dist/event-log.d.ts +12 -0
  36. package/dist/event-log.js +40 -0
  37. package/dist/event-log.js.map +1 -1
  38. package/dist/fleet-manager.d.ts +122 -2
  39. package/dist/fleet-manager.js +482 -27
  40. package/dist/fleet-manager.js.map +1 -1
  41. package/dist/general-knowledge/skills/hub/SKILL.md +38 -6
  42. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +16 -1
  43. package/dist/hub/admin-dashboard.js +3 -3
  44. package/dist/hub/admin-dashboard.js.map +1 -1
  45. package/dist/hub/agent-catalog-model.d.ts +276 -0
  46. package/dist/hub/agent-catalog-model.js +49 -0
  47. package/dist/hub/agent-catalog-model.js.map +1 -0
  48. package/dist/hub/agent-catalog.d.ts +137 -0
  49. package/dist/hub/agent-catalog.js +118 -0
  50. package/dist/hub/agent-catalog.js.map +1 -0
  51. package/dist/hub/agent-intro-model.d.ts +38 -0
  52. package/dist/hub/agent-intro-model.js +14 -0
  53. package/dist/hub/agent-intro-model.js.map +1 -0
  54. package/dist/hub/agent-intro-tool.d.ts +35 -0
  55. package/dist/hub/agent-intro-tool.js +83 -0
  56. package/dist/hub/agent-intro-tool.js.map +1 -0
  57. package/dist/hub/agent-intro.d.ts +31 -0
  58. package/dist/hub/agent-intro.js +51 -0
  59. package/dist/hub/agent-intro.js.map +1 -0
  60. package/dist/hub/catalog.d.ts +4 -2
  61. package/dist/hub/catalog.js +19 -3
  62. package/dist/hub/catalog.js.map +1 -1
  63. package/dist/hub/client.d.ts +3 -0
  64. package/dist/hub/client.js +47 -1
  65. package/dist/hub/client.js.map +1 -1
  66. package/dist/hub/compose/member.d.ts +19 -5
  67. package/dist/hub/compose/member.js +94 -13
  68. package/dist/hub/compose/member.js.map +1 -1
  69. package/dist/hub/compose/server.d.ts +5 -0
  70. package/dist/hub/compose/server.js +6 -1
  71. package/dist/hub/compose/server.js.map +1 -1
  72. package/dist/hub/execution/service.d.ts +1 -1
  73. package/dist/hub/execution/service.js +1 -0
  74. package/dist/hub/execution/service.js.map +1 -1
  75. package/dist/hub/http/compose.d.ts +3 -0
  76. package/dist/hub/http/compose.js +122 -15
  77. package/dist/hub/http/compose.js.map +1 -1
  78. package/dist/hub/http/schema.js +15 -0
  79. package/dist/hub/http/schema.js.map +1 -1
  80. package/dist/hub/mcp/tools.js +2 -1
  81. package/dist/hub/mcp/tools.js.map +1 -1
  82. package/dist/hub/member/agent-catalog.d.ts +28 -0
  83. package/dist/hub/member/agent-catalog.js +80 -0
  84. package/dist/hub/member/agent-catalog.js.map +1 -0
  85. package/dist/hub/member/agent-intro.d.ts +28 -0
  86. package/dist/hub/member/agent-intro.js +66 -0
  87. package/dist/hub/member/agent-intro.js.map +1 -0
  88. package/dist/hub/member/exposure-api.d.ts +3 -3
  89. package/dist/hub/member/exposure-api.js +4 -4
  90. package/dist/hub/member/exposure-api.js.map +1 -1
  91. package/dist/hub/member/exposures.d.ts +12 -4
  92. package/dist/hub/member/exposures.js +27 -13
  93. package/dist/hub/member/exposures.js.map +1 -1
  94. package/dist/hub/member/room-ask.d.ts +14 -1
  95. package/dist/hub/member/room-ask.js +76 -10
  96. package/dist/hub/member/room-ask.js.map +1 -1
  97. package/dist/hub/member/room-context-budget.d.ts +5 -0
  98. package/dist/hub/member/room-context-budget.js +34 -0
  99. package/dist/hub/member/room-context-budget.js.map +1 -0
  100. package/dist/hub/member/room-notification.d.ts +1 -1
  101. package/dist/hub/member/room-post.d.ts +6 -3
  102. package/dist/hub/member/room-post.js +9 -3
  103. package/dist/hub/member/room-post.js.map +1 -1
  104. package/dist/hub/member/sharing-journal.d.ts +252 -0
  105. package/dist/hub/member/sharing-journal.js +212 -0
  106. package/dist/hub/member/sharing-journal.js.map +1 -0
  107. package/dist/hub/member/sharing-link.d.ts +25 -0
  108. package/dist/hub/member/sharing-link.js +68 -0
  109. package/dist/hub/member/sharing-link.js.map +1 -0
  110. package/dist/hub/member/sharing-result.d.ts +6 -0
  111. package/dist/hub/member/sharing-result.js +46 -0
  112. package/dist/hub/member/sharing-result.js.map +1 -0
  113. package/dist/hub/member/sharing.d.ts +37 -0
  114. package/dist/hub/member/sharing.js +181 -0
  115. package/dist/hub/member/sharing.js.map +1 -0
  116. package/dist/hub/personal/owner-host.d.ts +6 -0
  117. package/dist/hub/personal/owner-host.js +4 -2
  118. package/dist/hub/personal/owner-host.js.map +1 -1
  119. package/dist/hub/protocol.d.ts +398 -4
  120. package/dist/hub/protocol.js +13 -5
  121. package/dist/hub/protocol.js.map +1 -1
  122. package/dist/hub/room-answer-status-model.d.ts +3 -0
  123. package/dist/hub/room-answer-status-model.js +4 -0
  124. package/dist/hub/room-answer-status-model.js.map +1 -0
  125. package/dist/hub/room-brief-model.d.ts +30 -0
  126. package/dist/hub/room-brief-model.js +37 -0
  127. package/dist/hub/room-brief-model.js.map +1 -0
  128. package/dist/hub/room-context-model.d.ts +2 -0
  129. package/dist/hub/room-context-model.js +2 -2
  130. package/dist/hub/room-context-model.js.map +1 -1
  131. package/dist/hub/room-members-model.d.ts +63 -0
  132. package/dist/hub/room-members-model.js +7 -0
  133. package/dist/hub/room-members-model.js.map +1 -0
  134. package/dist/hub/rooms/agents.d.ts +1 -0
  135. package/dist/hub/rooms/agents.js +62 -11
  136. package/dist/hub/rooms/agents.js.map +1 -1
  137. package/dist/hub/rooms/brief.d.ts +18 -0
  138. package/dist/hub/rooms/brief.js +39 -0
  139. package/dist/hub/rooms/brief.js.map +1 -0
  140. package/dist/hub/rooms/direct-view.d.ts +5 -1
  141. package/dist/hub/rooms/direct-view.js +2 -2
  142. package/dist/hub/rooms/direct-view.js.map +1 -1
  143. package/dist/hub/rooms/members-page.d.ts +33 -0
  144. package/dist/hub/rooms/members-page.js +37 -0
  145. package/dist/hub/rooms/members-page.js.map +1 -0
  146. package/dist/hub/rooms/purpose.d.ts +7 -0
  147. package/dist/hub/rooms/purpose.js +14 -0
  148. package/dist/hub/rooms/purpose.js.map +1 -0
  149. package/dist/hub/rooms/service.d.ts +43 -0
  150. package/dist/hub/rooms/service.js +80 -22
  151. package/dist/hub/rooms/service.js.map +1 -1
  152. package/dist/hub/rooms/types.d.ts +6 -1
  153. package/dist/hub/rooms.d.ts +1 -0
  154. package/dist/hub/rooms.js +9 -4
  155. package/dist/hub/rooms.js.map +1 -1
  156. package/dist/hub/runtime.d.ts +1 -1
  157. package/dist/hub/server.js +49 -1
  158. package/dist/hub/server.js.map +1 -1
  159. package/dist/hub/sharing-previous-access.d.ts +22 -0
  160. package/dist/hub/sharing-previous-access.js +93 -0
  161. package/dist/hub/sharing-previous-access.js.map +1 -0
  162. package/dist/hub/sharing-requests.d.ts +171 -0
  163. package/dist/hub/sharing-requests.js +311 -0
  164. package/dist/hub/sharing-requests.js.map +1 -0
  165. package/dist/hub/sharing-retention.d.ts +47 -0
  166. package/dist/hub/sharing-retention.js +83 -0
  167. package/dist/hub/sharing-retention.js.map +1 -0
  168. package/dist/hub/sharing-withdrawal.d.ts +14 -0
  169. package/dist/hub/sharing-withdrawal.js +28 -0
  170. package/dist/hub/sharing-withdrawal.js.map +1 -0
  171. package/dist/hub/types.d.ts +13 -5
  172. package/dist/hub-page-sharing-settings.d.ts +6 -0
  173. package/dist/hub-page-sharing-settings.js +19 -0
  174. package/dist/hub-page-sharing-settings.js.map +1 -0
  175. package/dist/hub-room-reply-warning.d.ts +2 -0
  176. package/dist/hub-room-reply-warning.js +16 -0
  177. package/dist/hub-room-reply-warning.js.map +1 -0
  178. package/dist/hub-sharing-notice.d.ts +43 -0
  179. package/dist/hub-sharing-notice.js +34 -0
  180. package/dist/hub-sharing-notice.js.map +1 -0
  181. package/dist/instance-lifecycle.d.ts +15 -0
  182. package/dist/instance-lifecycle.js +36 -1
  183. package/dist/instance-lifecycle.js.map +1 -1
  184. package/dist/locale.js +78 -0
  185. package/dist/locale.js.map +1 -1
  186. package/dist/login-controller.d.ts +26 -0
  187. package/dist/login-controller.js +72 -2
  188. package/dist/login-controller.js.map +1 -1
  189. package/dist/login-flows.js +1 -1
  190. package/dist/login-flows.js.map +1 -1
  191. package/dist/native-mcp.js +1 -1
  192. package/dist/native-mcp.js.map +1 -1
  193. package/dist/needs-you-hub.js +1 -1
  194. package/dist/needs-you-hub.js.map +1 -1
  195. package/dist/needs-you.d.ts +8 -1
  196. package/dist/needs-you.js +6 -0
  197. package/dist/needs-you.js.map +1 -1
  198. package/dist/office-share-page.js +1 -1
  199. package/dist/office-share-page.js.map +1 -1
  200. package/dist/outbound-handlers.d.ts +2 -1
  201. package/dist/outbound-handlers.js +17 -4
  202. package/dist/outbound-handlers.js.map +1 -1
  203. package/dist/outbound-schemas.d.ts +10 -0
  204. package/dist/outbound-schemas.js +3 -1
  205. package/dist/outbound-schemas.js.map +1 -1
  206. package/dist/public-web-gateway.js +9 -3
  207. package/dist/public-web-gateway.js.map +1 -1
  208. package/dist/remote-card-answer.d.ts +1 -1
  209. package/dist/remote-card-answer.js +8 -1
  210. package/dist/remote-card-answer.js.map +1 -1
  211. package/dist/remote-card-prompt.js +1 -1
  212. package/dist/remote-card-prompt.js.map +1 -1
  213. package/dist/restart-progress.d.ts +6 -0
  214. package/dist/restart-progress.js +5 -0
  215. package/dist/restart-progress.js.map +1 -1
  216. package/dist/settings-api.d.ts +1 -0
  217. package/dist/settings-api.js +84 -10
  218. package/dist/settings-api.js.map +1 -1
  219. package/dist/settings-baseline.d.ts +3 -0
  220. package/dist/settings-baseline.js +2 -2
  221. package/dist/settings-baseline.js.map +1 -1
  222. package/dist/settings-change.js +1 -0
  223. package/dist/settings-change.js.map +1 -1
  224. package/dist/settings-effect.d.ts +3 -0
  225. package/dist/settings-effect.js +33 -2
  226. package/dist/settings-effect.js.map +1 -1
  227. package/dist/tool-permissions.js +3 -3
  228. package/dist/tool-permissions.js.map +1 -1
  229. package/dist/ui/chat-quote.js +3 -261
  230. package/dist/ui/fleet-office-card.js +8 -4
  231. package/dist/ui/fleet-office-pack.d.ts +1 -0
  232. package/dist/ui/fleet-office-pack.js +6 -2
  233. package/dist/ui/fleet-office-play.js +84 -0
  234. package/dist/ui/fleet-office-store.js +23 -0
  235. package/dist/ui/fleet-office-zones.js +5 -1
  236. package/dist/ui/fleet-office.js +78 -8
  237. package/dist/ui/host-install.js +77 -3
  238. package/dist/ui/hub-agent-intro.js +35 -0
  239. package/dist/ui/hub-attachments.js +81 -3
  240. package/dist/ui/hub-chat-strings.js +4 -4
  241. package/dist/ui/hub-client.js +16 -1
  242. package/dist/ui/hub-grant-picker.js +25 -11
  243. package/dist/ui/hub-group-strings.js +3 -3
  244. package/dist/ui/hub-intro-notice.js +16 -0
  245. package/dist/ui/hub-my-agents-model.js +42 -0
  246. package/dist/ui/hub-my-agents-strings.js +18 -0
  247. package/dist/ui/hub-my-agents.js +144 -0
  248. package/dist/ui/hub-owner-strings.js +5 -5
  249. package/dist/ui/hub-personal-agent.js +5 -4
  250. package/dist/ui/hub-room-composer.js +37 -6
  251. package/dist/ui/hub-room-list.js +4 -3
  252. package/dist/ui/hub-room-members.js +5 -2
  253. package/dist/ui/hub-room-new.js +8 -5
  254. package/dist/ui/hub-room-purpose.js +19 -0
  255. package/dist/ui/hub-room-search.js +1 -1
  256. package/dist/ui/hub-room-settings.js +9 -0
  257. package/dist/ui/hub-room-strings.js +6 -4
  258. package/dist/ui/hub-room-thread.js +70 -17
  259. package/dist/ui/hub-strings.js +5 -5
  260. package/dist/ui/hub-welcome.js +6 -6
  261. package/dist/ui/notice-hub-sharing.js +81 -0
  262. package/dist/ui/panel-chat.js +19 -5
  263. package/dist/ui/panel-hub.js +77 -29
  264. package/dist/ui/panel-notices.js +2 -1
  265. package/dist/ui/settings-hub-connection.js +2 -2
  266. package/dist/ui/settings-hub-page-sharing.js +52 -0
  267. package/dist/ui/settings-hub.js +4 -2
  268. package/dist/ui/settings-registry.js +1 -0
  269. package/dist/ui/shared/app-i18n.js +2 -2
  270. package/dist/ui/shared/app-shell.js +14 -2
  271. package/dist/ui/shared/app-store.js +6 -2
  272. package/dist/ui/shared/app.js +3 -1
  273. package/dist/ui/shared/chat-msg-actions.js +3 -1
  274. package/dist/ui/shared/chat-quote.js +261 -0
  275. package/dist/ui/shared/hub-chat.css +31 -0
  276. package/dist/ui/shared/hub-my-agents.css +35 -0
  277. package/dist/ui/shared/hub-rooms-u2.css +5 -0
  278. package/dist/ui/shared/module-warm.d.ts +3 -0
  279. package/dist/ui/shared/module-warm.js +39 -0
  280. package/dist/web-api.d.ts +21 -5
  281. package/dist/web-api.js +138 -7
  282. package/dist/web-api.js.map +1 -1
  283. package/dist/web-asset-version.d.ts +65 -0
  284. package/dist/web-asset-version.js +259 -0
  285. package/dist/web-asset-version.js.map +1 -0
  286. package/dist/web-host-guard.js +3 -1
  287. package/dist/web-host-guard.js.map +1 -1
  288. package/dist/web-host-install.d.ts +30 -3
  289. package/dist/web-host-install.js +50 -4
  290. package/dist/web-host-install.js.map +1 -1
  291. package/dist/web-notices.d.ts +17 -0
  292. package/dist/web-notices.js +47 -6
  293. package/dist/web-notices.js.map +1 -1
  294. package/dist/web-terminal.d.ts +5 -0
  295. package/dist/web-terminal.js +11 -0
  296. package/dist/web-terminal.js.map +1 -1
  297. package/launcher/agend-install.cjs +48 -7
  298. package/package.json +1 -1
@@ -1,3 +1,6 @@
1
+ import { withHubRoomReplyWarning } from "./hub-room-reply-warning.js";
2
+ import { hubSharingNoticeText } from "./hub-sharing-notice.js";
3
+ import { hubPageSharingSettings } from "./hub-page-sharing-settings.js";
1
4
  import { replyPreviews } from "./reply-preview-spec.js";
2
5
  import { settingsSummary, translatedSummary } from "./settings-summary.js";
3
6
  import { readInstalledBuild } from "./build-provenance.js";
@@ -69,6 +72,7 @@ import { atomicWriteFileSync } from "./atomic-write.js";
69
72
  import { createHash, randomBytes, randomUUID } from "node:crypto";
70
73
  import { freemem, totalmem, homedir, hostname } from "node:os";
71
74
  import { effectiveCpuCount } from "./cpu-quota.js";
75
+ import { realpath } from "node:fs/promises";
72
76
  import { createServer } from "node:http";
73
77
  import { Worker } from "node:worker_threads";
74
78
  import { ProbeWorkerPool } from "./probe-worker-pool.js";
@@ -260,7 +264,7 @@ import { parsePoll } from "./reply-polls.js";
260
264
  import { isUploadRequest, limitRequestReceive, publicAttachment, sweepOrphanedUploads, UPLOAD_REQUEST_TIMEOUT_MS, uploadLimits, WebFileLedger } from "./web-upload.js";
261
265
  import { REPLY_FILES_MAX_BYTES, snapshotReplyFile, sweepReplySnapshots, webFilesDir } from "./web-reply-files.js";
262
266
  import { cardPicture, handleViewRequest, humanCards, identityColors, instanceTeams, isViewPath, personBannerFocus, personIdentityColour, profileIdentities, resolveInstanceIdentity, setPersonBannerFocus, setPersonIdentityColour } from "./view-api.js";
263
- import { autoIdentityColor } from "./web-identity-color.js";
267
+ import { autoIdentityColor, identityColorValue } from "./web-identity-color.js";
264
268
  import { AppearanceTools } from "./web-appearance-tools.js";
265
269
  import { cardVersion, resolveCard } from "./web-card.js";
266
270
  import { ModStore } from "./web-mod-store.js";
@@ -295,7 +299,8 @@ import { resolveUpdateLaunch, openUpdateLog, updateLogPath, watchUpdateLaunch }
295
299
  import { isWebUpdateTarget, readLogTail, RUNNING_AGEND_VERSION, updateOffer, webProgressOf, webUpdateTarget } from "./web-update.js";
296
300
  import { admitProfileLogin, LoginController, LOGIN_TOKEN_RESEND_PREFIX, POST_LOGIN_RECOVERY_DEADLINE_MS } from "./login-controller.js";
297
301
  import { WebBackendLogins, dashboardSignInSupported } from "./web-backend-login.js";
298
- import { WebHostInstalls, hostUpdatePlan } from "./web-host-install.js";
302
+ import { CLAUDE_NPM_PACKAGE, claudeInstallKind, displayHostPath } from "./claude-install-kind.js";
303
+ import { WebHostInstalls, claudeSelfUpdating, hostUpdatePlan, npmUninstallCommand } from "./web-host-install.js";
299
304
  import { cliUpdateView, versionOf } from "./cli-audited.js";
300
305
  import { runBeforeDeadline } from "./deadline.js";
301
306
  import { LoginWindowLock } from "./login-window-lock.js";
@@ -351,6 +356,7 @@ import { sharedRolloutIndex } from "./rollout-index.js";
351
356
  import { TASK_BOARD_ON_NOTICE, dashboardRefusalIn, taskBoardOffIn, taskBoardSwitchedOn } from "./dashboard-permissions.js";
352
357
  import { mayUseTool, resolveToolSet, scheduleOpRefusal, toolForIpcType, toolRefusedMessage, } from "./tool-permissions.js";
353
358
  import { authorizeSession, decideWebGate, loadOrCreateWebToken, readSessionCookies, readWebToken, sessionCookieUpgrade } from "./web-auth.js";
359
+ import { takeAssetVersion, warmAssetVersion } from "./web-asset-version.js";
354
360
  import { bypassesWebGate, handleAuthRequest, serveGuestRefusedPage, serveSigninPage } from "./auth-api.js";
355
361
  import { isWebPageNavigation } from "./web-shell-routes.js";
356
362
  import { guestSessionPolicy, localSessionPolicy, publicLinkSessionPolicy, sessionVia, tokenEpoch, WebSessionStore } from "./web-session.js";
@@ -623,6 +629,7 @@ const CLEAR_CONFIRM_CALLBACK_PREFIX = "clear-confirm:";
623
629
  const KIRO_MIGRATE_CALLBACK_PREFIX = "kiro-migrate:";
624
630
  /** M-3140: Update now on a Hub-recommended-version notice in General ("hub-update:" + 32 hex + ":update" = 50 bytes). */
625
631
  const HUB_UPDATE_CALLBACK_PREFIX = "hub-update:";
632
+ const HUB_SHARING_CALLBACK_PREFIX = "hub-share:";
626
633
  const HUB_FLEET_UPDATE_CALLBACK_PREFIX = "hub-fleet-update:";
627
634
  const KIRO_RECONCILE_CALLBACK_PREFIX = "kiro-reconcile:";
628
635
  /** #2692: a fleet admin's Approve / Reject on an agent's pending skin-pack change, in General. */
@@ -763,6 +770,11 @@ function emojiListFilter(opts) {
763
770
  }
764
771
  /** #1920: a guest's scope until phase 2 derives one: nothing. */
765
772
  const NO_GUEST_SCOPE = new Set();
773
+ /** M-3302: what a delivery log line says of a notice — its first line, places as plain text, at most 100 characters. */
774
+ export function noticePreview(text) {
775
+ const first = stripPlaceRefs(text).split("\n").find(l => l.trim() !== "")?.trim() ?? "";
776
+ return first.length > 100 ? `${first.slice(0, 99)}…` : first;
777
+ }
766
778
  /** #1490 row 27: a restart asked for one lifecycle of an instance after it was stopped, restarted or replaced. */
767
779
  export class RestartSupersededError extends Error {
768
780
  /** `shown`: the instance as the chat list names it (shownInstanceName). */
@@ -1461,7 +1473,7 @@ export class FleetManager {
1461
1473
  return { result: null, error: "Native panes can only read Windows runtime model inventories" };
1462
1474
  return { result: await this.listModelCatalog({ instanceName: target }) };
1463
1475
  }
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",
1476
+ const ops = { hub_set_intro: "hub-set-intro", 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",
1465
1477
  delegate_task: "delegate", request_information: "ask", report_result: "report", delivery_status: "delivery-status" };
1466
1478
  const { nativeAgentAdmissionContext } = await import("./native-agent-admission.js");
1467
1479
  const { dispatchAgentOperation } = await import("./agent-endpoint.js");
@@ -1962,6 +1974,74 @@ export class FleetManager {
1962
1974
  await this.startHubRequestedUpdateOnce(`chat:${nonce}`, `${adapterId}:${data.userId}`, () => this.fleetAdminGate(data.userId ?? "", adapterId) === "ok" && !this.shuttingDown, id);
1963
1975
  return true;
1964
1976
  }
1977
+ hubSharingController = null;
1978
+ pendingHubSharing = new Map();
1979
+ hubSharing() { return this.hubSharingController; }
1980
+ async recordHubSharingNotice(value) {
1981
+ const store = this.webNoticeStore();
1982
+ if (!store)
1983
+ return false;
1984
+ const text = hubSharingNoticeText(value, (key, ...args) => t(key, ...args));
1985
+ const notice = store.upsertSharing(value, text);
1986
+ if (!notice)
1987
+ return false;
1988
+ this.emitSseEvent("notice", { notice, unread: store.unread() });
1989
+ if (value.state === "complete" && !this.webOnlyPromptPlace() && store.startSharingChat(value.key)) {
1990
+ void this.postHubSharingChat(value, text).catch(() => this.logger.warn("Hub sharing chat notice not confirmed; Undo remains in web Notices"));
1991
+ }
1992
+ return true;
1993
+ }
1994
+ async postHubSharingChat(value, text) {
1995
+ const general = this.findGeneralInstance(), controller = this.hubSharingController;
1996
+ if (!general || !controller)
1997
+ return;
1998
+ if (!value.rows.some(row => row.state === "shared" || row.state === "stopped") || Date.now() >= value.undoUntil) {
1999
+ this.notifyInstanceTopic(general, text);
2000
+ return;
2001
+ }
2002
+ const adapter = this.getAdapterForInstance(general), adapterId = this.getInstanceAdapterId(general), chatId = this.getGroupIdForInstance(general);
2003
+ if (!adapter || !adapterId || !chatId)
2004
+ return;
2005
+ const threadId = String(this.fleetConfig?.instances[general]?.topic_id ?? "");
2006
+ const nonce = await this.postNonceButtonPromptOrThrow({ prefix: HUB_SHARING_CALLBACK_PREFIX, alertType: "tip", instanceName: general,
2007
+ adapter, adapterId, chatId, ...(threadId ? { threadId } : {}), message: text, choices: [{ action: "undo", label: t("hub_sharing.undo") }],
2008
+ expiredText: t("hub_sharing.expired"), timeoutMs: Math.max(1, value.undoUntil - Date.now()) });
2009
+ if (this.hubSharingController !== controller || this.shuttingDown)
2010
+ return;
2011
+ this.pendingHubSharing.set(nonce, { key: value.key, controller });
2012
+ const timer = setTimeout(() => this.pendingHubSharing.delete(nonce), Math.max(1, value.undoUntil - Date.now()));
2013
+ timer.unref();
2014
+ }
2015
+ async handleHubSharingCallback(data, adapterId, adapter) {
2016
+ const claimed = this.consumeNonceCallback(HUB_SHARING_CALLBACK_PREFIX, /^hub-share:([0-9a-f]{32}):undo$/, data, adapterId, adapter, { keepText: true, notice: t("hub_sharing.restart") }, userId => this.fleetAdminGate(userId, adapterId) === "ok");
2017
+ if (claimed === null)
2018
+ return false;
2019
+ if (claimed === "consumed")
2020
+ return true;
2021
+ const nonce = data.callbackData.slice(HUB_SHARING_CALLBACK_PREFIX.length, HUB_SHARING_CALLBACK_PREFIX.length + 32);
2022
+ const pending = this.pendingHubSharing.get(nonce);
2023
+ this.pendingHubSharing.delete(nonce);
2024
+ const current = () => !!pending && this.hubSharingController === pending.controller && !this.shuttingDown
2025
+ && this.fleetAdminGate(data.userId ?? "", adapterId) === "ok";
2026
+ let text = t("hub_sharing.restart");
2027
+ if (pending && current()) {
2028
+ try {
2029
+ const value = pending.controller.view(pending.key);
2030
+ if (value && Date.now() >= value.undoUntil)
2031
+ text = t("hub_sharing.expired");
2032
+ else if (value) {
2033
+ const result = await pending.controller.undo(pending.key, `${adapterId}:${data.userId}`, current);
2034
+ text = hubSharingNoticeText(result, (key, ...args) => t(key, ...args));
2035
+ }
2036
+ }
2037
+ catch {
2038
+ text = t("hub_sharing.uncertain");
2039
+ this.logger.warn("Hub sharing Undo not confirmed; use web Notices");
2040
+ }
2041
+ }
2042
+ await this.retireNonceButtons(claimed.entry, claimed.entry.messageId ?? data.messageId, text);
2043
+ return true;
2044
+ }
1965
2045
  hubPairingNotices = null;
1966
2046
  hubMemberPairing() { return this.hubMemberPairingApi; }
1967
2047
  /** Explicit owner Settings read only. A paused binding is not permission to mount or connect a member. */
@@ -2536,6 +2616,10 @@ export class FleetManager {
2536
2616
  // S3c's currentBinding: a fresh, fail-closed read of the pairing state (null unless consistent and connectable).
2537
2617
  boundHub: () => this.hubMemberBinding?.(this.dataDir)?.hubId ?? null,
2538
2618
  agents: () => this.hubMemberAgents(),
2619
+ catalogAgents: () => this.hubCatalogAgents(),
2620
+ sharingNotice: value => this.recordHubSharingNotice(value),
2621
+ attachSharing: controller => { this.hubSharingController = controller; },
2622
+ maxCrossInstanceMessageBytes: () => this.fleetConfig?.defaults?.max_cross_instance_message_bytes,
2539
2623
  // P1 representative mode (docs/design/hub-representative-agent.md): ordinary delivery + the report_result hook.
2540
2624
  representative: {
2541
2625
  quota: agent => this.hubAgentQuota(agent),
@@ -2557,11 +2641,15 @@ export class FleetManager {
2557
2641
  attachPrivateQuestions: read => { this.hubPrivateQuestions = read; },
2558
2642
  attachReacts: handler => { this.hubReacts = handler; },
2559
2643
  },
2644
+ attachAgentIntro: port => { this.hubAgentIntro = port; },
2560
2645
  attachAgentRooms: port => { this.hubAgentRooms = port; this.notifyHubRoomTools(); },
2561
2646
  roomToolsChanged: () => this.notifyHubRoomTools(),
2562
2647
  roomConversationGeneration: agent => this.daemons.get(agent)?.roomConversationGeneration() ?? null,
2563
2648
  attachRoomInputs: handler => { this.hubRoomInput = handler; },
2649
+ attachRoomOwed: port => { this.hubRoomOwed = port; },
2564
2650
  roomNotify: input => this.deliverHubRoomNotification(input),
2651
+ // M-3313: a sign-in token in what the Hub sends is taken back the moment the link receives it.
2652
+ sawText: text => this.sawHubText(text),
2565
2653
  roomReceipt: (caller, receiptId) => verifyRoomReceipt({
2566
2654
  lookup: (agent, id) => {
2567
2655
  const item = this.queryDurableDeliveryStatus(agent, { messageId: id }).items[0];
@@ -2662,6 +2750,28 @@ export class FleetManager {
2662
2750
  return [...fleet, ...(this.classicChannels?.getAll() ?? []).filter(ch => !Object.hasOwn(this.fleetConfig?.instances ?? {}, ch.instanceName))
2663
2751
  .map(ch => ({ name: ch.instanceName, display: ch.displayName || ch.name, kind: "classic-room" }))];
2664
2752
  }
2753
+ /** Owner-only cosmetic inventory. Lifecycle tokens only fence its digest; no paths or tools are projected. */
2754
+ hubCatalogAgents() {
2755
+ const profiles = profileIdentities(this.dataDir), colors = identityColors(this.dataDir);
2756
+ const rooms = new Map((this.classicChannels?.getAll() ?? []).map(room => [room.instanceName, room]));
2757
+ return this.hubMemberAgents().map(agent => {
2758
+ const config = this.hubAgentConfig(agent.name), room = rooms.get(agent.name);
2759
+ const identity = resolveInstanceIdentity({ cfg: config, classic: room, profile: profiles.get(agent.name) });
2760
+ const avatar = avatarFor({ name: agent.name, displayName: identity.display_name,
2761
+ personaEmoji: config?.status_emojis?.delivered });
2762
+ let color = colors.get(agent.name)?.color ? identityColorValue(colors.get(agent.name).color, "light") : null;
2763
+ try {
2764
+ color ??= this.webIdentityImage(agent.name, identity.display_name, null, { own: new Map(), speaking: new Map() }).agentColor ?? null;
2765
+ }
2766
+ catch { /* no cosmetic fallback data */ }
2767
+ const base = { instance: agent.name, displayName: identity.display_name || agent.display,
2768
+ description: identity.description ?? room?.description ?? "", avatar: { emoji: avatar.kind === "emoji" && "text" in avatar ? avatar.text : null, color: color ?? identityColorValue(autoIdentityColor(agent.name), "light") },
2769
+ kind: agent.kind ?? "agent", general: config?.general_topic === true, incarnation: this.hubAgentToken(agent.name) };
2770
+ return !config || !base.incarnation ? { ...base, shareable: false, reason: "delivery-unavailable" }
2771
+ : isNativeExecInstance(config) ? { ...base, shareable: false, reason: "remote-windows" }
2772
+ : { ...base, shareable: true };
2773
+ });
2774
+ }
2665
2775
  /** The actual launch target, including Classic's own effective backend/folder; never aliases a room to a Fleet topic. */
2666
2776
  hubAgentConfig(agent) {
2667
2777
  const instances = this.fleetConfig?.instances ?? {};
@@ -2924,6 +3034,32 @@ export class FleetManager {
2924
3034
  return this.hubContactWindows ??= new HubContactWindows(join(this.dataDir, "hub-contact-windows.json"));
2925
3035
  }
2926
3036
  hubContactRestricted(agent) { return this.contactWindows().restricted(agent); }
3037
+ /**
3038
+ * M-3313 (#4145 for the Hub): what a Hub question or room notification hands the agent, with this fleet's sign-in
3039
+ * access token hidden (exact match, as a chat's). The live one is taken back and replaced, and the sign-in's chat told.
3040
+ * The Hub's own copy of the post is beyond the Fleet: it keeps it (encrypted) until its retention deletes it.
3041
+ */
3042
+ /**
3043
+ * M-3313 (Fable #4165 F1): a Hub frame's content as the member link receives it — before it waits for its agent (busy,
3044
+ * paused, offline) or is dropped undelivered — so a live sign-in token in it is taken back at once, not at delivery.
3045
+ * Nothing is changed here: the delivery hides it from the agent (screenHubText).
3046
+ */
3047
+ sawHubText(text) {
3048
+ const screened = this.screenLoginToken(text);
3049
+ if (!screened?.live)
3050
+ return;
3051
+ this.logger.warn("A sign-in access token arrived from the Hub: taken back and replaced");
3052
+ void this.loginController?.tokenPastedElsewhere().catch((err) => this.logger.warn({ err: err.message }, "Taking back a sign-in token pasted on the Hub failed"));
3053
+ }
3054
+ screenHubText(text) {
3055
+ const screened = this.screenLoginToken(text);
3056
+ if (!screened)
3057
+ return text;
3058
+ this.logger.warn("A sign-in access token reached this Fleet in a Hub question: hidden from the agent, taken back and replaced");
3059
+ if (screened.live)
3060
+ void this.loginController?.tokenPastedElsewhere().catch((err) => this.logger.warn({ err: err.message }, "Taking back a sign-in token pasted on the Hub failed"));
3061
+ return screened.text;
3062
+ }
2927
3063
  /**
2928
3064
  * A Hub question to its representative agent: ordinary cross-instance delivery (idle gate, wake, retries), from the
2929
3065
  * reserved Hub sender with the Hub-issued correlation id. beforeInput runs immediately before the IPC hand-off.
@@ -2952,12 +3088,17 @@ export class FleetManager {
2952
3088
  };
2953
3089
  if (input.roomContextGeneration)
2954
3090
  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 () => {
3091
+ const result = await this.deliverToInstance(input.agent, { type: "fleet_inbound", targetSession: input.agent, content: this.screenHubText(input.text), meta: ipcMeta }, { isCrossInstance: true, stillCurrent: input.stillCurrent, beforeInput: async () => {
2956
3092
  const classic = this.isClassicInstance(input.agent);
2957
3093
  // A busy Classic room must finish its public turn first; never force a private question into that turn's queue.
2958
3094
  const idle = () => this.waitForInstanceIdle(input.agent, 0, this.lastDeliveryAt.get(input.agent) ?? 0, () => !input.stillCurrent());
2959
3095
  if (classic && !await idle())
2960
3096
  return false;
3097
+ if (!ipcMeta.hub_room_context_generation && /^hub-room-[a-f0-9-]{36}$/.test(input.correlationId)) {
3098
+ const generation = this.daemons.get(input.agent)?.roomConversationGeneration();
3099
+ if (generation)
3100
+ ipcMeta.hub_room_context_generation = generation;
3101
+ }
2961
3102
  if (!(await input.beforeInput()))
2962
3103
  return false;
2963
3104
  if (classic) {
@@ -2974,13 +3115,14 @@ export class FleetManager {
2974
3115
  }
2975
3116
  async deliverHubRoomNotification(input) {
2976
3117
  const { HUB_REPORT_TARGET } = await import("./hub/representative.js");
2977
- if (this.shuttingDown || !this.fleetConfig?.instances[input.agent] || isNativeExecInstance(this.fleetConfig.instances[input.agent]))
3118
+ const config = input.kind === "answer-reminder" ? this.hubAgentConfig(input.agent) : this.fleetConfig?.instances[input.agent];
3119
+ if (this.shuttingDown || !config || isNativeExecInstance(config))
2978
3120
  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,
3121
+ const prefix = input.kind === "answer-reminder" ? "hub-room-answer-reminder" : input.kind === "mention-feedback" ? "hub-room-mention-feedback" : "hub-room-post-answer";
3122
+ const result = await this.deliverToInstance(input.agent, { type: "fleet_inbound", targetSession: input.agent, content: this.screenHubText(input.text),
2981
3123
  meta: { chat_id: "", message_id: `${prefix}-${input.id}`, user: `instance:${HUB_REPORT_TARGET}`, user_id: `instance:${HUB_REPORT_TARGET}`,
2982
3124
  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 });
3125
+ request_kind: "notification", requires_reply: "false", task_summary: input.kind === "answer-reminder" ? "Hub room answer reminder" : input.kind === "mention-feedback" ? "Hub mention delivery feedback" : "A reply to your Hub room post" } }, { isCrossInstance: true, stillCurrent: input.stillCurrent, beforeInput: input.beforeInput });
2984
3126
  return result !== false;
2985
3127
  }
2986
3128
  /** S-51: why the Hub (or this fleet's Hub membership) is not running, if it is held. Empty while off or running. */
@@ -3110,16 +3252,25 @@ export class FleetManager {
3110
3252
  }
3111
3253
  hubReacts = null;
3112
3254
  /** The member side's pane-failure hook for a Hub-issued correlation id (else null). */
3255
+ hubRoomOwed = null;
3256
+ hubRoomReplyWarning(agent) { try {
3257
+ return this.hubRoomOwed?.replyWarning(agent);
3258
+ }
3259
+ catch {
3260
+ return undefined;
3261
+ } }
3113
3262
  hubRoomInput = null;
3114
3263
  hubDeliveryFailed = null;
3115
3264
  /** The connected member adapter; never an agent-selectable identity. */
3116
3265
  hubAgentRooms = null;
3266
+ hubAgentIntro = null;
3267
+ hubSetIntro(caller, text, operationId) { return this.hubAgentIntro?.set(caller, text, operationId) ?? Promise.resolve({ ok: false, code: "unavailable" }); }
3117
3268
  hubRoomToolsAvailable() { return this.hubAgentRooms?.available() === true; }
3118
3269
  hubRoomList(caller) {
3119
3270
  return this.hubAgentRooms?.rooms(caller) ?? Promise.resolve({ ok: false, code: "unavailable" });
3120
3271
  }
3121
- hubRoomMembers(caller, room) {
3122
- return this.hubAgentRooms?.members(caller, room) ?? Promise.resolve({ ok: false, code: "unavailable" });
3272
+ hubRoomMembers(caller, room, options) {
3273
+ return this.hubAgentRooms?.members(caller, room, options) ?? Promise.resolve({ ok: false, code: "unavailable" });
3123
3274
  }
3124
3275
  hubPeopleSearch(caller, q) {
3125
3276
  return this.hubAgentRooms?.people(caller, q) ?? Promise.resolve({ ok: false, code: "unavailable" });
@@ -3288,6 +3439,11 @@ export class FleetManager {
3288
3439
  startupRetries = new Map();
3289
3440
  /** #2484: instances whose automatic startup retry is running now (between its timer and its outcome). */
3290
3441
  startupRetriesRunning = new Set();
3442
+ /** M-3302 (#4146): instances held because their backend's CLI is not installed — started again the moment it is (watchMissingBinaries). */
3443
+ missingBinaryHolds = new Map();
3444
+ missingBinaryWatch = null;
3445
+ missingBinaryNotices = new Map();
3446
+ static MISSING_BINARY_WATCH_MS = 15_000;
3291
3447
  /** Bumped by every explicit stop (incl. the stop half of a restart); fences the outage hand-off. */
3292
3448
  explicitStopGeneration = new Map();
3293
3449
  /** instanceName → outage hand-off currently executing; a repeat joins it. */
@@ -4043,6 +4199,7 @@ export class FleetManager {
4043
4199
  config: () => this.fleetConfig, current: () => [this.settingsGeneration, this.settingsRuntimeRevision, this.shuttingDown],
4044
4200
  generalLocation: input => this.previewGeneralLocation(input),
4045
4201
  hubMembership: raw => hubMembershipSettings(raw),
4202
+ hubPageSharing: raw => hubPageSharingSettings(raw),
4046
4203
  hubPilotTrust: raw => hubPilotTrustSettings(raw, RUNNING_AGEND_VERSION),
4047
4204
  // S3c (S-55): a Hub exposure publish's confirmation summary, while a member composition is attached.
4048
4205
  hubBrowserCertificate: (input, binding) => {
@@ -9550,6 +9707,8 @@ export class FleetManager {
9550
9707
  return false;
9551
9708
  if (this.stopOnUnsupportedCli(name, err, what))
9552
9709
  return false;
9710
+ if (this.holdMissingBinary(name, err))
9711
+ return false;
9553
9712
  this.logger.error({ err, name }, `Failed to start ${what}`);
9554
9713
  this.scheduleStartupRetry(name, 0);
9555
9714
  return false;
@@ -9593,6 +9752,11 @@ export class FleetManager {
9593
9752
  }
9594
9753
  /** Drop a pending automatic retry (an operator start/stop/restart supersedes it). */
9595
9754
  cancelStartupRetry(name) {
9755
+ // M-3302: a person's start/stop/restart supersedes the hold too (a start that still finds no binary holds it again).
9756
+ if (this.missingBinaryHolds?.delete(name)) {
9757
+ this.needsYou?.poke();
9758
+ this.stopMissingBinaryWatchIfIdle();
9759
+ }
9596
9760
  const pending = this.startupRetries.get(name);
9597
9761
  if (!pending)
9598
9762
  return;
@@ -9600,11 +9764,124 @@ export class FleetManager {
9600
9764
  this.startupRetries.delete(name);
9601
9765
  this.logger.info({ name }, "Pending automatic startup retry cancelled");
9602
9766
  }
9767
+ /**
9768
+ * M-3302 (#4146): the start failed because the backend's CLI is not installed (BackendBinaryMissingError). That does not get better
9769
+ * on the 1 → 5 → 15 min backoff and should not be given up on either: the instance is held, one notice per binary names the binary
9770
+ * and the install command (Needs you shows it too), and the fleet looks for the binary every MISSING_BINARY_WATCH_MS and starts each
9771
+ * held instance the moment it is back. True: handled.
9772
+ */
9773
+ holdMissingBinary(name, failure) {
9774
+ if (failure instanceof SupersededStartError)
9775
+ return false;
9776
+ const err = this.lifecycle?.missingBinaryAt?.(name, failure) ?? null;
9777
+ if (!err)
9778
+ return false;
9779
+ const pending = this.startupRetries.get(name);
9780
+ if (pending) {
9781
+ clearTimeout(pending.timer);
9782
+ this.startupRetries.delete(name);
9783
+ }
9784
+ const known = this.missingBinaryHolds.get(name);
9785
+ if (!known || known.binary !== err.binary) {
9786
+ this.missingBinaryHolds.set(name, { backend: err.backend, binary: err.binary, since: known?.since ?? Date.now() });
9787
+ this.logger.error({ name, backend: err.backend, binary: err.binary }, `Not starting ${name}: its backend binary "${err.binary}" is not installed — held until it is back`);
9788
+ this.queueMissingBinaryNotice(name, err.backend, err.binary);
9789
+ this.needsYou?.poke();
9790
+ }
9791
+ this.instanceProcessStatus.set(name, "stopped");
9792
+ this.ensureMissingBinaryWatch();
9793
+ return true;
9794
+ }
9795
+ /** The install command shown for a missing binary: the registry's (what /login and the dashboard run). */
9796
+ missingBinaryFix(backend) {
9797
+ return BACKEND_INSTALLATION_INFO[backend]?.install ?? "";
9798
+ }
9799
+ /**
9800
+ * M-3302: the summary a restart/update completion posts — `base` plus the "why" of its failed instances (missingBinarySummary). The one place both completions
9801
+ * (the startup batch after an update or restart, and the in-process restart) build it, so neither can drop the line (Fable on #4161).
9802
+ */
9803
+ completionSummary(base) {
9804
+ return { ...base, ...this.missingBinarySummary(base.failedNames ?? []) };
9805
+ }
9806
+ /** M-3302: the restart/update completion's "why" for the failed instances held on a missing binary, grouped by binary ({} when none). */
9807
+ missingBinarySummary(failedNames) {
9808
+ const groups = new Map();
9809
+ for (const name of failedNames) {
9810
+ const hold = this.missingBinaryHold(name);
9811
+ if (!hold)
9812
+ continue;
9813
+ const group = groups.get(hold.binary) ?? { binary: hold.binary, fix: hold.fix, names: [] };
9814
+ group.names.push(name);
9815
+ groups.set(hold.binary, group);
9816
+ }
9817
+ return groups.size ? { missingBinaries: [...groups.values()] } : {};
9818
+ }
9819
+ /** M-3302: a missing binary's hold, for Needs you (null: none). */
9820
+ missingBinaryHold(name) {
9821
+ const hold = this.missingBinaryHolds?.get(name);
9822
+ return hold ? { ...hold, fix: this.missingBinaryFix(hold.backend) } : null;
9823
+ }
9824
+ /** One notice per missing binary, however many instances it stopped (the same aggregation window as the start-retry notices). */
9825
+ queueMissingBinaryNotice(name, backend, binary) {
9826
+ const pending = this.missingBinaryNotices.get(binary);
9827
+ if (pending) {
9828
+ if (!pending.names.includes(name))
9829
+ pending.names.push(name);
9830
+ return;
9831
+ }
9832
+ const timer = setTimeout(() => {
9833
+ const entry = this.missingBinaryNotices.get(binary);
9834
+ this.missingBinaryNotices.delete(binary);
9835
+ if (entry)
9836
+ this.notifyFleetError(t("fleet.backend_binary_missing", entry.names.length, entry.names.join(", "), binary, this.missingBinaryFix(entry.backend)));
9837
+ }, FleetManager.STARTUP_RETRY_NOTICE_AGGREGATE_MS);
9838
+ timer.unref?.();
9839
+ this.missingBinaryNotices.set(binary, { names: [name], backend, timer });
9840
+ }
9841
+ ensureMissingBinaryWatch() {
9842
+ if (this.missingBinaryWatch || this.shuttingDown)
9843
+ return;
9844
+ this.missingBinaryWatch = setInterval(() => { void this.checkMissingBinaries(); }, FleetManager.MISSING_BINARY_WATCH_MS);
9845
+ this.missingBinaryWatch.unref?.();
9846
+ }
9847
+ stopMissingBinaryWatchIfIdle() {
9848
+ if (this.missingBinaryHolds?.size || !this.missingBinaryWatch)
9849
+ return;
9850
+ clearInterval(this.missingBinaryWatch);
9851
+ this.missingBinaryWatch = null;
9852
+ }
9853
+ missingBinaryCheckRunning = false;
9854
+ /** One look per backend still missing; each held instance whose binary is back is started now (through the spawn gate, as a retry). */
9855
+ async checkMissingBinaries() {
9856
+ if (this.missingBinaryCheckRunning || this.shuttingDown)
9857
+ return;
9858
+ this.missingBinaryCheckRunning = true;
9859
+ try {
9860
+ const backends = [...new Set([...this.missingBinaryHolds.values()].map(h => h.backend))];
9861
+ for (const backend of backends) {
9862
+ const path = await resolveBackendBinary(backend).catch(() => undefined);
9863
+ if (typeof path !== "string" || !path)
9864
+ continue;
9865
+ for (const [name, hold] of [...this.missingBinaryHolds]) {
9866
+ if (hold.backend !== backend)
9867
+ continue;
9868
+ this.missingBinaryHolds.delete(name);
9869
+ this.logger.info({ name, backend, binary: hold.binary, path }, `Backend binary "${hold.binary}" is back — starting ${name}`);
9870
+ void this.runStartupRetry(name, 0);
9871
+ }
9872
+ this.needsYou?.poke();
9873
+ }
9874
+ }
9875
+ finally {
9876
+ this.missingBinaryCheckRunning = false;
9877
+ this.stopMissingBinaryWatchIfIdle();
9878
+ }
9879
+ }
9603
9880
  /** #2484: the instance's own start retry is scheduled or running, and no person paused it (a stop cancels the retry). */
9604
9881
  inStartRetryBackoff(name) {
9605
9882
  if (this.shuttingDown || this.lifecycle.isPaused(name))
9606
9883
  return false;
9607
- return this.startupRetries.has(name) || this.startupRetriesRunning.has(name);
9884
+ return this.startupRetries.has(name) || this.startupRetriesRunning.has(name) || this.missingBinaryHolds?.has(name) === true;
9608
9885
  }
9609
9886
  /** Pending automatic retry, if any (status display / tests). */
9610
9887
  pendingStartupRetry(name) {
@@ -9693,6 +9970,8 @@ export class FleetManager {
9693
9970
  return;
9694
9971
  if (this.stopOnUnsupportedCli(name, err, "instance"))
9695
9972
  return;
9973
+ if (this.holdMissingBinary(name, err))
9974
+ return;
9696
9975
  this.logger.error({ err, name, attempt: attempt + 1 }, "Automatic startup retry failed");
9697
9976
  this.scheduleStartupRetry(name, attempt + 1);
9698
9977
  }
@@ -12524,7 +12803,7 @@ export class FleetManager {
12524
12803
  // version it aimed for, the one running, and the one repair), never just "updated".
12525
12804
  const aimedAt = pendingProgressOperation === "update" ? pendingUpdateProgress?.progress.version : undefined;
12526
12805
  const notLanded = aimedAt && agendVersion !== "unknown" && aimedAt !== agendVersion ? t("update.not_landed", aimedAt, agendVersion) : null;
12527
- const completionSummary = {
12806
+ const completionSummary = this.completionSummary({
12528
12807
  running: started,
12529
12808
  total,
12530
12809
  version: agendVersion,
@@ -12534,7 +12813,7 @@ export class FleetManager {
12534
12813
  ...(cleanupOutcome && "render" in cleanupOutcome
12535
12814
  ? { warningText: cleanupOutcome.render.warning, warningCommand: cleanupOutcome.render.cleanupCommand }
12536
12815
  : notLanded ? { warningText: notLanded } : {}),
12537
- };
12816
+ });
12538
12817
  const progressCompleted = await startupProgress.finish(completionSummary);
12539
12818
  // Armed only after the completion posted: an append racing ahead of it would be overwritten by it.
12540
12819
  if (cleanupOutcome && "watch" in cleanupOutcome)
@@ -13643,6 +13922,10 @@ export class FleetManager {
13643
13922
  else if (msg.type === "instance_progress") {
13644
13923
  this.cacheInstanceProgress(name, msg.progress || null);
13645
13924
  }
13925
+ else if (msg.type === "hub_room_turn_ended") {
13926
+ if (this.instanceIpcClients.get(name) === ipc && typeof msg.generation === "string" && typeof msg.turn === "string")
13927
+ void this.hubRoomOwed?.turnEnded(name, msg.generation, msg.turn).catch(err => this.logger.warn({ err }, "Hub room completion notice held"));
13928
+ }
13646
13929
  else if (msg.type === "hub_room_input") {
13647
13930
  if (this.instanceIpcClients.get(name) === ipc && typeof msg.correlationId === "string" && typeof msg.generation === "string")
13648
13931
  this.hubRoomInput?.(msg.correlationId, name, msg.generation);
@@ -14008,6 +14291,14 @@ export class FleetManager {
14008
14291
  this.eventLog?.removeReaction(instanceName, r.messageId, r.username, r.emoji);
14009
14292
  }
14010
14293
  }
14294
+ /**
14295
+ * M-3293 (#4119): an Office pat or feed a person chose to tell `instance` about (their "Tell" on, the page's per-agent
14296
+ * choice). Queued with the reactions (EventLog.addOfficeReaction): it rides the instance's next real message in the
14297
+ * same `[Recent reactions: …]` line, never wakes it and never sends anything by itself. Whether it was stored (capped).
14298
+ */
14299
+ officeTell(instance, person, kind) {
14300
+ return this.eventLog?.addOfficeReaction(instance, person, kind) ?? false;
14301
+ }
14011
14302
  /**
14012
14303
  * The queued-reaction summary for an instance's next real message, or {} when
14013
14304
  * nothing is pending (the common case must add zero context). The consume
@@ -14311,10 +14602,42 @@ export class FleetManager {
14311
14602
  }
14312
14603
  async handleInboundMessage(msg) {
14313
14604
  msg = { ...msg, humanOriginalBody: msg.humanOriginalBody ?? msg.text, humanOrigin: msg.isBotMessage ? undefined : msg.humanOrigin && { ...msg.humanOrigin } };
14605
+ // #4145: this fleet's sign-in access token pasted into a chat is hidden before anything logs, indexes, keeps or
14606
+ // delivers the message — then taken back and replaced, and the chat told where it goes.
14607
+ const pasted = this.screenPastedLoginToken(msg);
14608
+ if (pasted) {
14609
+ msg = pasted.msg;
14610
+ if (pasted.live)
14611
+ await this.takeBackPastedLoginToken(msg);
14612
+ }
14314
14613
  if (msg.isBotMessage)
14315
14614
  return withSpawnHoldReply(undefined, () => this.handleInboundMessageCore(msg));
14316
14615
  return withSpawnHoldReply(text => this.inboundNoticeAdapter(msg)?.sendText(msg.chatId, text, { threadId: msg.threadId }) ?? Promise.resolve(), () => this.handleInboundMessageCore(msg));
14317
14616
  }
14617
+ /** #4145 (the web chat's /ui/send too): `text` with this fleet's sign-in access token hidden; null when there is none in it. */
14618
+ screenLoginToken(text) { return this.loginController?.screenToken(text) ?? null; }
14619
+ /** #4145: take a pasted access token back (a new one goes the way the first went); the line for the chat it was pasted in, or null. */
14620
+ loginTokenPasted() { return this.loginController?.tokenPasted() ?? Promise.resolve(null); }
14621
+ /** #4145: the message with the live (or a just-taken-back) sign-in access token hidden in its text and its receipt body; null when neither has one. */
14622
+ screenPastedLoginToken(msg) {
14623
+ const text = this.screenLoginToken(msg.text ?? "");
14624
+ const body = msg.humanOriginalBody === undefined || msg.humanOriginalBody === msg.text ? text : this.screenLoginToken(msg.humanOriginalBody);
14625
+ if (!text && !body)
14626
+ return null;
14627
+ return { msg: { ...msg, ...(text ? { text: text.text } : {}), ...(body ? { humanOriginalBody: body.text } : {}) }, live: !!(text?.live || body?.live) };
14628
+ }
14629
+ /** #4145: take the pasted token back (a new one goes privately) and say so once, where it was pasted. Never the token in a log line. */
14630
+ async takeBackPastedLoginToken(msg) {
14631
+ this.logger.warn({ source: msg.source, adapterId: msg.adapterId, chatId: msg.chatId, threadId: msg.threadId, userId: msg.userId }, "A sign-in access token was pasted into a chat: hidden, taken back and replaced");
14632
+ const notice = await this.loginTokenPasted().catch((err) => {
14633
+ this.logger.warn({ err: err.message }, "Taking back a pasted sign-in token failed");
14634
+ return null;
14635
+ });
14636
+ if (!notice || msg.isBotMessage)
14637
+ return;
14638
+ await this.inboundNoticeAdapter(msg)?.sendText(msg.chatId, notice, { threadId: msg.threadId || undefined })
14639
+ .catch((err) => this.logger.warn({ err: err.message }, "Pasted sign-in token notice failed"));
14640
+ }
14318
14641
  /**
14319
14642
  * #1752: the bot that speaks back about an inbound message — in a fleet topic the owning instance's adapter, never
14320
14643
  * the sibling that happened to win the dedup race; elsewhere (ClassicBot rooms, no routed instance) the receiver.
@@ -15095,6 +15418,8 @@ export class FleetManager {
15095
15418
  const operationId = typeof msg.operationId === "string" ? msg.operationId : undefined;
15096
15419
  const sourceDaemonBootId = typeof msg.sourceDaemonBootId === "string" ? msg.sourceDaemonBootId : undefined;
15097
15420
  const respond = (result, error) => {
15421
+ if (tool === "reply" && msg.statusOnly !== true)
15422
+ result = withHubRoomReplyWarning(result, () => this.hubRoomReplyWarning(instanceName), error);
15098
15423
  const ipc = this.instanceIpcClients.get(instanceName);
15099
15424
  let sent = false;
15100
15425
  if (fleetRequestId) {
@@ -17438,6 +17763,11 @@ export class FleetManager {
17438
17763
  await this.lifecycle.remove(name, authorization, execution, transition);
17439
17764
  else
17440
17765
  await this.lifecycle.remove(name, authorization);
17766
+ // M-3302: a removed instance is no longer held for its missing binary (the watch would only skip it).
17767
+ if (this.missingBinaryHolds?.delete(name)) {
17768
+ this.needsYou?.poke();
17769
+ this.stopMissingBinaryWatchIfIdle();
17770
+ }
17441
17771
  // #1490 row 27: its hang/exit offers were for the instance now gone (stopInstance clears them; removal stops
17442
17772
  // through the lifecycle directly). The offers' own lifecycle pins refuse them too.
17443
17773
  this.clearNoncePromptsForInstance(name);
@@ -18990,7 +19320,7 @@ export class FleetManager {
18990
19320
  if (this.adapter && target) {
18991
19321
  const out = this.renderPlaces(this.getPrimaryAdapterId(), body, target.opts);
18992
19322
  this.adapter.sendText(target.chatId, out.text, out.opts)
18993
- .then(() => opts.ack?.(true), err => { this.logger.warn({ err }, "Failed to send fleet error notification"); opts.ack?.(false); });
19323
+ .then(() => { this.logger.info({ notice: noticePreview(body) }, "Fleet notice delivered"); opts.ack?.(true); }, err => { this.logger.warn({ err }, "Failed to send fleet error notification"); opts.ack?.(false); });
18994
19324
  dispatched = true;
18995
19325
  }
18996
19326
  }
@@ -19097,7 +19427,8 @@ export class FleetManager {
19097
19427
  if (!send)
19098
19428
  return false;
19099
19429
  // `ack` (a caller that must not lose the message) is told when the platform took it or refused it; everyone else only gets the log line.
19100
- send.sent.then(() => ack?.(true), e => { this.logger.warn({ err: e, instanceName }, send.failure); ack?.(false); });
19430
+ // M-3302 (#4146): a delivered notice leaves one line, so the log can tell whether the person was told (only failures were logged).
19431
+ send.sent.then(() => { this.logger.info({ instanceName, notice: noticePreview(text) }, "Notice delivered"); ack?.(true); }, e => { this.logger.warn({ err: e, instanceName }, send.failure); ack?.(false); });
19101
19432
  return true;
19102
19433
  }
19103
19434
  /**
@@ -19472,6 +19803,8 @@ export class FleetManager {
19472
19803
  return true;
19473
19804
  if (await this.handleKiroMigrateCallback(data, adapterId, adapter))
19474
19805
  return true;
19806
+ if (await this.handleHubSharingCallback(data, adapterId, adapter))
19807
+ return true;
19475
19808
  if (await this.handleHubFleetUpdateCallback(data, adapterId, adapter))
19476
19809
  return true;
19477
19810
  if (await this.handleHubUpdateCallback(data, adapterId, adapter))
@@ -19790,6 +20123,7 @@ export class FleetManager {
19790
20123
  interaction: p.interaction ? { kind: p.interaction.kind, owner: wait?.owner ?? null, episode: p.interaction.episode, since: p.interaction.since } : null,
19791
20124
  interactionSummary: p.interaction?.kind === "kiro_choice" ? t("kiro3.running") : p.interaction_summary ?? null,
19792
20125
  kiroCompatibility: this.kiroCompatibilityHolds?.get(name),
20126
+ backendMissing: this.missingBinaryHold(name),
19793
20127
  pauseReason, pausedAt,
19794
20128
  crashedAt: crashed ? (this.needsCrashedAt.get(name) ?? null) : null,
19795
20129
  signIn: pauseReason === "auth" ? this.signInFor(name) : null,
@@ -20066,7 +20400,10 @@ export class FleetManager {
20066
20400
  const buttons = this.replyButtons();
20067
20401
  return buttons ? buttons.clickWeb(instance, id, index, voter) : Promise.resolve({ status: 409, error: t("reply_buttons.closed") });
20068
20402
  }
20069
- async clickWebPrompt(instance, nonce, action, text) {
20403
+ webPromptNeedsHuman(nonce) {
20404
+ return this.pendingNonceButtons.get(nonce)?.remoteCard?.humanOnly === true;
20405
+ }
20406
+ async clickWebPrompt(instance, nonce, action, text, humanSession = false) {
20070
20407
  if (!/^[0-9a-f]{32}$/.test(nonce) || !/^[a-z][a-z0-9-]{0,23}$/.test(action))
20071
20408
  return { status: 400, error: "Malformed prompt answer" };
20072
20409
  // #2675: only an action the page shows a text box for takes text, and it must say something.
@@ -20081,6 +20418,8 @@ export class FleetManager {
20081
20418
  return { status: 403, error: "This prompt belongs to another instance" };
20082
20419
  if (!entry.web.actions.some(a => a.id === action))
20083
20420
  return { status: 400, error: "Not one of this prompt's answers" };
20421
+ if (entry.remoteCard?.humanOnly && !humanSession)
20422
+ return { status: 403, error: "This decision needs a signed-in administrator" };
20084
20423
  let notice;
20085
20424
  const data = {
20086
20425
  callbackData: `${entry.prefix}${nonce}:${action}`,
@@ -21917,7 +22256,7 @@ export class FleetManager {
21917
22256
  message: prompt.message, choices: prompt.choices, webInput: prompt.webInput,
21918
22257
  expiredText: t("card.expired", instanceName), timeoutMs: REMOTE_CARD_TIMEOUT_MS,
21919
22258
  extra: { remoteCard: { identity: card.identity, kind: card.kind, options: shown.kind === "question" ? shown.options.map(o => ({ n: o.n, title: o.title })) : [],
21920
- requiresAdmin, ownerAdapterId: this.getInstanceAdapterId(instanceName) } },
22259
+ requiresAdmin, ownerAdapterId: this.getInstanceAdapterId(instanceName), humanOnly: card.kind === "question" && card.humanOnly === true } },
21921
22260
  });
21922
22261
  if (nonce)
21923
22262
  this.remoteCardPosts.set(instanceName, nonce);
@@ -23238,7 +23577,58 @@ export class FleetManager {
23238
23577
  }
23239
23578
  }
23240
23579
  return buildAccountsView({ targets, diskProfiles, agents, classic, fleetDefaults, usage, keepAlive, machines, installShown: this.webHostInstalls.view()?.backend ?? null,
23241
- versions: new Map(this.backendAvailabilityRows().map(row => [row.backend, row.version ?? null])) });
23580
+ versions: new Map(this.backendAvailabilityRows().map(row => [row.backend, row.version ?? null])), claudeInstall: await this.claudeInstallShown() });
23581
+ }
23582
+ /**
23583
+ * M-3307: the install kind as the AI accounts page is told it — paths `~`-abbreviated (Fable note 2 on #4163) — and, for a native install, the npm copy still left on
23584
+ * this computer (note 1: found again here, not only remembered from a switch in this process), so its removal is offered after a restart too.
23585
+ */
23586
+ async claudeInstallShown() {
23587
+ const ci = await this.claudeInstall();
23588
+ if (!ci)
23589
+ return null;
23590
+ const home = homedir();
23591
+ if (ci.kind === "npm-global")
23592
+ return { kind: ci.kind, ...(ci.npmPackageDir ? { npmPackageDir: displayHostPath(ci.npmPackageDir, home) } : {}) };
23593
+ if (ci.kind !== "native")
23594
+ return { kind: ci.kind };
23595
+ const left = await this.findClaudeNpmCopy().catch(() => null);
23596
+ return { kind: "native", ...(left ? { npmLeftover: displayHostPath(left, home) } : {}) };
23597
+ }
23598
+ claudeNpmCopyCache = null;
23599
+ /**
23600
+ * M-3307 (Fable note 1 on #4163): an npm copy of Claude Code on this computer, looked for afresh: the one a switch in this process found, else `<npm root -g>/@anthropic-ai/claude-code`
23601
+ * (a fresh login shell's npm), else the system prefixes' (/usr/lib, /usr/local/lib). The answer is kept a minute (the page reads it on each view). Null: none.
23602
+ */
23603
+ async findClaudeNpmCopy() {
23604
+ if (this.claudeNpmCopy && existsSync(this.claudeNpmCopy))
23605
+ return this.claudeNpmCopy;
23606
+ const now = performance.now();
23607
+ if (this.claudeNpmCopyCache && now - this.claudeNpmCopyCache.at < 60_000)
23608
+ return this.claudeNpmCopyCache.dir;
23609
+ const roots = [];
23610
+ try {
23611
+ const r = await runOnLoginShell("npm root -g 2>/dev/null");
23612
+ const root = r.status === 0 ? r.stdout.trim().split("\n").pop()?.trim() ?? "" : "";
23613
+ if (isAbsolute(root))
23614
+ roots.push(root);
23615
+ }
23616
+ catch { /* no npm */ }
23617
+ roots.push("/usr/lib/node_modules", "/usr/local/lib/node_modules");
23618
+ const dir = roots.map(root => join(root, CLAUDE_NPM_PACKAGE)).find(d => existsSync(d)) ?? null;
23619
+ this.claudeNpmCopyCache = { at: now, dir };
23620
+ return dir;
23621
+ }
23622
+ /** M-3307 (#4146): the kind of the host's Claude Code install, from the real path of the `claude` the availability snapshot resolved (null: none, or unreadable). */
23623
+ async claudeInstall(path = this.backendAvailabilityRows().find(row => row.backend === "claude-code")?.path ?? null) {
23624
+ if (!path)
23625
+ return null;
23626
+ try {
23627
+ return claudeInstallKind(await realpath(path), process.env, homedir());
23628
+ }
23629
+ catch {
23630
+ return null;
23631
+ }
23242
23632
  }
23243
23633
  /**
23244
23634
  * AGEND-113: a dashboard sign-in just finished: read the usage once more now (the panel's own forced read, so its 30-second floor and Retry-After hold), instead of showing what was read
@@ -24522,14 +24912,29 @@ export class FleetManager {
24522
24912
  if (!base || isRemovedBackend(backend))
24523
24913
  return { refused: "unsupported" };
24524
24914
  // AGEND-136: an update runs the registry's `host.update` command with the audited release in it (hostUpdatePlan); the window, its judgement and its release are the install's.
24525
- const plan = mode === "update" ? hostUpdatePlan(backend) : null;
24526
- if (mode === "update" && !plan)
24915
+ const plan = mode === "update" || mode === "native" ? hostUpdatePlan(backend) : null;
24916
+ if ((mode === "update" || mode === "native") && !plan)
24917
+ return { refused: "unsupported" };
24918
+ // M-3307 (#4146): the switch and the npm copy's removal are Claude Code's alone.
24919
+ if ((mode === "native" || mode === "remove-npm") && backend !== "claude-code")
24527
24920
  return { refused: "unsupported" };
24528
- const info = plan ? { install: plan.command } : base;
24921
+ // remove-npm: the npm copy the switch found (its package directory), removed with npm of that same prefix (<prefix>/lib/node_modules/@anthropic-ai/claude-code).
24922
+ // Fable note 1 on #4163: found afresh, so a restart after the switch does not lose it.
24923
+ if (mode === "remove-npm")
24924
+ this.claudeNpmCopyCache = null;
24925
+ const npmCopy = mode === "remove-npm" ? await this.findClaudeNpmCopy().catch(() => null) : null;
24926
+ if (mode === "remove-npm" && (!npmCopy || !existsSync(npmCopy)))
24927
+ return { refused: "no_npm_copy" };
24928
+ const info = plan ? { install: plan.command } : npmCopy ? { install: npmUninstallCommand(npmCopy) } : base;
24529
24929
  // The fleet-wide window, claimed before the first await (shared with /login, chat's install and sign-in).
24530
24930
  const claim = this.loginWindow.tryClaim("install", backend);
24531
24931
  if (!claim)
24532
24932
  return { refused: this.loginWindow.isClosed ? "shutting_down" : "busy" };
24933
+ // M-3302: Claude Code downloading an update of its own right now — its installer, started from here, would race it. Asked to try again in a few minutes.
24934
+ if (backend === "claude-code" && claudeSelfUpdating()) {
24935
+ this.loginWindow.release(claim);
24936
+ return { refused: "cli_self_updating" };
24937
+ }
24533
24938
  // #3542 / AGEND-144 (Prism on #3539): the claim is a lock, not the asker's authority. The confirmed change's own execution (its session, role, confirmation and the settings it was held
24534
24939
  // against) is asked again after each wait (the binary check, the version refresh), and its admission ends at the tmux command that starts the installer (openInstallWindow → `launch`).
24535
24940
  const asker = () => { try {
@@ -24544,10 +24949,25 @@ export class FleetManager {
24544
24949
  return { refused: "already" };
24545
24950
  }
24546
24951
  // An update needs the CLI where the Accounts page found it: on the fleet's PATH, else (a fresh login shell, then) the installer's own directories (~/.grok/bin, ~/.opencode/bin …).
24547
- if (mode === "update" && !present && !(await this.locateInstalledCli(backend, base.binary).catch(() => null))) {
24952
+ if (mode !== "install" && !present && !(await this.locateInstalledCli(backend, base.binary).catch(() => null))) {
24548
24953
  this.loginWindow.release(claim);
24549
24954
  return { refused: "not_installed" };
24550
24955
  }
24956
+ // M-3307: the switch is offered only over an npm-global install; the removal only once `claude` resolves to the native install (else nothing would be left).
24957
+ if (mode === "native" || mode === "remove-npm") {
24958
+ const now = await this.claudeInstallAfter(base.binary, null);
24959
+ if (mode === "native" && now.kind !== "npm-global") {
24960
+ this.loginWindow.release(claim);
24961
+ return { refused: "not_npm" };
24962
+ }
24963
+ if (mode === "native")
24964
+ this.claudeNpmCopy = (await this.claudeInstall(now.path))?.npmPackageDir ?? null;
24965
+ // The removal needs a native install to fall back on: `claude` resolves to it already, or it is there behind the npm copy on PATH (the switch's "still npm" case).
24966
+ if (mode === "remove-npm" && now.kind !== "native" && !(await this.nativeClaudePresent())) {
24967
+ this.loginWindow.release(claim);
24968
+ return { refused: "still_npm" };
24969
+ }
24970
+ }
24551
24971
  if (!asker()) {
24552
24972
  this.loginWindow.release(claim);
24553
24973
  return { refused: "failed" };
@@ -24576,7 +24996,7 @@ export class FleetManager {
24576
24996
  return { refused: "version_unreadable" };
24577
24997
  }
24578
24998
  // AGEND-153: the named exception (`release: "latest-unaudited"`) is offered at any readable version (it goes to the vendor's newest, not to our audited release), so "behind" does not decide it.
24579
- if (cliUpdateView(backend, versionBefore, true, plan.target === null)?.button !== true) {
24999
+ if (mode === "update" && cliUpdateView(backend, versionBefore, true, plan.target === null)?.button !== true) {
24580
25000
  this.loginWindow.release(claim);
24581
25001
  return { refused: "up_to_date" };
24582
25002
  }
@@ -24607,9 +25027,17 @@ export class FleetManager {
24607
25027
  version = this.backendAvailabilityRows().find(row => row.backend === backend)?.version ?? null;
24608
25028
  }
24609
25029
  }
24610
- this.logger.info({ backend, mode, ok, verified, ...(plan ? { to: plan.target } : {}), ...(ok ? {} : { detail }) }, mode === "update" ? "Dashboard update ended" : "Dashboard install ended");
25030
+ // M-3307: after the switch or the removal, where `claude` resolves now (a fresh login shell), its kind, and whether the npm copy is still there.
25031
+ const claude = ok && (mode === "native" || mode === "remove-npm") ? await this.claudeInstallAfter(base.binary, mode === "remove-npm" ? npmCopy : this.claudeNpmCopy).catch(() => undefined) : undefined;
25032
+ if (claude && mode === "remove-npm" && !claude.npmLeftover) {
25033
+ this.claudeNpmCopy = null;
25034
+ this.claudeNpmCopyCache = null;
25035
+ }
25036
+ this.logger.info({ backend, mode, ok, verified, ...(plan ? { to: plan.target } : {}), ...(claude ? { claude } : {}), ...(ok ? {} : { detail }) }, mode === "install" ? "Dashboard install ended" : mode === "update" ? "Dashboard update ended" : mode === "native" ? "Dashboard switch to Claude's native install ended" : "Dashboard removal of the npm Claude Code ended");
25037
+ // Fable note 2 on #4163: what the page is told names no user — paths are shown `~`-abbreviated (the log above keeps them whole, on this computer).
25038
+ const shown = claude ? { ...claude, path: displayHostPath(claude.path, homedir()), npmLeftover: displayHostPath(claude.npmLeftover, homedir()) } : undefined;
24611
25039
  try {
24612
- reporter.done({ ok, detail, cleanupFailed, verified, version, signIn: !!LOGIN_FLOWS[backend] && dashboardSignInSupported(backend) });
25040
+ reporter.done({ ok, detail, cleanupFailed, verified, version, signIn: mode === "install" && !!LOGIN_FLOWS[backend] && dashboardSignInSupported(backend), ...(shown ? { claude: shown } : {}) });
24613
25041
  }
24614
25042
  catch { /* a view never stops the install */ }
24615
25043
  },
@@ -24623,6 +25051,20 @@ export class FleetManager {
24623
25051
  }
24624
25052
  return { started: true };
24625
25053
  }
25054
+ /** M-3307: the npm copy of Claude Code the last switch found (its package directory), the one `remove-npm` removes. */
25055
+ claudeNpmCopy = null;
25056
+ /** M-3307: Claude's native install is there: `~/.local/bin/claude` leads into its versions folder. */
25057
+ async nativeClaudePresent() {
25058
+ const real = await realpath(join(homedir(), ".local", "bin", "claude")).catch(() => null);
25059
+ return !!real && claudeInstallKind(real, process.env, homedir()).kind === "native";
25060
+ }
25061
+ /** M-3307: where `binary` resolves in a fresh login shell now, the kind of that install, and whether `npmCopy` (a package directory) is still there. */
25062
+ async claudeInstallAfter(binary, npmCopy) {
25063
+ const at = await this.locateBinaryOnLoginShell(binary).catch(() => null);
25064
+ const real = at ? await realpath(at).catch(() => null) : null;
25065
+ const kind = real ? claudeInstallKind(real, process.env, homedir()).kind : null;
25066
+ return { kind, path: real, npmLeftover: npmCopy && existsSync(npmCopy) ? npmCopy : null };
25067
+ }
24626
25068
  /** A fresh login shell's answer for `binary`, else the installer's own directories (see locateBinaryOnLoginShell / locateInstalledBackend). */
24627
25069
  async locateInstalledCli(backend, binary) {
24628
25070
  return (await this.locateBinaryOnLoginShell(binary)) ?? (await this.locateInstalledBackend(backend));
@@ -28555,6 +28997,13 @@ export class FleetManager {
28555
28997
  for (const pending of this.startupRetries.values())
28556
28998
  clearTimeout(pending.timer);
28557
28999
  this.startupRetries.clear();
29000
+ if (this.missingBinaryWatch) {
29001
+ clearInterval(this.missingBinaryWatch);
29002
+ this.missingBinaryWatch = null;
29003
+ }
29004
+ for (const pending of this.missingBinaryNotices?.values() ?? [])
29005
+ clearTimeout(pending.timer);
29006
+ this.missingBinaryNotices?.clear();
28558
29007
  for (const pending of this.startupRetryNotices.values())
28559
29008
  clearTimeout(pending.timer);
28560
29009
  this.startupRetryNotices.clear();
@@ -30761,13 +31210,13 @@ export class FleetManager {
30761
31210
  const { createRequire } = await import("node:module");
30762
31211
  const _require2 = createRequire(import.meta.url);
30763
31212
  const agendVersion2 = _require2("../package.json").version ?? "unknown";
30764
- const progressCompleted = await restartProgress.finish({
31213
+ const progressCompleted = await restartProgress.finish(this.completionSummary({
30765
31214
  running: started,
30766
31215
  total,
30767
31216
  version: agendVersion2,
30768
31217
  pausedNames: pausedNames2,
30769
31218
  failedNames,
30770
- });
31219
+ }));
30771
31220
  if (groupId && this.adapter) {
30772
31221
  let restartText;
30773
31222
  if (failedNames.length === 0 && pausedNames2.length === 0) {
@@ -31361,6 +31810,9 @@ export class FleetManager {
31361
31810
  res.end(JSON.stringify({ error: "fleet stopping" }));
31362
31811
  return;
31363
31812
  }
31813
+ // M-3314: a versioned asset path goes through every check below as its plain path (the public link's gateway did
31814
+ // this already for its own requests; once per request).
31815
+ takeAssetVersion(req);
31364
31816
  const requestPath = new URL(req.url ?? "/", `http://localhost:${port}`).pathname;
31365
31817
  const publicUrl = new URL(req.url ?? "/", `http://localhost:${port}`);
31366
31818
  if (remoteRuntimeEnabled() && !gatewayRequestContext(req)
@@ -31747,6 +32199,9 @@ export class FleetManager {
31747
32199
  }
31748
32200
  }
31749
32201
  startHealthServer(port) {
32202
+ // M-3314: <V> describes the files this process started with, taken now — not at the first page, which may come after
32203
+ // an update rewrote them.
32204
+ warmAssetVersion();
31750
32205
  let settled;
31751
32206
  const listening = new Promise(resolve => { settled = resolve; });
31752
32207
  this.startedAt = Date.now();