@songsid/agend 2.4.0-beta.2 → 2.4.0-beta.4

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 (294) hide show
  1. package/dist/agent-cli.js +1 -1
  2. package/dist/agent-endpoint.d.ts +1 -1
  3. package/dist/agent-endpoint.js +8 -2
  4. package/dist/agent-endpoint.js.map +1 -1
  5. package/dist/agent-token-header.d.ts +1 -1
  6. package/dist/agent-token-header.js +1 -1
  7. package/dist/auth-api.d.ts +3 -0
  8. package/dist/auth-api.js +15 -1
  9. package/dist/auth-api.js.map +1 -1
  10. package/dist/backend/agy-model-switch.d.ts +22 -0
  11. package/dist/backend/agy-model-switch.js +62 -0
  12. package/dist/backend/agy-model-switch.js.map +1 -0
  13. package/dist/backend/antigravity.js +60 -3
  14. package/dist/backend/antigravity.js.map +1 -1
  15. package/dist/backend/cli-runtime-switch.d.ts +71 -0
  16. package/dist/backend/cli-runtime-switch.js +176 -0
  17. package/dist/backend/cli-runtime-switch.js.map +1 -0
  18. package/dist/backend/codex-model-switch.d.ts +41 -0
  19. package/dist/backend/codex-model-switch.js +170 -0
  20. package/dist/backend/codex-model-switch.js.map +1 -0
  21. package/dist/backend/credential-profile.js +1 -1
  22. package/dist/backend/credential-profile.js.map +1 -1
  23. package/dist/backend/grok-model-switch.d.ts +16 -0
  24. package/dist/backend/grok-model-switch.js +45 -0
  25. package/dist/backend/grok-model-switch.js.map +1 -0
  26. package/dist/backend/grok.js +1 -1
  27. package/dist/backend/grok.js.map +1 -1
  28. package/dist/backend/muse.d.ts +2 -0
  29. package/dist/backend/muse.js +7 -3
  30. package/dist/backend/muse.js.map +1 -1
  31. package/dist/build-provenance.json +1 -1
  32. package/dist/channel/mcp-server.js +10 -1
  33. package/dist/channel/mcp-server.js.map +1 -1
  34. package/dist/channel/mcp-tools.js +8 -0
  35. package/dist/channel/mcp-tools.js.map +1 -1
  36. package/dist/classic-channel-manager.d.ts +1 -1
  37. package/dist/classic-channel-manager.js +1 -1
  38. package/dist/cli-audited.js +12 -12
  39. package/dist/cli-audited.js.map +1 -1
  40. package/dist/daemon.d.ts +48 -2
  41. package/dist/daemon.js +302 -21
  42. package/dist/daemon.js.map +1 -1
  43. package/dist/delivery-consumed-watch.js +3 -0
  44. package/dist/delivery-consumed-watch.js.map +1 -1
  45. package/dist/event-log.d.ts +1 -1
  46. package/dist/event-log.js +1 -1
  47. package/dist/fleet-manager.d.ts +104 -2
  48. package/dist/fleet-manager.js +665 -27
  49. package/dist/fleet-manager.js.map +1 -1
  50. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +10 -0
  51. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +2 -0
  52. package/dist/general-knowledge/skills/fleet-health/SKILL.md +18 -0
  53. package/dist/general-knowledge/skills/hub/SKILL.md +154 -0
  54. package/dist/general-knowledge/skills/model-discovery/SKILL.md +4 -0
  55. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +17 -3
  56. package/dist/hub/admin-dashboard.d.ts +85 -0
  57. package/dist/hub/admin-dashboard.js +161 -0
  58. package/dist/hub/admin-dashboard.js.map +1 -0
  59. package/dist/hub/attachments/store.d.ts +2 -0
  60. package/dist/hub/attachments/store.js +6 -0
  61. package/dist/hub/attachments/store.js.map +1 -1
  62. package/dist/hub/client.d.ts +10 -0
  63. package/dist/hub/client.js +72 -10
  64. package/dist/hub/client.js.map +1 -1
  65. package/dist/hub/compose/member.d.ts +20 -0
  66. package/dist/hub/compose/member.js +212 -17
  67. package/dist/hub/compose/member.js.map +1 -1
  68. package/dist/hub/compose/server.d.ts +8 -0
  69. package/dist/hub/compose/server.js +13 -2
  70. package/dist/hub/compose/server.js.map +1 -1
  71. package/dist/hub/display-name.d.ts +10 -0
  72. package/dist/hub/display-name.js +35 -0
  73. package/dist/hub/display-name.js.map +1 -0
  74. package/dist/hub/execution/service.d.ts +1 -0
  75. package/dist/hub/execution/service.js +1 -1
  76. package/dist/hub/execution/service.js.map +1 -1
  77. package/dist/hub/fleet-info.d.ts +12 -0
  78. package/dist/hub/fleet-info.js +14 -0
  79. package/dist/hub/fleet-info.js.map +1 -0
  80. package/dist/hub/fleet-update-model.d.ts +100 -0
  81. package/dist/hub/fleet-update-model.js +15 -0
  82. package/dist/hub/fleet-update-model.js.map +1 -0
  83. package/dist/hub/fleet-updates.d.ts +46 -0
  84. package/dist/hub/fleet-updates.js +282 -0
  85. package/dist/hub/fleet-updates.js.map +1 -0
  86. package/dist/hub/fleet-versions.d.ts +28 -0
  87. package/dist/hub/fleet-versions.js +80 -0
  88. package/dist/hub/fleet-versions.js.map +1 -0
  89. package/dist/hub/http/compose.d.ts +2 -0
  90. package/dist/hub/http/compose.js +192 -16
  91. package/dist/hub/http/compose.js.map +1 -1
  92. package/dist/hub/http/deps.d.ts +1 -0
  93. package/dist/hub/http/schema.js +13 -1
  94. package/dist/hub/http/schema.js.map +1 -1
  95. package/dist/hub/member/display-name.d.ts +9 -0
  96. package/dist/hub/member/display-name.js +71 -0
  97. package/dist/hub/member/display-name.js.map +1 -0
  98. package/dist/hub/member/exposure-api.d.ts +4 -0
  99. package/dist/hub/member/exposure-api.js +8 -3
  100. package/dist/hub/member/exposure-api.js.map +1 -1
  101. package/dist/hub/member/exposures.d.ts +4 -0
  102. package/dist/hub/member/exposures.js +20 -0
  103. package/dist/hub/member/exposures.js.map +1 -1
  104. package/dist/hub/member/pairing-api.js +3 -2
  105. package/dist/hub/member/pairing-api.js.map +1 -1
  106. package/dist/hub/member/recommendations.d.ts +37 -0
  107. package/dist/hub/member/recommendations.js +129 -0
  108. package/dist/hub/member/recommendations.js.map +1 -0
  109. package/dist/hub/member/room-ask.d.ts +60 -1
  110. package/dist/hub/member/room-ask.js +254 -24
  111. package/dist/hub/member/room-ask.js.map +1 -1
  112. package/dist/hub/member/room-post-answers.d.ts +52 -0
  113. package/dist/hub/member/room-post-answers.js +152 -0
  114. package/dist/hub/member/room-post-answers.js.map +1 -0
  115. package/dist/hub/member/room-post-receipt.d.ts +21 -0
  116. package/dist/hub/member/room-post-receipt.js +49 -0
  117. package/dist/hub/member/room-post-receipt.js.map +1 -0
  118. package/dist/hub/member/room-post.d.ts +100 -0
  119. package/dist/hub/member/room-post.js +223 -0
  120. package/dist/hub/member/room-post.js.map +1 -0
  121. package/dist/hub/member/updates.d.ts +92 -0
  122. package/dist/hub/member/updates.js +316 -0
  123. package/dist/hub/member/updates.js.map +1 -0
  124. package/dist/hub/protocol.d.ts +658 -1
  125. package/dist/hub/protocol.js +90 -13
  126. package/dist/hub/protocol.js.map +1 -1
  127. package/dist/hub/published-version.d.ts +3 -0
  128. package/dist/hub/published-version.js +35 -0
  129. package/dist/hub/published-version.js.map +1 -0
  130. package/dist/hub/recommendation-model.d.ts +36 -0
  131. package/dist/hub/recommendation-model.js +9 -0
  132. package/dist/hub/recommendation-model.js.map +1 -0
  133. package/dist/hub/recommendations.d.ts +58 -0
  134. package/dist/hub/recommendations.js +211 -0
  135. package/dist/hub/recommendations.js.map +1 -0
  136. package/dist/hub/representative.d.ts +3 -0
  137. package/dist/hub/representative.js +2 -1
  138. package/dist/hub/representative.js.map +1 -1
  139. package/dist/hub/room-context-model.d.ts +43 -0
  140. package/dist/hub/room-context-model.js +12 -0
  141. package/dist/hub/room-context-model.js.map +1 -0
  142. package/dist/hub/rooms/agents.d.ts +41 -9
  143. package/dist/hub/rooms/agents.js +183 -21
  144. package/dist/hub/rooms/agents.js.map +1 -1
  145. package/dist/hub/rooms/assistant.d.ts +1 -6
  146. package/dist/hub/rooms/assistant.js +7 -2
  147. package/dist/hub/rooms/assistant.js.map +1 -1
  148. package/dist/hub/rooms/automation.d.ts +24 -0
  149. package/dist/hub/rooms/automation.js +66 -0
  150. package/dist/hub/rooms/automation.js.map +1 -0
  151. package/dist/hub/rooms/buttons.d.ts +85 -0
  152. package/dist/hub/rooms/buttons.js +62 -0
  153. package/dist/hub/rooms/buttons.js.map +1 -0
  154. package/dist/hub/rooms/context-cursor.d.ts +18 -0
  155. package/dist/hub/rooms/context-cursor.js +61 -0
  156. package/dist/hub/rooms/context-cursor.js.map +1 -0
  157. package/dist/hub/rooms/context.d.ts +1 -1
  158. package/dist/hub/rooms/context.js +4 -4
  159. package/dist/hub/rooms/context.js.map +1 -1
  160. package/dist/hub/rooms/mentions.d.ts +15 -0
  161. package/dist/hub/rooms/mentions.js +43 -0
  162. package/dist/hub/rooms/mentions.js.map +1 -0
  163. package/dist/hub/rooms/post-replies.d.ts +23 -0
  164. package/dist/hub/rooms/post-replies.js +114 -0
  165. package/dist/hub/rooms/post-replies.js.map +1 -0
  166. package/dist/hub/rooms/schema.d.ts +9 -0
  167. package/dist/hub/rooms/schema.js +43 -0
  168. package/dist/hub/rooms/schema.js.map +1 -1
  169. package/dist/hub/rooms/service.d.ts +136 -1
  170. package/dist/hub/rooms/service.js +727 -18
  171. package/dist/hub/rooms/service.js.map +1 -1
  172. package/dist/hub/rooms/types.d.ts +27 -3
  173. package/dist/hub/rooms.js +1 -1
  174. package/dist/hub/rooms.js.map +1 -1
  175. package/dist/hub/runtime.d.ts +1 -1
  176. package/dist/hub/runtime.js +12 -0
  177. package/dist/hub/runtime.js.map +1 -1
  178. package/dist/hub/server.d.ts +6 -1
  179. package/dist/hub/server.js +75 -5
  180. package/dist/hub/server.js.map +1 -1
  181. package/dist/hub/settings-directory-proof.js +22 -1
  182. package/dist/hub/settings-directory-proof.js.map +1 -1
  183. package/dist/hub/types.d.ts +133 -2
  184. package/dist/hub-contact-windows.d.ts +11 -0
  185. package/dist/hub-contact-windows.js +56 -0
  186. package/dist/hub-contact-windows.js.map +1 -0
  187. package/dist/hub-pairing-summary.d.ts +1 -1
  188. package/dist/hub-room-conversation.d.ts +14 -0
  189. package/dist/hub-room-conversation.js +60 -0
  190. package/dist/hub-room-conversation.js.map +1 -0
  191. package/dist/hub-update-notice.d.ts +12 -0
  192. package/dist/hub-update-notice.js +35 -0
  193. package/dist/hub-update-notice.js.map +1 -0
  194. package/dist/locale.js +58 -2
  195. package/dist/locale.js.map +1 -1
  196. package/dist/native-mcp.js +9 -6
  197. package/dist/native-mcp.js.map +1 -1
  198. package/dist/outbound-handlers.d.ts +14 -4
  199. package/dist/outbound-handlers.js +54 -1
  200. package/dist/outbound-handlers.js.map +1 -1
  201. package/dist/outbound-schemas.d.ts +12 -0
  202. package/dist/outbound-schemas.js +12 -0
  203. package/dist/outbound-schemas.js.map +1 -1
  204. package/dist/pane-port.d.ts +2 -0
  205. package/dist/queued-handoffs.d.ts +16 -4
  206. package/dist/queued-handoffs.js +18 -1
  207. package/dist/queued-handoffs.js.map +1 -1
  208. package/dist/runtime-cli-install.js +13 -10
  209. package/dist/runtime-cli-install.js.map +1 -1
  210. package/dist/settings-api.d.ts +1 -0
  211. package/dist/settings-api.js +87 -0
  212. package/dist/settings-api.js.map +1 -1
  213. package/dist/tmux-manager.d.ts +2 -0
  214. package/dist/tmux-manager.js +2 -0
  215. package/dist/tmux-manager.js.map +1 -1
  216. package/dist/tool-permissions.js +3 -0
  217. package/dist/tool-permissions.js.map +1 -1
  218. package/dist/ui/chat-msg-actions.js +3 -222
  219. package/dist/ui/hub-admin-overview.js +189 -0
  220. package/dist/ui/hub-client.js +36 -4
  221. package/dist/ui/hub-fleet-versions.js +393 -0
  222. package/dist/ui/hub-room-agent-strings.js +28 -0
  223. package/dist/ui/hub-room-composer.js +16 -8
  224. package/dist/ui/hub-room-members-strings.js +2 -2
  225. package/dist/ui/hub-room-members.js +3 -2
  226. package/dist/ui/hub-room-notify.js +161 -0
  227. package/dist/ui/hub-room-search.js +126 -0
  228. package/dist/ui/hub-room-strings.js +47 -1
  229. package/dist/ui/hub-room-thread.js +243 -35
  230. package/dist/ui/hub-room-unread.js +2 -1
  231. package/dist/ui/hub-strings.js +8 -0
  232. package/dist/ui/image-annotate.js +2 -283
  233. package/dist/ui/image-lightbox.js +2 -176
  234. package/dist/ui/image-zoom.js +2 -242
  235. package/dist/ui/notice-hub-update.js +94 -0
  236. package/dist/ui/panel-chat.js +121 -12
  237. package/dist/ui/panel-hub.js +133 -19
  238. package/dist/ui/panel-notices.js +3 -1
  239. package/dist/ui/panel-settings.js +1 -1
  240. package/dist/ui/settings-hub-updates.js +67 -0
  241. package/dist/ui/settings-hub.js +28 -3
  242. package/dist/ui/settings-registry.js +1 -0
  243. package/dist/ui/settings-update.js +11 -5
  244. package/dist/ui/settings-web-authority.js +1 -1
  245. package/dist/ui/shared/app-i18n.js +2 -0
  246. package/dist/ui/shared/app-nav.js +6 -2
  247. package/dist/ui/shared/app-prefs.js +2 -1
  248. package/dist/ui/shared/app-shell.js +29 -4
  249. package/dist/ui/shared/app-update.js +90 -8
  250. package/dist/ui/shared/app.css +33 -0
  251. package/dist/ui/shared/chat-composer.js +6 -3
  252. package/dist/ui/shared/chat-msg-actions.js +225 -0
  253. package/dist/ui/shared/chat-thread.js +70 -5
  254. package/dist/ui/shared/chat-work-bar.css +48 -0
  255. package/dist/ui/shared/hub-chat.css +16 -2
  256. package/dist/ui/shared/hub-owner.css +104 -0
  257. package/dist/ui/shared/hub-rooms-u2.css +16 -0
  258. package/dist/ui/shared/hub.css +5 -0
  259. package/dist/ui/shared/image-annotate.js +306 -0
  260. package/dist/ui/shared/image-lightbox.js +183 -0
  261. package/dist/ui/shared/image-zoom.js +242 -0
  262. package/dist/ui/shared/instance-nav.js +36 -7
  263. package/dist/ui/shared/model-picker.css +4 -3
  264. package/dist/ui/shared/view-strings.js +8 -0
  265. package/dist/ui/shared/web-authorize.js +2 -2
  266. package/dist/update-dispatch.d.ts +8 -1
  267. package/dist/update-dispatch.js +16 -1
  268. package/dist/update-dispatch.js.map +1 -1
  269. package/dist/update-idle.d.ts +65 -0
  270. package/dist/update-idle.js +190 -0
  271. package/dist/update-idle.js.map +1 -0
  272. package/dist/update-launch.d.ts +1 -1
  273. package/dist/update-launch.js +9 -2
  274. package/dist/update-launch.js.map +1 -1
  275. package/dist/usage/i18n-keys.d.ts +1 -1
  276. package/dist/usage/i18n-keys.js +1 -1
  277. package/dist/usage/i18n-keys.js.map +1 -1
  278. package/dist/usage/profile-timeline.d.ts +2 -0
  279. package/dist/usage/profile-timeline.js +4 -0
  280. package/dist/usage/profile-timeline.js.map +1 -1
  281. package/dist/usage/providers.js +4 -4
  282. package/dist/usage/providers.js.map +1 -1
  283. package/dist/usage/quota-history.d.ts +1 -1
  284. package/dist/view-api.js +1 -1
  285. package/dist/view-api.js.map +1 -1
  286. package/dist/web-api.js +19 -2
  287. package/dist/web-api.js.map +1 -1
  288. package/dist/web-notices.d.ts +3 -0
  289. package/dist/web-notices.js +17 -2
  290. package/dist/web-notices.js.map +1 -1
  291. package/dist/web-prefs.js +1 -0
  292. package/dist/web-prefs.js.map +1 -1
  293. package/dist/web-update.d.ts +15 -1
  294. package/package.json +1 -1
package/dist/daemon.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { HUB_REPORT_TARGET } from "./hub-report-target.js";
2
+ import { RoomConversationGeneration, roomContextInputMarker } from "./hub-room-conversation.js";
1
3
  import { checkpointGrokDelivery } from "./grok-delivery-proof.js";
2
4
  import { nativePaneToolRefusal } from "./native-pane-tools.js";
3
5
  import { generalByName } from "./general-instance.js";
@@ -79,6 +81,8 @@ import { QUEUED_HANDOFF_MAX_REDELIVERIES, QueuedHandoffStore } from "./queued-ha
79
81
  import { measureSyncWork, noteSyncWork } from "./sync-work-attribution.js";
80
82
  import { TranscriptDeltaReader } from "./transcript-delta-reader.js";
81
83
  import { checkpointCodexPane } from "./codex-pane-ownership.js";
84
+ import { codexAppliedFromRollout, codexRunningVersion, codexSupportsInlineModel, codexSwitchAnswerCount, codexSwitchFromPane, readFrom } from "./backend/codex-model-switch.js";
85
+ import { CLI_RUNTIME_SWITCH, cliRunningVersion, cliSwitchAllowed } from "./backend/cli-runtime-switch.js";
82
86
  import { buildResumeContinuation, clearInFlightTurnMarker, consumeInFlightTurnMarker, decideTurnResume, normalizeResumeBackend, readResumeFingerprint, RESUME_BLOCKING_DELIVERY_STATES, writeInFlightTurnMarker, } from "./turn-resume.js";
83
87
  import { codexLiveRowMatches } from "./backend/codex.js";
84
88
  import { codexPackageProblemMessage } from "./backend/codex-package.js";
@@ -109,7 +113,7 @@ const WEB_THEME_IPC = Object.freeze({
109
113
  });
110
114
  /** The largest picture any slot may take (a card slot's ceiling; the fleet checks the limit in force): read no more. */
111
115
  const WEB_THEME_ASSET_MAX_BYTES = ASSET_UPLOAD_MAX_BYTES;
112
- const CROSS_INSTANCE_TOOLS = new Set(["send_to_instance", "broadcast", "list_instances", "start_instance", "restart_instance", "create_instance", "delete_instance", "replace_instance", "request_information", "delegate_task", "report_result", "delivery_status", "describe_instance"]);
116
+ const CROSS_INSTANCE_TOOLS = new Set(["hub_room_status", "hub_room_list", "hub_room_post", "hub_room_members", "hub_people_search", "send_to_instance", "broadcast", "list_instances", "start_instance", "restart_instance", "create_instance", "delete_instance", "replace_instance", "request_information", "delegate_task", "report_result", "delivery_status", "describe_instance"]);
113
117
  const SCHEDULE_TOOLS = new Set(["create_schedule", "list_schedules", "update_schedule", "delete_schedule"]);
114
118
  const DECISION_TOOLS = new Set(["post_decision", "list_decisions", "update_decision"]);
115
119
  const TASK_TOOL = "task";
@@ -187,7 +191,7 @@ const HEALTH_ERROR_NOTIFY_INTERVAL_MS = 10 * 60_000;
187
191
  * Whether two working directories belong to the same project, so a fleet-scoped
188
192
  * decision recorded in one reaches the other. Covers the worktree/checkout
189
193
  * layout AgEnD fleets actually use — `AgEnD`, `AgEnD-dev1`, `AgEnD-dev2`,
190
- * `AgEnD-reviewer`, `AgEnD-main` are one project; `DouPo_Server` is not.
194
+ * `AgEnD-reviewer`, `AgEnD-main` are one project; `GameServer` is not.
191
195
  * Nesting counts too (a subdirectory of a project belongs to it).
192
196
  */
193
197
  export function sameProjectFamily(a, b) {
@@ -563,6 +567,13 @@ const STARTUP_DIALOG_BUDGET_MS = 30_000;
563
567
  export const OWN_SWITCH_WAIT_MS = 6_000;
564
568
  /** #1690: after an answer to that dialog, how long it gets to go away. */
565
569
  const OWN_SWITCH_SETTLE_MS = 3_000;
570
+ /** M-3175: how long a codex switch waits for the pane to be idle before it is not typed (the fleet then restarts instead). */
571
+ const CODEX_SWITCH_IDLE_MS = 60_000;
572
+ /** M-3175: how long codex gets to record the switch (rollout) or answer it (pane) after it is typed. */
573
+ const CODEX_SWITCH_VERIFY_MS = 10_000;
574
+ /** M-3175: the scrollback read around a codex switch (codex's answer rows are counted in it) and the most of a rollout delta read. */
575
+ const CODEX_SWITCH_HISTORY_LINES = 200;
576
+ const CODEX_SWITCH_ROLLOUT_READ = 4 * 1024 * 1024;
566
577
  /** A blocking dialog still on screen this long after first being seen is reported for a human. */
567
578
  const DIALOG_PARKED_NOTIFY_MS = 60_000;
568
579
  /** #2675: a card a person can answer from the chat is posted once it has been on screen, unchanged, this long. */
@@ -2455,25 +2466,26 @@ export class Daemon extends EventEmitter {
2455
2466
  if (!["claude-code", "codex"].includes(backend))
2456
2467
  return;
2457
2468
  const marker = durableAttempt ? `[agend-delivery-id:${durableAttempt.deliveryId}]`
2458
- : humanVerificationId ? verdict.humanReceipt?.marker ?? `[agend-human-id:${humanVerificationId}]` : null;
2469
+ : humanVerificationId ? verdict.humanReceipt?.marker ?? `[agend-human-id:${humanVerificationId}]` : roomContextInputMarker(track.meta);
2459
2470
  if (!marker || !formatted.startsWith(marker))
2460
2471
  return;
2461
2472
  let found = verdict.transcriptCheckpoint ?? null;
2462
2473
  if (!found) {
2463
2474
  try {
2464
- found = await this.transcriptMonitor?.reconciliationCheckpoint() ?? null;
2475
+ // M-2403: a native or remote pane checkpoints its runtime transcript (no local file); a local CLI, its file.
2476
+ const runtime = this.nativePaneLifecycle ? await this.transcriptMonitor?.reconciliationRuntimeCheckpoint() ?? null : null;
2477
+ found = runtime ? { runtime } : await this.transcriptMonitor?.reconciliationCheckpoint() ?? null;
2465
2478
  }
2466
2479
  catch (err) {
2467
2480
  this.logger.debug({ err }, "Could not checkpoint the transcript before a queued hand-off");
2468
2481
  }
2469
2482
  }
2470
- // main→alpha sync: a hand-off record is judged against a local transcript file. A native or remote runtime's
2471
- // transcript (no local path) has none: it runs as before (✅ at the hand-off), as with no checkpoint at all.
2472
- const checkpoint = found && typeof found.path === "string" && typeof found.offset === "number" ? { path: found.path, offset: found.offset } : null;
2483
+ const checkpoint = found?.runtime ? { runtime: found.runtime }
2484
+ : found && typeof found.path === "string" && typeof found.offset === "number" ? { path: found.path, offset: found.offset } : null;
2473
2485
  if (!checkpoint)
2474
2486
  return; // nothing could judge it later: it runs as before (✅ at the hand-off)
2475
2487
  const entry = {
2476
- id: track.id ?? randomUUID(), marker, backend, path: checkpoint.path, offset: checkpoint.offset,
2488
+ id: track.id ?? randomUUID(), marker, backend, ...checkpoint,
2477
2489
  content: track.content, meta: track.meta, wire: formatted, holder: this.handoffHolder(), createdAt: Date.now(),
2478
2490
  redeliveries: track.redeliveries ?? 0,
2479
2491
  };
@@ -2504,6 +2516,8 @@ export class Daemon extends EventEmitter {
2504
2516
  this.dropQueuedHandoff(verdict);
2505
2517
  return;
2506
2518
  }
2519
+ if (sent && !verdict.roomInputQueued && meta.hub_room_context_generation)
2520
+ this.roomInputHandedOff(meta);
2507
2521
  const id = meta.handoff_redelivery;
2508
2522
  if (!id)
2509
2523
  return;
@@ -2545,12 +2559,24 @@ export class Daemon extends EventEmitter {
2545
2559
  */
2546
2560
  watchQueuedHandoff(entry) {
2547
2561
  const spawn = this.spawnGeneration, fence = this.launchFenceEpoch, epoch = this.deliveryEpoch;
2562
+ // M-2403: a native or remote pane's record is read through its runner (the runtime reader), a local one from its file.
2563
+ let source;
2564
+ if (entry.runtime) {
2565
+ try {
2566
+ source = { reader: this.nativeTranscriptReader(entry.runtime, { marker: entry.marker, ...(entry.wire !== undefined ? { wire: entry.wire } : {}) }) };
2567
+ }
2568
+ catch (err) {
2569
+ this.logger.debug({ err, handoff: entry.id }, "Queued hand-off: its pane's transcript is not readable now");
2570
+ return this.settleQueuedHandoff(entry, "unverifiable", "transcript:unavailable");
2571
+ }
2572
+ }
2573
+ else
2574
+ source = { path: entry.path, offset: entry.offset };
2548
2575
  const started = consumedWatches.start({
2549
2576
  deliveryId: `handoff:${entry.id}`,
2550
2577
  attemptNo: entry.redeliveries,
2551
2578
  backend: entry.backend,
2552
- path: entry.path,
2553
- offset: entry.offset,
2579
+ ...source,
2554
2580
  marker: entry.marker,
2555
2581
  ...(entry.wire !== undefined ? { wire: entry.wire } : {}),
2556
2582
  // A cancel or stop moves the epoch: the watch ends quietly (a cancel cleared the record, a stop leaves it).
@@ -2581,6 +2607,8 @@ export class Daemon extends EventEmitter {
2581
2607
  const meta = entry.meta;
2582
2608
  const status = channelStatus(meta);
2583
2609
  if (outcome === "taken") {
2610
+ if (meta.hub_room_context_generation)
2611
+ this.roomInputHandedOff(meta);
2584
2612
  this.logger.info({ handoff: entry.id, proof, redeliveries: entry.redeliveries }, "Queued hand-off taken by the CLI");
2585
2613
  if (status)
2586
2614
  this.emit("message_confirmed", status);
@@ -2628,8 +2656,20 @@ export class Daemon extends EventEmitter {
2628
2656
  const spawn = this.spawnGeneration, fence = this.launchFenceEpoch, epoch = this.deliveryEpoch;
2629
2657
  const fresh = () => spawn === this.spawnGeneration && fence === this.launchFenceEpoch && epoch === this.deliveryEpoch
2630
2658
  && !this.deliveryWritesStopping;
2631
- let redelivered = 0, taken = 0, unverifiable = 0;
2659
+ let redelivered = 0, taken = 0, unverifiable = 0, watching = 0;
2632
2660
  for (const entry of entries) {
2661
+ if (entry.runtime) {
2662
+ const outcome = await this.reconcileRuntimeHandoff(entry, holder, fresh);
2663
+ if (outcome === "stale")
2664
+ return;
2665
+ if (outcome === "taken")
2666
+ taken++;
2667
+ else if (outcome === "unverifiable")
2668
+ unverifiable++;
2669
+ else if (outcome === "watching")
2670
+ watching++;
2671
+ continue;
2672
+ }
2633
2673
  const kind = await scanTranscriptForDeliveryMarker(entry.path, entry.offset, entry.backend, { marker: entry.marker, ...(entry.wire !== undefined ? { wire: entry.wire } : {}) });
2634
2674
  // This CLI is gone already, or a cancel came: the next CLI settles them (a cancel cleared them).
2635
2675
  if (!fresh())
@@ -2669,7 +2709,71 @@ export class Daemon extends EventEmitter {
2669
2709
  this.pushChannelMessage(entry.content, { ...meta, handoff_redelivery: entry.id,
2670
2710
  handoff_redeliveries: String(next.redeliveries), handoff_holder: next.holder }, undefined, epoch);
2671
2711
  }
2672
- this.logger.info({ instance: this.name, redelivered, taken, unverifiable, proof: "transcript" }, "Queued hand-offs left by the previous CLI settled");
2712
+ this.logger.info({ instance: this.name, redelivered, taken, unverifiable, watching, proof: "transcript" }, "Queued hand-offs left by the previous CLI settled");
2713
+ }
2714
+ /**
2715
+ * M-2403: a native or remote pane's record, after this daemon came up. Its runner may have kept the CLI (and its queue)
2716
+ * across the coordinator's restart, so nothing here proves the queue is gone, and a runtime record is never
2717
+ * redelivered. Read through the runner from its checkpoint (bounded, as reconcileNativePaneTarget): taken → ✅; the
2718
+ * same launch still current with the marker not taken yet → watched again under this CLI; that launch gone, or its
2719
+ * transcript unreadable → unverifiable (reported, never pasted again).
2720
+ */
2721
+ async reconcileRuntimeHandoff(entry, holder, fresh) {
2722
+ const still = () => {
2723
+ let current;
2724
+ try {
2725
+ current = this.handoffStore().get(entry.id);
2726
+ }
2727
+ catch {
2728
+ current = undefined;
2729
+ }
2730
+ return !!current && current.holder === entry.holder && current.redeliveries === entry.redeliveries;
2731
+ };
2732
+ const native = this.nativePaneLifecycle;
2733
+ let kind = null;
2734
+ if (native?.current(entry.runtime)) {
2735
+ let reader;
2736
+ try {
2737
+ reader = this.nativeTranscriptReader(entry.runtime, { marker: entry.marker, ...(entry.wire !== undefined ? { wire: entry.wire } : {}) });
2738
+ for (let n = 0; n < 8; n++) {
2739
+ const before = reader.readPosition, look = await reader.look();
2740
+ if (!fresh())
2741
+ return "stale";
2742
+ kind = look;
2743
+ if (markerConsumed(look) || look === "unavailable" || look === "pending" || reader.readPosition === before)
2744
+ break;
2745
+ }
2746
+ }
2747
+ catch {
2748
+ kind = "unavailable";
2749
+ }
2750
+ finally {
2751
+ reader?.close?.();
2752
+ }
2753
+ }
2754
+ if (!fresh())
2755
+ return "stale";
2756
+ if (!still())
2757
+ return "skipped";
2758
+ if (kind && markerConsumed(kind)) {
2759
+ this.settleQueuedHandoff(entry, "taken", `restart-transcript:${kind}`);
2760
+ return "taken";
2761
+ }
2762
+ if (kind === null || kind === "unavailable" || !native?.current(entry.runtime)) {
2763
+ this.settleQueuedHandoff(entry, "unverifiable", "restart-transcript:unavailable");
2764
+ return "unverifiable";
2765
+ }
2766
+ // The same launch still holds it in its queue: this CLI watches it from where the read stopped.
2767
+ const next = { ...entry, holder };
2768
+ try {
2769
+ this.handoffStore().put(next);
2770
+ }
2771
+ catch (err) {
2772
+ this.logger.warn({ err, handoff: entry.id }, "Could not update a queued hand-off record");
2773
+ return "skipped";
2774
+ }
2775
+ this.watchQueuedHandoff(next);
2776
+ return "watching";
2673
2777
  }
2674
2778
  finishDurableSubmission(delivery, verdict) {
2675
2779
  // Legacy backends may accept a pane write without enough pane evidence to
@@ -3133,6 +3237,7 @@ export class Daemon extends EventEmitter {
3133
3237
  }
3134
3238
  if (nativeDisposition)
3135
3239
  this.isNewSession = nativeDisposition === "fresh";
3240
+ this.resetRoomConversation(nativeDisposition === "reattached");
3136
3241
  // #1209: conditional continuation for the turn interrupted by the last
3137
3242
  // restart, if the gates allow. Detached; the gate
3138
3243
  // consumes its one-shot marker first and never throws into boot.
@@ -5037,6 +5142,8 @@ export class Daemon extends EventEmitter {
5037
5142
  return;
5038
5143
  }
5039
5144
  const verdict = { reached: false };
5145
+ let codexBefore = null;
5146
+ let cliBefore = null;
5040
5147
  try {
5041
5148
  await this.wake();
5042
5149
  if (!this.isDeliveryEpochCurrent(deliveryEpoch)) {
@@ -5046,6 +5153,27 @@ export class Daemon extends EventEmitter {
5046
5153
  tellWritten(false);
5047
5154
  return;
5048
5155
  }
5156
+ // M-3175: a codex switch is typed only into an idle pane of a codex known to take it, with the rollout's end taken first.
5157
+ if (ownSwitch?.codex) {
5158
+ const gate = await this.codexSwitchGate();
5159
+ if ("blocked" in gate) {
5160
+ this.logger.info({ requested: ownSwitch.codex, reason: gate.blocked, version: gate.version }, "Codex runtime switch not typed");
5161
+ reportSwitch({ outcome: "not_sent", reason: gate.blocked, version: gate.version ?? null });
5162
+ tellWritten(false);
5163
+ return;
5164
+ }
5165
+ codexBefore = gate;
5166
+ }
5167
+ if (ownSwitch?.cli) {
5168
+ const gate = await this.cliSwitchGate(ownSwitch.cli);
5169
+ if ("blocked" in gate) {
5170
+ this.logger.info({ requested: ownSwitch.cli, reason: gate.blocked, version: gate.version }, "CLI runtime switch not typed");
5171
+ reportSwitch({ outcome: "not_sent", reason: gate.blocked, version: gate.version ?? null });
5172
+ tellWritten(false);
5173
+ return;
5174
+ }
5175
+ cliBefore = gate;
5176
+ }
5049
5177
  // Board 907c7899: the pane just before this attempt's paste — after its readiness wait, last capture and fence,
5050
5178
  // under the paste lock (no other input lands in between). Each attempt looks again.
5051
5179
  const lookBefore = async () => {
@@ -5060,8 +5188,10 @@ export class Daemon extends EventEmitter {
5060
5188
  preserveExactBytes: true,
5061
5189
  // #1690: our own /model holds every other delivery from its write on — before the lock is released, so a steer
5062
5190
  // or /btw waiting on it cannot type into the gap before claude paints "Switch model?" (default cursor: Yes).
5063
- ...(ownSwitch || notifyWritten || contextReset ? { onPaneWritten: () => { if (contextReset)
5064
- this.resetInboundPresentation(); if (ownSwitch) {
5191
+ ...(ownSwitch || notifyWritten || contextReset ? { onPaneWritten: () => { if (contextReset) {
5192
+ this.resetInboundPresentation();
5193
+ this.resetRoomConversation();
5194
+ } if (ownSwitch) {
5065
5195
  this.ownSwitch = ownSwitch;
5066
5196
  if (currentModelOwner())
5067
5197
  modelObserver?.ownIntent(ownSwitch.requested);
@@ -5115,7 +5245,7 @@ export class Daemon extends EventEmitter {
5115
5245
  reportSwitch({ outcome: "not_sent" }); // its write never began
5116
5246
  else {
5117
5247
  try {
5118
- reportSwitch(await this.answerOwnSwitchDialog(ownSwitch));
5248
+ reportSwitch(ownSwitch.codex ? await this.verifyCodexSwitch(ownSwitch.codex, codexBefore) : ownSwitch.cli ? await this.verifyCliSwitch(ownSwitch.cli, cliBefore) : await this.answerOwnSwitchDialog(ownSwitch));
5119
5249
  }
5120
5250
  catch (err) {
5121
5251
  this.logger.warn({ err: err.message }, "Answering our own model switch failed");
@@ -5145,11 +5275,118 @@ export class Daemon extends EventEmitter {
5145
5275
  return;
5146
5276
  }
5147
5277
  const sw = msg.runtime_switch;
5148
- const ownSwitch = sw && typeof sw.id === "string" && sw.kind === "model" && typeof sw.requested === "string"
5149
- ? { id: sw.id, kind: "model", requested: sw.requested } : undefined;
5278
+ const codexPart = (v) => v === null ? null : typeof v === "string" && v ? v : undefined;
5279
+ const codex = sw?.codex && typeof sw.codex === "object" ? { model: codexPart(sw.codex.model), effort: codexPart(sw.codex.effort) } : undefined;
5280
+ // M-3180: one generic spec for the CLIs of CLI_RUNTIME_SWITCH — a known backend and one command (which may carry both model and effort).
5281
+ const rawCli = sw?.cli;
5282
+ const cli = rawCli && typeof rawCli === "object" && typeof rawCli.backend === "string" && Object.hasOwn(CLI_RUNTIME_SWITCH, rawCli.backend)
5283
+ ? { backend: rawCli.backend, model: codexPart(rawCli.model), effort: codexPart(rawCli.effort) } : rawCli === undefined ? undefined : null;
5284
+ const cliOk = !cli || (cli.model !== undefined && cli.effort !== undefined && (cli.model !== null || cli.effort !== null)
5285
+ && CLI_RUNTIME_SWITCH[cli.backend].command({ model: cli.model, effort: cli.effort }) === msg.content);
5286
+ // A malformed switch must not downgrade into an ungated legacy raw paste.
5287
+ if (rawCli !== undefined && (cli === null || !cliOk || codex || !sw || typeof sw.id !== "string" || sw.kind !== "model" || typeof sw.requested !== "string")) {
5288
+ if (typeof sw?.id === "string")
5289
+ this.broadcastFleetMessage({ type: "runtime_switch_result", id: sw.id, outcome: "not_sent", reason: "command" });
5290
+ return;
5291
+ }
5292
+ const ownSwitch = sw && typeof sw.id === "string" && sw.kind === "model" && typeof sw.requested === "string" && cli !== null && cliOk && !(codex && cli)
5293
+ && (!codex || (codex.model !== undefined && codex.effort !== undefined && (codex.model !== null || codex.effort !== null)))
5294
+ ? { id: sw.id, kind: "model", requested: sw.requested,
5295
+ ...(codex ? { codex: { model: codex.model, effort: codex.effort } } : {}),
5296
+ ...(cli ? { cli: { backend: cli.backend, model: cli.model, effort: cli.effort } } : {}) } : undefined;
5150
5297
  const notifyWritten = typeof msg.notify_written === "string" && /^[0-9a-f]{16}$/.test(msg.notify_written) ? msg.notify_written : undefined;
5151
5298
  this.queueRawPaste(msg.content, this.captureDeliveryEpoch(msg.delivery_epoch), msg.confirm_clear === true, durableAttempt ? { ...durableAttempt, submissionMode: "raw_paste", silentSchedule: msg.silent_schedule === true } : undefined, ownSwitch, notifyWritten, msg.context_reset === "clear" || msg.context_reset === "compact" ? msg.context_reset : undefined);
5152
5299
  }
5300
+ /**
5301
+ * M-3175: before typing a codex `/model … --reasoning=…`: the pane authoritatively idle (bounded), the RUNNING codex at a
5302
+ * version that has the inline form (an older one would send the line to the model as a prompt), and what the switch is
5303
+ * verified against afterwards — the rollout's end when the session has one, and the count of codex's answers on the pane.
5304
+ */
5305
+ async codexSwitchGate() {
5306
+ const tmux = this.tmux;
5307
+ if (!tmux || !await this.waitForAuthoritativePaneIdle(CODEX_SWITCH_IDLE_MS, 500) || this.tmux !== tmux)
5308
+ return { blocked: "busy" };
5309
+ const pid = await tmux.getPanePid?.() ?? null;
5310
+ const version = pid ? await codexRunningVersion(pid) : null;
5311
+ if (!codexSupportsInlineModel(version))
5312
+ return { blocked: "version", version };
5313
+ const pane = await tmux.capturePaneWithHistory(CODEX_SWITCH_HISTORY_LINES).catch(() => "");
5314
+ let rollout = null;
5315
+ const session = this.backend?.readRawPasteSession?.(pane);
5316
+ if (session) {
5317
+ const file = await checkpointCodexPane(session.sessionsDir, session.sessionId, this.config.working_directory || process.cwd()).catch(() => null);
5318
+ if (file)
5319
+ rollout = { path: file.path, offset: file.offset };
5320
+ }
5321
+ return { rollout, answers: codexSwitchAnswerCount(pane), version };
5322
+ }
5323
+ /**
5324
+ * M-3180: before typing a CLI_RUNTIME_SWITCH step: the pane authoritatively idle (bounded), the RUNNING binary at the entry's minimum
5325
+ * for this step, and what the verdict compares against — the scrollback before the command and the entry's record checkpoint.
5326
+ */
5327
+ async cliSwitchGate(step) {
5328
+ const tmux = this.tmux, entry = CLI_RUNTIME_SWITCH[step.backend];
5329
+ if (!entry || !tmux || !await this.waitForAuthoritativePaneIdle(CODEX_SWITCH_IDLE_MS, 500) || this.tmux !== tmux)
5330
+ return { blocked: "busy" };
5331
+ const pid = await tmux.getPanePid?.() ?? null;
5332
+ const version = pid ? await cliRunningVersion(pid, { backend: step.backend, matchExe: entry.matchExe, versionFromExe: entry.versionFromExe }) : null;
5333
+ if (!cliSwitchAllowed(entry, step, version))
5334
+ return { blocked: "version", version };
5335
+ const pane = await tmux.capturePaneWithHistory(CODEX_SWITCH_HISTORY_LINES).catch(() => "");
5336
+ const record = entry.checkpoint ? await entry.checkpoint(pane, this.config.working_directory || process.cwd()).catch(() => undefined) : undefined;
5337
+ return { pane, ...(record !== undefined ? { record } : {}) };
5338
+ }
5339
+ /** M-3180: the entry's verdict on the scrollback after the step, against the one before it; nothing in time is not confirmed. */
5340
+ async verifyCliSwitch(step, before) {
5341
+ const tmux = this.tmux, entry = CLI_RUNTIME_SWITCH[step.backend];
5342
+ if (!tmux || !before || !entry)
5343
+ return { outcome: "not_confirmed" };
5344
+ const deadline = performance.now() + CODEX_SWITCH_VERIFY_MS;
5345
+ while (performance.now() < deadline && this.tmux === tmux) {
5346
+ const pane = await tmux.capturePaneWithHistory(CODEX_SWITCH_HISTORY_LINES).catch(() => "");
5347
+ const verdict = await entry.verify({ model: step.model, effort: step.effort }, before, { pane });
5348
+ if (verdict?.outcome === "switched")
5349
+ return { outcome: "switched", confirmed: true, shown: verdict.shown };
5350
+ if (verdict?.outcome === "mismatch")
5351
+ return { outcome: "mismatch", shown: verdict.shown, answered: true };
5352
+ await new Promise(resolve => setTimeout(resolve, 200));
5353
+ }
5354
+ return { outcome: "not_confirmed" };
5355
+ }
5356
+ /**
5357
+ * M-3175: what our codex switch came to. The rollout's `thread_settings_applied` written after our checkpoint is the proof
5358
+ * (codex writes it at once once the session has a rollout); a session with none yet has codex's own answer on the pane —
5359
+ * a NEW `• Model changed to … for this session only` (or `■` refusal) after the ones counted before the line was typed.
5360
+ * Anything that does not name what was asked is a mismatch; no answer in time is not confirmed. The fleet restarts on both.
5361
+ */
5362
+ async verifyCodexSwitch(want, before) {
5363
+ const tmux = this.tmux;
5364
+ if (!tmux || !before)
5365
+ return { outcome: "not_confirmed" };
5366
+ const fits = (model, effort) => (want.model === null || model === want.model) && (want.effort === null || effort === want.effort);
5367
+ const deadline = performance.now() + CODEX_SWITCH_VERIFY_MS;
5368
+ while (performance.now() < deadline && this.tmux === tmux) {
5369
+ if (before.rollout) {
5370
+ const applied = codexAppliedFromRollout(await readFrom(before.rollout.path, before.rollout.offset, CODEX_SWITCH_ROLLOUT_READ));
5371
+ if (applied) {
5372
+ const shown = `${applied.model} ${applied.effort ?? "default"}`;
5373
+ return fits(applied.model, applied.effort) ? { outcome: "switched", confirmed: true, shown } : { outcome: "mismatch", shown, answered: true };
5374
+ }
5375
+ }
5376
+ const pane = await tmux.capturePaneWithHistory(CODEX_SWITCH_HISTORY_LINES).catch(() => "");
5377
+ if (codexSwitchAnswerCount(pane) > before.answers) {
5378
+ const answer = codexSwitchFromPane(pane);
5379
+ if (answer?.kind === "refused")
5380
+ return { outcome: "mismatch", shown: answer.text, answered: true };
5381
+ if (answer?.kind === "switched" && !before.rollout) {
5382
+ const shown = `${answer.model} ${answer.effort}`;
5383
+ return fits(answer.model, answer.effort) ? { outcome: "switched", confirmed: true, shown } : { outcome: "mismatch", shown, answered: true };
5384
+ }
5385
+ }
5386
+ await new Promise(resolve => setTimeout(resolve, 200));
5387
+ }
5388
+ return { outcome: "not_confirmed" };
5389
+ }
5153
5390
  /**
5154
5391
  * #1690 (the user's choice A): after AgEnD's own `/model <name>`, claude may ask "Switch model?" (a warm cache for
5155
5392
  * another model). When the model it names is the one asked for, answer Yes; otherwise No (Escape — `Kept model as …`),
@@ -5910,6 +6147,10 @@ export class Daemon extends EventEmitter {
5910
6147
  }
5911
6148
  /** Shared Fleet inputs: socket and native transports retain the same wake, epoch and raw-paste semantics. */
5912
6149
  handleFleetMessage(msg, send, current = () => true) {
6150
+ if (msg.type === "hub_room_tools_changed") {
6151
+ this.ipcServer?.broadcast({ type: "hub_room_tools_changed" });
6152
+ return true;
6153
+ }
5913
6154
  if (msg.type === "query_sessions") {
5914
6155
  send({ type: "query_sessions_response", sessions: [] });
5915
6156
  }
@@ -8498,7 +8739,9 @@ export class Daemon extends EventEmitter {
8498
8739
  // byte for byte (its proof is the wire's hash), so the notice waits for the next delivery without one.
8499
8740
  const whatsNew = this.pendingWhatsNew && !meta.human_receipt_id && !meta.handoff_redelivery
8500
8741
  ? this.currentWhatsNew(this.pendingWhatsNew) : null;
8501
- const pasted = whatsNew ? withWhatsNew(formatted, whatsNew.notice) : formatted;
8742
+ const body = whatsNew ? withWhatsNew(formatted, whatsNew.notice) : formatted;
8743
+ const roomMarker = roomContextInputMarker(meta);
8744
+ const pasted = roomMarker ? `${roomMarker}\n${body}` : body;
8502
8745
  const status = channelStatus(meta);
8503
8746
  // A fresh delivery begins a fresh turn — its bubble must not inherit
8504
8747
  // the previous turn's tool list.
@@ -8516,6 +8759,10 @@ export class Daemon extends EventEmitter {
8516
8759
  this.logger.info({ handoff: meta.handoff_redelivery }, "Queued hand-off redelivery dropped: its CLI was replaced before the write");
8517
8760
  return;
8518
8761
  }
8762
+ if (meta.hub_room_context_generation && meta.hub_room_context_generation !== this.roomConversationGeneration()) {
8763
+ this.reportCrossInstanceDeliveryFailure(meta, { reached: true, phase: "room-context", proof: "stale-generation" });
8764
+ return;
8765
+ }
8519
8766
  const durableAttempt = this.durableDeliveryAttempt(meta, content);
8520
8767
  if (durableAttempt === false) {
8521
8768
  this.deferDurableDelivery(meta, "invalid durable delivery attempt metadata");
@@ -8527,6 +8774,7 @@ export class Daemon extends EventEmitter {
8527
8774
  sent = await this.deliverMessage(pasted, status, {
8528
8775
  deliveryEpoch,
8529
8776
  submissionId: meta.message_id,
8777
+ ...(meta.hub_room_context_generation ? { roomContextGeneration: meta.hub_room_context_generation } : {}),
8530
8778
  ...(meta.verification_id ? { humanVerificationId: meta.verification_id, humanMeta: meta } : {}),
8531
8779
  verdict,
8532
8780
  durableAttempt: durableAttempt || undefined,
@@ -8620,8 +8868,8 @@ export class Daemon extends EventEmitter {
8620
8868
  const verdict = opts?.verdict ?? { reached: false };
8621
8869
  if (opts?.durableAttempt)
8622
8870
  verdict.durableAttempt = true;
8623
- const cancelled = () => opts?.deliveryEpoch !== undefined
8624
- && !this.isDeliveryEpochCurrent(opts.deliveryEpoch);
8871
+ const cancelled = () => (opts?.deliveryEpoch !== undefined && !this.isDeliveryEpochCurrent(opts.deliveryEpoch))
8872
+ || (!!opts?.roomContextGeneration && opts.roomContextGeneration !== this.roomConversationGeneration());
8625
8873
  if (cancelled() || this.stormWindow?.isStopped())
8626
8874
  return false;
8627
8875
  formatted = prepareDeliveryWire(formatted, opts?.preserveExactBytes);
@@ -10984,6 +11232,7 @@ export class Daemon extends EventEmitter {
10984
11232
  signature.takenMarker = leadMarker;
10985
11233
  const rawPaste = durableAttempt?.submissionMode === "raw_paste";
10986
11234
  const humanAttempt = verdict.humanReceipt;
11235
+ verdict.roomInputQueued = handingOffToNativeQueue || steer;
10987
11236
  const humanMode = rawPaste ? "raw_paste" : steer ? "steer"
10988
11237
  : handingOffToNativeQueue ? "native_queue_handoff" : "idle_submit";
10989
11238
  if (humanAttempt && signature.unique && signature.value === humanReceiptMarker(humanAttempt.verificationId, humanDialect).slice(1, -1)
@@ -11349,6 +11598,7 @@ export class Daemon extends EventEmitter {
11349
11598
  : after === "queue" ? "composer-empty-queue" : "composer-empty-idle");
11350
11599
  verdict.phase = steer ? "steer-accepted" : "composer-accepted";
11351
11600
  verdict.proof = `${steer ? "steer" : "handoff"}-composer-${after}`;
11601
+ verdict.roomInputQueued = after === "queue";
11352
11602
  if (status)
11353
11603
  this.emit("message_confirmed", status); // ✅ taken from the box
11354
11604
  return true;
@@ -11424,6 +11674,7 @@ export class Daemon extends EventEmitter {
11424
11674
  if (verdict.handoff && !verdict.trackHandoff?.id)
11425
11675
  this.dropQueuedHandoff(verdict);
11426
11676
  verdict.handoff = undefined;
11677
+ verdict.roomInputQueued = false;
11427
11678
  if (windowId && this.controlClient && !(await this.controlClient.waitUntilIdle(windowId))) {
11428
11679
  verdict.phase = "native-queue-idle-wait";
11429
11680
  verdict.proof = "idle-wait-failed";
@@ -12789,7 +13040,7 @@ export class Daemon extends EventEmitter {
12789
13040
  type: "fleet_outbound",
12790
13041
  tool,
12791
13042
  args,
12792
- ...(operationId ? { operationId, sourceDaemonBootId: this.bootId } : {}),
13043
+ ...((operationId || (tool.startsWith("hub_room_") || tool === "hub_people_search")) ? { ...(operationId ? { operationId } : {}), sourceDaemonBootId: this.bootId } : {}),
12793
13044
  fleetRequestId: fleetReqId,
12794
13045
  senderSessionName,
12795
13046
  });
@@ -15041,11 +15292,40 @@ export class Daemon extends EventEmitter {
15041
15292
  this.lastIdleSessionRefreshAt = now;
15042
15293
  void refresh.call(this.backend).then(() => this.saveSessionId(), () => { });
15043
15294
  }
15295
+ roomConversationState = null;
15296
+ roomConversationGeneration() {
15297
+ try {
15298
+ // Local non-Claude backends checkpoint their own session below; do not replace it with a Claude-only field.
15299
+ if (this.nativePaneLifecycle || (this.config.backend ?? "claude-code") === "claude-code")
15300
+ this.roomConversationState?.observeSession(this.ownedWorkingSession);
15301
+ }
15302
+ catch (err) {
15303
+ this.logger.warn({ err }, "Room conversation checkpoint failed");
15304
+ return null;
15305
+ }
15306
+ return this.roomConversationState?.current() ?? null;
15307
+ }
15308
+ resetRoomConversation(reattached = false) {
15309
+ this.roomConversationState ??= new RoomConversationGeneration(this.instanceDir);
15310
+ try {
15311
+ this.roomConversationState.start(reattached);
15312
+ }
15313
+ catch (err) {
15314
+ this.logger.warn({ err }, "Room conversation generation is unconfirmed");
15315
+ }
15316
+ }
15317
+ roomInputHandedOff(meta) {
15318
+ const generation = meta.hub_room_context_generation;
15319
+ if (meta.from_instance !== HUB_REPORT_TARGET || !generation || generation !== this.roomConversationGeneration())
15320
+ return;
15321
+ this.broadcastFleetMessage({ type: "hub_room_input", correlationId: meta.correlation_id, generation });
15322
+ }
15044
15323
  saveSessionId() {
15045
15324
  if (this.nativePaneLifecycle) {
15046
15325
  try {
15047
15326
  this.nativePaneLifecycle.checkpointSession();
15048
15327
  this.ownedWorkingSession = this.backend?.getSessionId() ?? null;
15328
+ this.roomConversationState?.observeSession(this.ownedWorkingSession);
15049
15329
  }
15050
15330
  catch (err) {
15051
15331
  this.logger.warn({ err }, "Native conversation checkpoint is unconfirmed");
@@ -15060,6 +15340,7 @@ export class Daemon extends EventEmitter {
15060
15340
  const sid = this.backend?.getSessionId();
15061
15341
  if (!sid)
15062
15342
  return;
15343
+ this.roomConversationState?.observeSession(sid);
15063
15344
  if ((this.config.backend ?? "claude-code") === "claude-code" && Buffer.byteLength(sid) <= 256
15064
15345
  && !/[\u0000-\u001f\u007f]/.test(sid) && this.ownedWorkingSession !== sid) {
15065
15346
  this.ownedWorkingSession = sid;