@songsid/agend 2.4.0-beta.24 → 2.4.0-beta.25

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 (395) hide show
  1. package/README.md +1 -1
  2. package/README.zh-TW.md +1 -1
  3. package/dist/agend-home.js +5 -5
  4. package/dist/agend-home.js.map +1 -1
  5. package/dist/agent-endpoint.js +10 -0
  6. package/dist/agent-endpoint.js.map +1 -1
  7. package/dist/agent-workspace.d.ts +18 -2
  8. package/dist/agent-workspace.js +15 -4
  9. package/dist/agent-workspace.js.map +1 -1
  10. package/dist/backend/antigravity.js +8 -6
  11. package/dist/backend/antigravity.js.map +1 -1
  12. package/dist/backend/claude-code.js +17 -0
  13. package/dist/backend/claude-code.js.map +1 -1
  14. package/dist/backend/claude-usage-credits.d.ts +8 -0
  15. package/dist/backend/claude-usage-credits.js +121 -0
  16. package/dist/backend/claude-usage-credits.js.map +1 -0
  17. package/dist/backend/types.d.ts +30 -0
  18. package/dist/backend/types.js.map +1 -1
  19. package/dist/build-provenance.json +1 -1
  20. package/dist/channel/adapters/discord.js +7 -1
  21. package/dist/channel/adapters/discord.js.map +1 -1
  22. package/dist/channel/tool-router.js +1 -0
  23. package/dist/channel/tool-router.js.map +1 -1
  24. package/dist/cli-audited.js +9 -4
  25. package/dist/cli-audited.js.map +1 -1
  26. package/dist/cli.js +184 -21
  27. package/dist/cli.js.map +1 -1
  28. package/dist/config-validator.js +11 -1
  29. package/dist/config-validator.js.map +1 -1
  30. package/dist/config.js +2 -0
  31. package/dist/config.js.map +1 -1
  32. package/dist/contact-auth-store.d.ts +18 -0
  33. package/dist/contact-auth-store.js +55 -8
  34. package/dist/contact-auth-store.js.map +1 -1
  35. package/dist/contact-auth-types.d.ts +3 -0
  36. package/dist/contact-auth-types.js.map +1 -1
  37. package/dist/contact-change-proposals.d.ts +34 -0
  38. package/dist/contact-change-proposals.js +1 -1
  39. package/dist/contact-change-proposals.js.map +1 -1
  40. package/dist/cross-instance-notice.d.ts +1 -0
  41. package/dist/cross-instance-notice.js +9 -8
  42. package/dist/cross-instance-notice.js.map +1 -1
  43. package/dist/daemon.d.ts +35 -0
  44. package/dist/daemon.js +234 -19
  45. package/dist/daemon.js.map +1 -1
  46. package/dist/delivery-outbox.d.ts +42 -1
  47. package/dist/delivery-outbox.js +194 -20
  48. package/dist/delivery-outbox.js.map +1 -1
  49. package/dist/fleet-context.d.ts +8 -0
  50. package/dist/fleet-lock.d.ts +67 -2
  51. package/dist/fleet-lock.js +236 -2
  52. package/dist/fleet-lock.js.map +1 -1
  53. package/dist/fleet-manager.d.ts +163 -6
  54. package/dist/fleet-manager.js +1136 -75
  55. package/dist/fleet-manager.js.map +1 -1
  56. package/dist/fleet-windows-runtime.d.ts +20 -1
  57. package/dist/fleet-windows-runtime.js +98 -18
  58. package/dist/fleet-windows-runtime.js.map +1 -1
  59. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +7 -0
  60. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +14 -4
  61. package/dist/home-update-lock.d.ts +35 -0
  62. package/dist/home-update-lock.js +81 -0
  63. package/dist/home-update-lock.js.map +1 -0
  64. package/dist/hub/compose/member.d.ts +5 -1
  65. package/dist/hub/compose/member.js +9 -5
  66. package/dist/hub/compose/member.js.map +1 -1
  67. package/dist/hub/member/room-ask.d.ts +5 -0
  68. package/dist/hub/member/room-ask.js +43 -16
  69. package/dist/hub/member/room-ask.js.map +1 -1
  70. package/dist/hub/member/room-mention-feedback.d.ts +2 -0
  71. package/dist/hub/member/room-mention-feedback.js +1 -1
  72. package/dist/hub/member/room-mention-feedback.js.map +1 -1
  73. package/dist/hub/member/room-post-answers.d.ts +2 -0
  74. package/dist/hub/member/room-post-answers.js +1 -1
  75. package/dist/hub/member/room-post-answers.js.map +1 -1
  76. package/dist/hub/member/room-post.d.ts +5 -0
  77. package/dist/hub/member/room-post.js +4 -1
  78. package/dist/hub/member/room-post.js.map +1 -1
  79. package/dist/hub/member/updates.d.ts +7 -1
  80. package/dist/hub/member/updates.js +7 -1
  81. package/dist/hub/member/updates.js.map +1 -1
  82. package/dist/hub/representative.d.ts +7 -0
  83. package/dist/hub/representative.js +38 -5
  84. package/dist/hub/representative.js.map +1 -1
  85. package/dist/install-lock.d.ts +15 -1
  86. package/dist/install-lock.js +16 -8
  87. package/dist/install-lock.js.map +1 -1
  88. package/dist/install-ownership.d.ts +165 -0
  89. package/dist/install-ownership.js +404 -0
  90. package/dist/install-ownership.js.map +1 -0
  91. package/dist/instance-config-impact.js +2 -0
  92. package/dist/instance-config-impact.js.map +1 -1
  93. package/dist/instructions.d.ts +4 -0
  94. package/dist/instructions.js +4 -0
  95. package/dist/instructions.js.map +1 -1
  96. package/dist/local-pane-endpoint.d.ts +4 -1
  97. package/dist/local-pane-endpoint.js +12 -2
  98. package/dist/local-pane-endpoint.js.map +1 -1
  99. package/dist/locale.js +160 -4
  100. package/dist/locale.js.map +1 -1
  101. package/dist/native-agent-admission.d.ts +7 -0
  102. package/dist/native-agent-admission.js +46 -3
  103. package/dist/native-agent-admission.js.map +1 -1
  104. package/dist/native-mcp.d.ts +16 -1
  105. package/dist/native-mcp.js +38 -5
  106. package/dist/native-mcp.js.map +1 -1
  107. package/dist/native-pane-lifecycle.d.ts +9 -0
  108. package/dist/native-pane-lifecycle.js +23 -0
  109. package/dist/native-pane-lifecycle.js.map +1 -1
  110. package/dist/native-pane-manager.d.ts +19 -6
  111. package/dist/native-pane-manager.js +79 -4
  112. package/dist/native-pane-manager.js.map +1 -1
  113. package/dist/needs-you.d.ts +8 -0
  114. package/dist/needs-you.js +1 -0
  115. package/dist/needs-you.js.map +1 -1
  116. package/dist/outbound-handlers.d.ts +12 -0
  117. package/dist/outbound-handlers.js +30 -2
  118. package/dist/outbound-handlers.js.map +1 -1
  119. package/dist/package-preimage.js +4 -0
  120. package/dist/package-preimage.js.map +1 -1
  121. package/dist/pane-port.d.ts +1 -0
  122. package/dist/plist-args.d.ts +9 -0
  123. package/dist/plist-args.js +22 -0
  124. package/dist/plist-args.js.map +1 -0
  125. package/dist/public-preview.d.ts +4 -6
  126. package/dist/public-preview.js +5 -2
  127. package/dist/public-preview.js.map +1 -1
  128. package/dist/public-web-gateway.js +8 -3
  129. package/dist/public-web-gateway.js.map +1 -1
  130. package/dist/public-web-link.d.ts +13 -1
  131. package/dist/public-web-link.js +28 -1
  132. package/dist/public-web-link.js.map +1 -1
  133. package/dist/recover.cjs +2452 -0
  134. package/dist/remote-card-prompt.d.ts +6 -2
  135. package/dist/remote-card-prompt.js +12 -3
  136. package/dist/remote-card-prompt.js.map +1 -1
  137. package/dist/reply-draft.d.ts +12 -0
  138. package/dist/reply-draft.js +81 -0
  139. package/dist/reply-draft.js.map +1 -0
  140. package/dist/request-contact-api.d.ts +15 -0
  141. package/dist/request-contact-api.js +120 -0
  142. package/dist/request-contact-api.js.map +1 -0
  143. package/dist/request-contact-card.d.ts +36 -0
  144. package/dist/request-contact-card.js +206 -0
  145. package/dist/request-contact-card.js.map +1 -0
  146. package/dist/request-contact-gate.d.ts +79 -0
  147. package/dist/request-contact-gate.js +262 -0
  148. package/dist/request-contact-gate.js.map +1 -0
  149. package/dist/request-contact-native.d.ts +52 -0
  150. package/dist/request-contact-native.js +83 -0
  151. package/dist/request-contact-native.js.map +1 -0
  152. package/dist/request-contact-types.d.ts +86 -0
  153. package/dist/request-contact-types.js +7 -0
  154. package/dist/request-contact-types.js.map +1 -0
  155. package/dist/request-context-call-protocol.d.ts +12 -0
  156. package/dist/request-context-call-protocol.js +14 -0
  157. package/dist/request-context-call-protocol.js.map +1 -0
  158. package/dist/request-context-call.d.ts +22 -0
  159. package/dist/request-context-call.js +35 -0
  160. package/dist/request-context-call.js.map +1 -0
  161. package/dist/request-context-drain.d.ts +39 -0
  162. package/dist/request-context-drain.js +159 -0
  163. package/dist/request-context-drain.js.map +1 -0
  164. package/dist/request-context-fence.d.ts +28 -0
  165. package/dist/request-context-fence.js +58 -0
  166. package/dist/request-context-fence.js.map +1 -0
  167. package/dist/request-context-migration.d.ts +64 -0
  168. package/dist/request-context-migration.js +158 -0
  169. package/dist/request-context-migration.js.map +1 -0
  170. package/dist/request-context-pane.d.ts +25 -0
  171. package/dist/request-context-pane.js +48 -0
  172. package/dist/request-context-pane.js.map +1 -0
  173. package/dist/request-context-policy.d.ts +74 -0
  174. package/dist/request-context-policy.js +116 -0
  175. package/dist/request-context-policy.js.map +1 -0
  176. package/dist/request-context-recovery.d.ts +14 -0
  177. package/dist/request-context-recovery.js +56 -0
  178. package/dist/request-context-recovery.js.map +1 -0
  179. package/dist/request-context-relay.d.ts +19 -0
  180. package/dist/request-context-relay.js +63 -0
  181. package/dist/request-context-relay.js.map +1 -0
  182. package/dist/request-context-returns.d.ts +67 -0
  183. package/dist/request-context-returns.js +211 -0
  184. package/dist/request-context-returns.js.map +1 -0
  185. package/dist/request-context-store.d.ts +2 -1
  186. package/dist/request-context-store.js +8 -1
  187. package/dist/request-context-store.js.map +1 -1
  188. package/dist/request-context-turns.d.ts +99 -0
  189. package/dist/request-context-turns.js +215 -0
  190. package/dist/request-context-turns.js.map +1 -0
  191. package/dist/request-context-view.d.ts +33 -0
  192. package/dist/request-context-view.js +36 -0
  193. package/dist/request-context-view.js.map +1 -0
  194. package/dist/request-hub-context.d.ts +130 -0
  195. package/dist/request-hub-context.js +89 -0
  196. package/dist/request-hub-context.js.map +1 -0
  197. package/dist/request-hub-output.d.ts +11 -0
  198. package/dist/request-hub-output.js +21 -0
  199. package/dist/request-hub-output.js.map +1 -0
  200. package/dist/runtime-cli-install.js +13 -11
  201. package/dist/runtime-cli-install.js.map +1 -1
  202. package/dist/runtime-client.d.ts +2 -0
  203. package/dist/runtime-client.js +17 -4
  204. package/dist/runtime-client.js.map +1 -1
  205. package/dist/runtime-coordinator.d.ts +4 -1
  206. package/dist/runtime-coordinator.js +10 -3
  207. package/dist/runtime-coordinator.js.map +1 -1
  208. package/dist/runtime-pane-assets.d.ts +1 -1
  209. package/dist/runtime-pane-assets.js +1 -1
  210. package/dist/runtime-pane-assets.js.map +1 -1
  211. package/dist/runtime-pane-host.d.ts +3 -0
  212. package/dist/runtime-pane-host.js +39 -21
  213. package/dist/runtime-pane-host.js.map +1 -1
  214. package/dist/runtime-pane-link.d.ts +6 -2
  215. package/dist/runtime-pane-link.js +17 -4
  216. package/dist/runtime-pane-link.js.map +1 -1
  217. package/dist/runtime-pane-mcp-relay.d.ts +11 -1
  218. package/dist/runtime-pane-mcp-relay.js +69 -3
  219. package/dist/runtime-pane-mcp-relay.js.map +1 -1
  220. package/dist/runtime-pane-mcp.d.ts +28 -1
  221. package/dist/runtime-pane-mcp.js +92 -15
  222. package/dist/runtime-pane-mcp.js.map +1 -1
  223. package/dist/runtime-pane-port.d.ts +6 -0
  224. package/dist/runtime-pane-port.js +23 -4
  225. package/dist/runtime-pane-port.js.map +1 -1
  226. package/dist/runtime-pane-protocol.d.ts +4 -0
  227. package/dist/runtime-pane-protocol.js +11 -4
  228. package/dist/runtime-pane-protocol.js.map +1 -1
  229. package/dist/runtime-pane-service.d.ts +1 -0
  230. package/dist/runtime-pane-service.js +25 -9
  231. package/dist/runtime-pane-service.js.map +1 -1
  232. package/dist/runtime-pane-stdio-protocol.d.ts +4 -0
  233. package/dist/runtime-pane-stdio-protocol.js +12 -5
  234. package/dist/runtime-pane-stdio-protocol.js.map +1 -1
  235. package/dist/runtime-pane-stdio.js +5 -5
  236. package/dist/runtime-pane-stdio.js.map +1 -1
  237. package/dist/runtime-protocol.d.ts +3 -0
  238. package/dist/runtime-protocol.js.map +1 -1
  239. package/dist/scheduler/scheduler.d.ts +6 -0
  240. package/dist/scheduler/scheduler.js +19 -1
  241. package/dist/scheduler/scheduler.js.map +1 -1
  242. package/dist/scheduler/task-board.d.ts +4 -0
  243. package/dist/scheduler/task-board.js +6 -0
  244. package/dist/scheduler/task-board.js.map +1 -1
  245. package/dist/scheduler/types.d.ts +1 -1
  246. package/dist/service-activation.js +3 -13
  247. package/dist/service-activation.js.map +1 -1
  248. package/dist/service-lock.d.ts +28 -0
  249. package/dist/service-lock.js +85 -0
  250. package/dist/service-lock.js.map +1 -0
  251. package/dist/settings-api.d.ts +6 -0
  252. package/dist/settings-api.js +35 -0
  253. package/dist/settings-api.js.map +1 -1
  254. package/dist/settings-change.js +1 -1
  255. package/dist/settings-change.js.map +1 -1
  256. package/dist/state-lease.d.ts +24 -0
  257. package/dist/state-lease.js +103 -0
  258. package/dist/state-lease.js.map +1 -0
  259. package/dist/tmux-binary.js +1 -1
  260. package/dist/tmux-binary.js.map +1 -1
  261. package/dist/tool-receipt-output.d.ts +2 -0
  262. package/dist/topic-commands.js +21 -1
  263. package/dist/topic-commands.js.map +1 -1
  264. package/dist/transcript-monitor.js +3 -0
  265. package/dist/transcript-monitor.js.map +1 -1
  266. package/dist/tunnel/named-link-test.d.ts +27 -0
  267. package/dist/tunnel/named-link-test.js +41 -0
  268. package/dist/tunnel/named-link-test.js.map +1 -1
  269. package/dist/types.d.ts +7 -0
  270. package/dist/ui/chat-store.js +5 -4
  271. package/dist/ui/fleet-office-card.js +15 -2
  272. package/dist/ui/fleet-office-skin.js +33 -9
  273. package/dist/ui/fleet-office-zones.js +8 -3
  274. package/dist/ui/fleet-office.js +136 -18
  275. package/dist/ui/fleet-task-files.js +1 -1
  276. package/dist/ui/panel-chat.js +15 -2
  277. package/dist/ui/panel-needs.js +22 -2
  278. package/dist/ui/panel-settings.js +22 -8
  279. package/dist/ui/settings-preview-address.js +156 -0
  280. package/dist/ui/settings-registry.js +2 -0
  281. package/dist/ui/settings-strings.js +6 -6
  282. package/dist/ui/shared/app.css +76 -2
  283. package/dist/ui/shared/chat-strings.js +6 -2
  284. package/dist/ui/shared/chat-thread.js +7 -1
  285. package/dist/ui/shared/preview-panel.js +1 -1
  286. package/dist/ui/shared/preview.js +11 -2
  287. package/dist/ui/shared/tokens.css +18 -3
  288. package/dist/ui/shared/ui-confirm.js +5 -4
  289. package/dist/ui/shared/workspace.css +7 -0
  290. package/dist/ui/usage-credits-card.js +84 -0
  291. package/dist/ui/workspace-ignored-strings.js +16 -0
  292. package/dist/ui/workspace-panel.js +15 -6
  293. package/dist/update-card.d.ts +193 -0
  294. package/dist/update-card.js +620 -0
  295. package/dist/update-card.js.map +1 -0
  296. package/dist/update-dispatch.d.ts +16 -1
  297. package/dist/update-dispatch.js +12 -4
  298. package/dist/update-dispatch.js.map +1 -1
  299. package/dist/update-forward.d.ts +73 -0
  300. package/dist/update-forward.js +283 -0
  301. package/dist/update-forward.js.map +1 -0
  302. package/dist/update-idle.d.ts +1 -0
  303. package/dist/update-idle.js +12 -3
  304. package/dist/update-idle.js.map +1 -1
  305. package/dist/update-install.d.ts +2 -1
  306. package/dist/update-install.js +18 -10
  307. package/dist/update-install.js.map +1 -1
  308. package/dist/update-journal.d.ts +351 -0
  309. package/dist/update-journal.js +717 -0
  310. package/dist/update-journal.js.map +1 -0
  311. package/dist/update-launch.js +1 -1
  312. package/dist/update-launch.js.map +1 -1
  313. package/dist/update-npm-env.d.ts +45 -12
  314. package/dist/update-npm-env.js +48 -0
  315. package/dist/update-npm-env.js.map +1 -1
  316. package/dist/update-package-restore.d.ts +75 -0
  317. package/dist/update-package-restore.js +318 -0
  318. package/dist/update-package-restore.js.map +1 -0
  319. package/dist/update-quiescence.d.ts +192 -0
  320. package/dist/update-quiescence.js +330 -0
  321. package/dist/update-quiescence.js.map +1 -0
  322. package/dist/update-readiness-host.d.ts +61 -0
  323. package/dist/update-readiness-host.js +297 -0
  324. package/dist/update-readiness-host.js.map +1 -0
  325. package/dist/update-readiness.d.ts +83 -0
  326. package/dist/update-readiness.js +459 -0
  327. package/dist/update-readiness.js.map +1 -0
  328. package/dist/update-recovery/kit.d.ts +35 -0
  329. package/dist/update-recovery/kit.js +99 -0
  330. package/dist/update-recovery/kit.js.map +1 -0
  331. package/dist/update-recovery/pre-start.d.ts +34 -0
  332. package/dist/update-recovery/pre-start.js +103 -0
  333. package/dist/update-recovery/pre-start.js.map +1 -0
  334. package/dist/update-recovery/recover-main.d.ts +1 -0
  335. package/dist/update-recovery/recover-main.js +4 -0
  336. package/dist/update-recovery/recover-main.js.map +1 -0
  337. package/dist/update-recovery/recover.d.ts +22 -0
  338. package/dist/update-recovery/recover.js +124 -0
  339. package/dist/update-recovery/recover.js.map +1 -0
  340. package/dist/update-recovery/route.d.ts +53 -0
  341. package/dist/update-recovery/route.js +262 -0
  342. package/dist/update-recovery/route.js.map +1 -0
  343. package/dist/update-recovery/runner.d.ts +58 -0
  344. package/dist/update-recovery/runner.js +196 -0
  345. package/dist/update-recovery/runner.js.map +1 -0
  346. package/dist/update-recovery/service-manager.d.ts +39 -0
  347. package/dist/update-recovery/service-manager.js +57 -0
  348. package/dist/update-recovery/service-manager.js.map +1 -0
  349. package/dist/update-restore.d.ts +44 -0
  350. package/dist/update-restore.js +355 -0
  351. package/dist/update-restore.js.map +1 -0
  352. package/dist/update-retained.d.ts +38 -0
  353. package/dist/update-retained.js +91 -0
  354. package/dist/update-retained.js.map +1 -0
  355. package/dist/update-rollback.d.ts +74 -0
  356. package/dist/update-rollback.js +221 -0
  357. package/dist/update-rollback.js.map +1 -0
  358. package/dist/update-settings.d.ts +36 -0
  359. package/dist/update-settings.js +122 -0
  360. package/dist/update-settings.js.map +1 -0
  361. package/dist/update-snapshot-manifest.d.ts +32 -0
  362. package/dist/update-snapshot-manifest.js +65 -0
  363. package/dist/update-snapshot-manifest.js.map +1 -0
  364. package/dist/update-snapshot-scope.d.ts +67 -0
  365. package/dist/update-snapshot-scope.js +172 -0
  366. package/dist/update-snapshot-scope.js.map +1 -0
  367. package/dist/update-snapshot.d.ts +34 -0
  368. package/dist/update-snapshot.js +246 -0
  369. package/dist/update-snapshot.js.map +1 -0
  370. package/dist/update-writers.d.ts +71 -0
  371. package/dist/update-writers.js +235 -0
  372. package/dist/update-writers.js.map +1 -0
  373. package/dist/web-api.d.ts +3 -0
  374. package/dist/web-api.js +43 -8
  375. package/dist/web-api.js.map +1 -1
  376. package/dist/web-chat-history.d.ts +7 -0
  377. package/dist/web-chat-history.js +15 -0
  378. package/dist/web-chat-history.js.map +1 -1
  379. package/dist/web-preview.d.ts +5 -0
  380. package/dist/web-preview.js +1 -1
  381. package/dist/web-preview.js.map +1 -1
  382. package/dist/web-update.d.ts +6 -0
  383. package/dist/windows-agents.d.ts +12 -0
  384. package/dist/windows-agents.js +5 -0
  385. package/dist/windows-agents.js.map +1 -1
  386. package/launcher/agend +4 -1
  387. package/launcher/agend-agent +4 -1
  388. package/launcher/agend-install.cjs +16 -8
  389. package/launcher/install-admission.d.cts +8 -0
  390. package/launcher/npm-allow-scripts.cjs +72 -0
  391. package/launcher/npm-global-prefix.cjs +81 -0
  392. package/launcher/postinstall.cjs +9 -8
  393. package/launcher/runtime-select.cjs +8 -2
  394. package/package.json +3 -2
  395. package/scripts/preinstall-guard.cjs +1 -1
package/dist/daemon.js CHANGED
@@ -1,3 +1,6 @@
1
+ import { ReplyDraft } from "./reply-draft.js";
2
+ import { requireRequestContextPolicy } from "./request-context-policy.js";
3
+ import { RequestContextReferenceMap } from "./request-context-fence.js";
1
4
  import { managedClaudeBinding } from "./claude-credential-launch.js";
2
5
  import { HUB_REPORT_TARGET } from "./hub-report-target.js";
3
6
  import { atomicWriteFileSync } from "./atomic-write.js";
@@ -60,6 +63,7 @@ import { ContextGuardian } from "./context-guardian.js";
60
63
  import { IpcServer } from "./channel/ipc-bridge.js";
61
64
  import { daemonBudgetMs } from "./channel/ipc-timeouts.js";
62
65
  import { MessageBus } from "./channel/message-bus.js";
66
+ import { captureRequestContextCall } from "./request-context-call.js";
63
67
  import { shellQuote, KiroCompatibilityError, UnsupportedCliError, ResumeBlockedError } from "./backend/types.js";
64
68
  import { getTmuxSession } from "./config.js";
65
69
  import { routeToolCall } from "./channel/tool-router.js";
@@ -2365,10 +2369,121 @@ export class Daemon extends EventEmitter {
2365
2369
  return classicGuardInventory(status.state === "ready" && this.processStatus !== "running"
2366
2370
  ? { state: "restart-required", backend, reason: "not-running" } : status);
2367
2371
  }
2372
+ /** Internal local-lifecycle port only. No config, IPC or MCP setter; production stays unbound until cutover. */
2373
+ requestContextLifecycle;
2374
+ requestContextWrite;
2375
+ requestContextPolicy;
2376
+ bindRequestContextPolicy(policy) { if (this.requestContextPolicy || !this.requestContextLifecycle)
2377
+ throw Error("request-context policy requires its owned turn binding"); this.requestContextPolicy = policy; }
2378
+ requestContextCalls = new RequestContextReferenceMap(call => call.admission.coverage === "covered" ? call.admission.lease.snapshot.context.ref.rootContextId : null, call => `local-call:${call.id}`);
2379
+ requestContextInterruptedLaunch;
2380
+ requestContextLaunch() { return JSON.stringify([this.bootId, this.spawnGeneration, this.nativePaneLifecycle?.snapshot?.()?.launchId ?? null]); }
2381
+ /** First local owned hop only. No lookup at a later Fleet receipt may retag this call. */
2382
+ beginRequestContextCall(socket) {
2383
+ if (!this.requestContextLifecycle)
2384
+ return;
2385
+ if (this.requestContextCalls.size >= 128)
2386
+ throw Error("Request context call admission backlog");
2387
+ const launch = this.requestContextLaunch();
2388
+ const snapshot = socket && this.socketSessionNames.get(socket) === this.name ? this.requestContextTurnSnapshot() : null;
2389
+ const reason = this.requestContextInterruptedLaunch === launch ? "interrupted-launch" : "unbound-input";
2390
+ const admission = snapshot && reason !== "interrupted-launch"
2391
+ ? { coverage: "covered", lease: captureRequestContextCall(snapshot, captured => this.requestContextTurnCurrent(captured)) }
2392
+ : { coverage: "not-covered", reason };
2393
+ const call = Object.freeze({ id: randomUUID(), admission: Object.freeze(admission),
2394
+ current: () => !this.deliveryWritesStopping && this.requestContextLaunch() === launch
2395
+ && (admission.coverage !== "covered" || admission.lease.current()) });
2396
+ this.requestContextCalls.set(call.id, call);
2397
+ return call;
2398
+ }
2399
+ /** Internal Fleet accessor, paired with the current daemon/IPC connection; returns original scope or nothing. */
2400
+ requestContextCall(callId) {
2401
+ const call = this.requestContextCalls.get(callId);
2402
+ return call?.current() ? call : null;
2403
+ }
2404
+ requestContextCallsRequired() { return this.requestContextLifecycle !== undefined; }
2405
+ get requestContextCallDrainRevision() { return this.requestContextCalls.revision; }
2406
+ requestContextCallDrainView(rootId) { return this.requestContextCalls.view(rootId); }
2407
+ requestContextTurnDrainView(rootId) { return this.requestContextLifecycle?.turns.drainView(rootId) ?? null; }
2408
+ get requestContextTurnDrainRevision() { return this.requestContextLifecycle?.turns.drainRevision ?? "unavailable"; }
2409
+ handleOwnedToolCall(message, socket) {
2410
+ let call;
2411
+ try {
2412
+ call = this.beginRequestContextCall(socket);
2413
+ this.handleToolCall(message, socket, undefined, call);
2414
+ }
2415
+ catch {
2416
+ if (call)
2417
+ this.requestContextCalls.delete(call.id);
2418
+ this.ipcServer?.send(socket, { requestId: message.requestId, result: null, error: "Request context call admission is unavailable" });
2419
+ }
2420
+ }
2421
+ setRequestContextLocalLifecycle(turns, identity) {
2422
+ if (this.tmux || this.ipcServer || this.requestContextLifecycle || this.nativePaneLifecycle && !this.nativePaneLifecycle.requestContextAvailable?.())
2423
+ throw Error("Request context must be bound before a supported daemon startup");
2424
+ this.requestContextCalls.installRegistration(turns.registrationGate ?? undefined);
2425
+ this.requestContextLifecycle = { turns, identity };
2426
+ }
2427
+ requestContextOwner() {
2428
+ const lifecycle = this.requestContextLifecycle;
2429
+ return lifecycle ? { ...lifecycle.identity(), instance: this.name, daemonBootId: this.bootId,
2430
+ spawnGeneration: this.spawnGeneration, launchFenceEpoch: this.launchFenceEpoch, deliveryEpoch: this.deliveryEpoch } : null;
2431
+ }
2432
+ requestContextTurnSnapshot() {
2433
+ const owner = this.requestContextOwner();
2434
+ return owner ? this.requestContextLifecycle.turns.current(owner) : null;
2435
+ }
2436
+ requestContextTurnCurrent(snapshot) {
2437
+ const owner = this.requestContextOwner();
2438
+ return !!owner && this.requestContextLifecycle.turns.isCurrent(snapshot, owner);
2439
+ }
2440
+ bindRequestContextWrite(inputId, text, queued, recovery) {
2441
+ const owner = this.requestContextOwner();
2442
+ if (!owner)
2443
+ return;
2444
+ // Ordinary queues are never evidence of consumption. Only a proven steer can join the EXISTING turn.
2445
+ if (queued && recovery)
2446
+ throw Error("request-context queued input consumption is not covered yet");
2447
+ if (recovery && !recovery.current())
2448
+ throw Error("request-context recovery job is no longer current");
2449
+ const previous = this.requestContextTurnSnapshot();
2450
+ const snapshot = queued ? this.requestContextLifecycle.turns.beforeQueuedSteer(inputId, deliveryContentDigest(text), owner)
2451
+ : recovery ? this.requestContextLifecycle.turns.beforeRecoveryWrite(recovery.inputId, deliveryContentDigest(text), owner, recovery.parent)
2452
+ : this.requestContextLifecycle.turns.beforeWrite(inputId, deliveryContentDigest(text), owner);
2453
+ try {
2454
+ this.nativePaneLifecycle?.stageRequestContext?.(snapshot, deliveryContentDigest(text), () => this.requestContextTurnCurrent(snapshot), this.requestContextInterruptedLaunch === this.requestContextLaunch());
2455
+ }
2456
+ catch (error) {
2457
+ if (snapshot !== previous)
2458
+ this.requestContextLifecycle.turns.ended(snapshot, owner);
2459
+ throw error;
2460
+ }
2461
+ if (this.requestContextWrite?.snapshot.token !== snapshot.token) {
2462
+ const id = snapshot.inputId;
2463
+ const humanId = id.startsWith("human:") ? id.slice(6) : null;
2464
+ const deliveryId = /^delivery:([^:]+):[0-9]+$/.exec(id)?.[1];
2465
+ const endAnchor = !!humanId && /^[A-Za-z0-9_-]+$/.test(humanId) && text.split("\n").some(line => line.startsWith(`[hid:${humanId}]`) || line.startsWith(`[agend-human-id:${humanId}]`))
2466
+ || !!deliveryId && text.startsWith(`[agend-delivery-id:${deliveryId}]\n`)
2467
+ || /^[A-Za-z0-9:_-]+$/.test(id) && text.startsWith(`[agend-request-input:${id}]\n`);
2468
+ this.requestContextWrite = { snapshot, text, at: Date.now(), ledger: new TranscriptTurnLedger(), endAnchor };
2469
+ }
2470
+ }
2471
+ settleRequestContextFromTranscript() {
2472
+ const write = this.requestContextWrite, owner = this.requestContextOwner();
2473
+ if (!write || !write.endAnchor || !owner || !this.requestContextLifecycle.turns.isCurrent(write.snapshot, owner))
2474
+ return;
2475
+ const verdict = write.ledger.verdict(write.text, write.at);
2476
+ if (verdict === "ended" || verdict === "aborted" || verdict === "error") {
2477
+ if (verdict !== "ended")
2478
+ this.requestContextInterruptedLaunch = this.requestContextLaunch();
2479
+ this.requestContextLifecycle.turns.ended(write.snapshot, owner);
2480
+ this.requestContextWrite = undefined;
2481
+ }
2482
+ }
2368
2483
  /** Internal lifecycle injection, before start. Native paths and provider files stay on their runner. */
2369
2484
  setNativePaneLifecycle(native) {
2370
- if (this.tmux || this.ipcServer || this.nativePaneLifecycle)
2371
- throw Error("Native pane adapter must be bound before daemon startup");
2485
+ if (this.tmux || this.ipcServer || this.nativePaneLifecycle || this.requestContextLifecycle && !native.requestContextAvailable?.())
2486
+ throw Error("Native pane adapter must be bound before daemon startup with a supported request-context producer");
2372
2487
  this.nativePaneLifecycle = native;
2373
2488
  this.backend = native.backend;
2374
2489
  this.paneTransport = native.host;
@@ -2420,6 +2535,7 @@ export class Daemon extends EventEmitter {
2420
2535
  // deliberately NOT hooked: stop/spawn abandon the in-memory turn while
2421
2536
  // the on-disk interruption must survive for the resume gate.
2422
2537
  this.turnReplyGuard.onComplete = () => {
2538
+ this.replyDraft.reset();
2423
2539
  clearInFlightTurnMarker(this.instanceDir);
2424
2540
  this.publishWorkingState("turn_closed");
2425
2541
  };
@@ -2508,6 +2624,9 @@ export class Daemon extends EventEmitter {
2508
2624
  return;
2509
2625
  this.deliveryWritesStopping = true;
2510
2626
  this.deliveryEpoch++;
2627
+ this.replyDraft.reset();
2628
+ this.requestContextLifecycle?.turns.fence();
2629
+ this.requestContextCalls.clear();
2511
2630
  }
2512
2631
  /** Bounded drain: timeout remains safe because Enter has a write-ahead fence. */
2513
2632
  waitForDeliveryWritesToDrain(timeoutMs) {
@@ -3323,7 +3442,7 @@ export class Daemon extends EventEmitter {
3323
3442
  this.ipcServer.on("message", (msg, socket) => {
3324
3443
  if (msg.type === "tool_call") {
3325
3444
  // MCP server forwarding a Claude tool call (reply, react, edit, download)
3326
- this.handleToolCall(msg, socket);
3445
+ this.handleOwnedToolCall(msg, socket);
3327
3446
  }
3328
3447
  else if (msg.type === "mcp_ready") {
3329
3448
  this.handleMcpReady(msg, socket);
@@ -5221,7 +5340,7 @@ export class Daemon extends EventEmitter {
5221
5340
  const screen = await tmux.capturePane().catch(() => null);
5222
5341
  if (screen === null)
5223
5342
  return;
5224
- await tmux.sendSpecialKey(cancelKey, undefined, { kind: "dialog", screen });
5343
+ await tmux.sendSpecialKey(cancelKey, undefined, { kind: "dialog", screen, cancelTurn: true });
5225
5344
  return;
5226
5345
  }
5227
5346
  await tmux.sendSpecialKey(cancelKey);
@@ -5237,6 +5356,7 @@ export class Daemon extends EventEmitter {
5237
5356
  // current human turn; leave already-forwarded tool requests to settle.
5238
5357
  this.recoveryCancelled = true;
5239
5358
  this.turnReplyGuard.cancelByUser();
5359
+ this.replyDraft.reset();
5240
5360
  // #1241: a cancelled turn never confirms — its next edge completes it as
5241
5361
  // intentional. Drop a pending confirmation so it cannot promote afterwards.
5242
5362
  this.clearReplyGuardConfirm();
@@ -6248,6 +6368,7 @@ export class Daemon extends EventEmitter {
6248
6368
  }
6249
6369
  }
6250
6370
  workingTurnDelivery = null;
6371
+ workingTurnRequestContext = null;
6251
6372
  workingBackgroundObservation = null;
6252
6373
  /** Pure metadata read: never discovers sessions, captures a pane or reads backend files. */
6253
6374
  getWorkingStateObservation() {
@@ -6986,6 +7107,9 @@ export class Daemon extends EventEmitter {
6986
7107
  // Its late success must not re-arm the turn that the user just cancelled.
6987
7108
  if (!this.isDeliveryEpochCurrent(deliveryEpoch))
6988
7109
  return;
7110
+ // New input, including a peer/system input, cannot inherit an earlier draft.
7111
+ // If its transcript was already polled before paste confirmation, prefer a generic recovery.
7112
+ this.replyDraft.reset();
6989
7113
  // Channel turns started by a person. Cross-instance, schedules (silent or
6990
7114
  // not), and AgEnD system notices must not expect a reply to a person (#2544):
6991
7115
  // a proxy or recovery notice would land in the last USER topic, or flag a
@@ -7019,6 +7143,8 @@ export class Daemon extends EventEmitter {
7019
7143
  }, this.pendingWork.lastInboundTimestamp());
7020
7144
  const armed = this.turnReplyGuard.snapshot();
7021
7145
  this.workingTurnDelivery = { generation: armed.generation, deliveryId: meta.delivery_id || null };
7146
+ const requestContext = this.requestContextTurnSnapshot();
7147
+ this.workingTurnRequestContext = requestContext ? { generation: armed.generation, snapshot: requestContext } : null;
7022
7148
  this.publishWorkingState("turn_started");
7023
7149
  // #1209: persist the in-flight turn with a seam checkpoint. A marker
7024
7150
  // that survives a restart is an interrupted turn by construction —
@@ -7537,6 +7663,7 @@ export class Daemon extends EventEmitter {
7537
7663
  }
7538
7664
  buildTranscriptMonitor(source) {
7539
7665
  this.followLog.reset();
7666
+ this.replyDraft.reset();
7540
7667
  const modelLaunch = this.backend?.modelObservationLaunch?.();
7541
7668
  const monitor = new TranscriptMonitor(this.instanceDir, this.logger, source, () => modelLaunch);
7542
7669
  let savedModel;
@@ -7594,6 +7721,20 @@ export class Daemon extends EventEmitter {
7594
7721
  if (changed)
7595
7722
  this.emit("model_observation");
7596
7723
  });
7724
+ monitor.on("reply_draft_record", (entry) => {
7725
+ if (this.transcriptMonitor === monitor && owner === launchIdentity(this.interactionOwner())) {
7726
+ const turn = this.turnReplyGuard?.snapshot();
7727
+ if (turn)
7728
+ this.replyDraft.observe(entry, turn.generation);
7729
+ else
7730
+ this.replyDraft.reset();
7731
+ }
7732
+ });
7733
+ for (const event of ["reset", "workspace_reset", "context_reset"])
7734
+ monitor.on(event, () => {
7735
+ if (this.transcriptMonitor === monitor)
7736
+ this.replyDraft.reset();
7737
+ });
7597
7738
  this.transcriptTurns.reset();
7598
7739
  this.transcriptActivityAt = 0;
7599
7740
  // Monotonic: a wall-clock correction must neither end nor extend the open-turn hold (#1641 R1).
@@ -7601,6 +7742,10 @@ export class Daemon extends EventEmitter {
7601
7742
  monitor.on("turns", (turns) => {
7602
7743
  this.transcriptTurns.observe(turns, performance.now());
7603
7744
  touch();
7745
+ if (this.transcriptMonitor === monitor && owner === launchIdentity(this.interactionOwner())) {
7746
+ this.requestContextWrite?.ledger.observe(turns, performance.now());
7747
+ this.settleRequestContextFromTranscript();
7748
+ }
7604
7749
  });
7605
7750
  // #3160: the files this turn reads, edits and searches, for the Files & changes panel's Follow (a few string checks;
7606
7751
  // nothing is read from disk until someone asks). Claude's turn boundary is its next prompt.
@@ -7727,8 +7872,13 @@ export class Daemon extends EventEmitter {
7727
7872
  message: formatReplyDropDetection(turn, reason),
7728
7873
  });
7729
7874
  }
7875
+ _replyDraft;
7876
+ /** Also supports existing prototype-based lifecycle harnesses without constructor state. */
7877
+ get replyDraft() { return this._replyDraft ??= new ReplyDraft(); }
7730
7878
  queueReplyRecoveryPrompt(turn) {
7731
7879
  const deliveryEpoch = this.deliveryEpoch;
7880
+ const parent = this.workingTurnRequestContext?.generation === turn.generation ? this.workingTurnRequestContext.snapshot : null;
7881
+ const recoveryInputId = `reply-recovery:${this.bootId}:${turn.generation}:${deliveryEpoch}`;
7732
7882
  this.pasteQueueDepth++;
7733
7883
  this.pasteLock = this.pasteLock.then(async () => {
7734
7884
  try {
@@ -7744,8 +7894,16 @@ export class Daemon extends EventEmitter {
7744
7894
  });
7745
7895
  return;
7746
7896
  }
7747
- const delivered = await this.deliverMessage(REPLY_RECOVERY_PROMPT, undefined, {
7897
+ let prompt = REPLY_RECOVERY_PROMPT;
7898
+ try {
7899
+ prompt = this.replyDraft.recoveryPrompt(current, REPLY_RECOVERY_PROMPT);
7900
+ }
7901
+ catch { /* Draft evidence is best-effort; keep the existing generic recovery. */ }
7902
+ const recoveryText = parent && this.requestContextLifecycle ? `[agend-request-input:${recoveryInputId}]\n${prompt}` : prompt;
7903
+ const delivered = await this.deliverMessage(recoveryText, undefined, {
7748
7904
  deliveryEpoch,
7905
+ ...(parent ? { requestContextRecovery: { inputId: recoveryInputId, parent,
7906
+ current: () => !!this.currentReplyRecovery(turn.generation, deliveryEpoch) } } : {}),
7749
7907
  });
7750
7908
  if (!this.currentReplyRecovery(turn.generation, deliveryEpoch))
7751
7909
  return;
@@ -9348,7 +9506,7 @@ export class Daemon extends EventEmitter {
9348
9506
  // M-3660: a Hub question is never handed into a running turn (Claude would merge it into that turn's work), and while
9349
9507
  // a Hub answer turn runs, nothing else is handed into it: each waits for the idle pane and becomes a turn of its own.
9350
9508
  const exclusiveTurn = opts?.hubQuestion !== undefined || this.hubAnswerTurnMayRun();
9351
- const handOffEligible = !exclusiveTurn && !!(supportsQueuedInput || opts?.steer || composerQueue);
9509
+ const handOffEligible = !exclusiveTurn && (!this.requestContextLifecycle || opts?.steer === true) && !!(supportsQueuedInput || opts?.steer || composerQueue);
9352
9510
  const handOffAdmissible = async () => (await this.probeBlockingDialog()).state === "clear"
9353
9511
  && await this.hasPositiveDeliveryInput(true)
9354
9512
  && ((!opts?.steer && !composerQueue) || (this.launchTakesSteer() && await this.steerComposerAdmits(false, opts?.steer === true)));
@@ -9529,10 +9687,27 @@ export class Daemon extends EventEmitter {
9529
9687
  return stale();
9530
9688
  if (residue !== "clear")
9531
9689
  return this.failDelivery(verdict, status, "input-residue", residue);
9690
+ let newlyBound = null;
9532
9691
  const written = await this.writeMessageToPane(formatted, windowId, handingOffToNativeQueue, status, opts?.submissionId, verdict, opts?.durableAttempt, opts?.steer === true, writeCurrent, opts?.humanVerificationId,
9533
9692
  // M-3660: written into an idle pane, so whatever Hub answer turn ran is over; a Hub question begins its own.
9534
- () => { if (!handingOffToNativeQueue)
9535
- this.hubAnswerTurnBegins(opts?.hubQuestion, opts?.hubContactLimit !== false); opts?.beforePaneWrite?.(); }, opts?.lookBeforePaneWrite, opts?.humanMeta);
9693
+ (wireText) => {
9694
+ const receiptId = opts?.humanMeta?.verification_id ?? opts?.humanVerificationId;
9695
+ const inputId = opts?.requestContextInputId ?? (receiptId ? `human:${receiptId}` : opts?.durableAttempt
9696
+ ? `delivery:${opts.durableAttempt.deliveryId}:${opts.durableAttempt.attemptNo}` : null);
9697
+ const prior = this.requestContextTurnSnapshot();
9698
+ this.bindRequestContextWrite(inputId, wireText, handingOffToNativeQueue, opts?.requestContextRecovery);
9699
+ const after = this.requestContextTurnSnapshot();
9700
+ if (after && after !== prior)
9701
+ newlyBound = after;
9702
+ if (!handingOffToNativeQueue)
9703
+ this.hubAnswerTurnBegins(opts?.hubQuestion, opts?.hubContactLimit !== false);
9704
+ opts?.beforePaneWrite?.();
9705
+ }, opts?.lookBeforePaneWrite, opts?.humanMeta);
9706
+ if (written === false && newlyBound && this.nativePaneLifecycle?.lastInputWasNotSent?.()) {
9707
+ const owner = this.requestContextOwner();
9708
+ if (owner && this.requestContextLifecycle.turns.ended(newlyBound, owner))
9709
+ this.requestContextWrite = undefined;
9710
+ }
9536
9711
  // #1690: still under the lock — whatever waits on it next must already see what this write started.
9537
9712
  if (verdict.paneWriteStarted)
9538
9713
  opts?.onPaneWritten?.();
@@ -11916,7 +12091,7 @@ export class Daemon extends EventEmitter {
11916
12091
  return this.failDelivery(verdict, status, "paste", "pane-in-tmux-mode");
11917
12092
  }
11918
12093
  const pasteGeneration = this.spawnGeneration;
11919
- beforePaste?.();
12094
+ beforePaste?.(formatted);
11920
12095
  const pasted = await this.sendDeliveryPaste(formatted, nativeOwner);
11921
12096
  if (!pasted && this.nativePaneLifecycle) {
11922
12097
  // The native write attempt is retained as uncertain, including exhausted positive refusals. Never route an
@@ -13209,11 +13384,16 @@ export class Daemon extends EventEmitter {
13209
13384
  const current = () => lease.current() && lease.allowed(input.tool, input.args) && !this.deliveryWritesStopping && fence === this.launchFenceEpoch;
13210
13385
  return new Promise(resolve => {
13211
13386
  let settled = false;
13387
+ let call;
13212
13388
  const finish = (value) => { if (settled)
13213
- return; settled = true; clearTimeout(timer); resolve(value); };
13389
+ return; settled = true; if (call)
13390
+ this.requestContextCalls.delete(call.id); clearTimeout(timer); resolve(value); };
13214
13391
  const timer = setTimeout(() => finish({ result: null, error: "Pane tool result is unconfirmed; inspect its operation before retrying" }), daemonBudgetMs(input.tool) + 1000);
13215
13392
  timer.unref?.();
13216
13393
  try {
13394
+ call = lease.requestContext ? Object.freeze({ id: randomUUID(), admission: lease.requestContext, current }) : undefined;
13395
+ if (call)
13396
+ this.requestContextCalls.set(call.id, call);
13217
13397
  this.handleToolCall({ ...input, requestId: ++this.fleetRequestSeq }, undefined, {
13218
13398
  current,
13219
13399
  dispatch: (tool, args, respond) => {
@@ -13233,7 +13413,7 @@ export class Daemon extends EventEmitter {
13233
13413
  ...(typeof value.errorCode === "string" || typeof value.errorCode === "number" ? { errorCode: value.errorCode } : {}) });
13234
13414
  return false;
13235
13415
  },
13236
- });
13416
+ }, call);
13237
13417
  }
13238
13418
  catch {
13239
13419
  finish({ result: null, error: "Pane tool operation failed" });
@@ -13246,7 +13426,7 @@ export class Daemon extends EventEmitter {
13246
13426
  return;
13247
13427
  this.emit("mcp_tool_response_written", { operationId, daemonBootId: this.bootId });
13248
13428
  }
13249
- handleToolCall(msg, socket, peer) {
13429
+ handleToolCall(msg, socket, peer, originatingCall) {
13250
13430
  const tool = msg.tool;
13251
13431
  const args = (msg.args ?? {});
13252
13432
  const requestId = msg.requestId;
@@ -13268,6 +13448,12 @@ export class Daemon extends EventEmitter {
13268
13448
  : null;
13269
13449
  // For now, log and respond. Full adapter routing will be wired in fleet manager.
13270
13450
  const respond = (result, error, errorCode) => {
13451
+ if (originatingCall && !originatingCall.current()) {
13452
+ result = null;
13453
+ error = `Tool outcome is unconfirmed. ${operationId ? `Inspect operation ${operationId}` : "Inspect the tool operation status"}; do not repeat it.`;
13454
+ }
13455
+ if (originatingCall)
13456
+ this.requestContextCalls.delete(originatingCall.id);
13271
13457
  // A message that verifiably went out stands down the dead-MCP proxy reply
13272
13458
  // for this turn: the agent proved it can still speak for itself.
13273
13459
  if (!error && result != null && TURN_OUTBOUND_TOOLS.has(tool)) {
@@ -13320,6 +13506,35 @@ export class Daemon extends EventEmitter {
13320
13506
  this.emit("mcp_tool_response_written", { operationId, daemonBootId: this.bootId });
13321
13507
  }
13322
13508
  };
13509
+ const sendFleet = (message) => {
13510
+ if (originatingCall && !originatingCall.current()) {
13511
+ const id = String(message.fleetRequestId ?? ""), callback = this.pendingIpcRequests.get(id);
13512
+ this.pendingIpcRequests.delete(id);
13513
+ if (callback)
13514
+ callback({ error: "Originating request context is no longer current" });
13515
+ else
13516
+ respond(null, "Originating request context is no longer current");
13517
+ return;
13518
+ }
13519
+ this.broadcastFleetMessage(originatingCall ? { ...message, requestContextCallId: originatingCall.id, sourceDaemonBootId: this.bootId } : message);
13520
+ };
13521
+ try {
13522
+ if (this.requestContextPolicy)
13523
+ requireRequestContextPolicy(this, this.name, tool, args, originatingCall?.admission);
13524
+ }
13525
+ catch (error) {
13526
+ respond(null, error.message);
13527
+ return;
13528
+ }
13529
+ if (this.requestContextLifecycle && !peer && !originatingCall || originatingCall && !originatingCall.current()) {
13530
+ respond(null, "Originating request context is unavailable");
13531
+ return;
13532
+ }
13533
+ // These local shell mutations have no scoped admission boundary yet (F); never imply coverage.
13534
+ if (originatingCall && (tool === "checkout_repo" || tool === "release_repo")) {
13535
+ respond(null, "This operation is not covered by request-context admission");
13536
+ return;
13537
+ }
13323
13538
  // Native Fleet/task operations carry their lease to the existing dispatcher mutation admission points.
13324
13539
  if (peer?.dispatch?.(tool, args, respond))
13325
13540
  return;
@@ -13351,7 +13566,7 @@ export class Daemon extends EventEmitter {
13351
13566
  clearTimeout(timeout);
13352
13567
  respond(respMsg.result, respMsg.error);
13353
13568
  });
13354
- this.broadcastFleetMessage({
13569
+ sendFleet({
13355
13570
  type,
13356
13571
  payload: args,
13357
13572
  meta: { instance_name: this.name },
@@ -13377,7 +13592,7 @@ export class Daemon extends EventEmitter {
13377
13592
  clearTimeout(timeout);
13378
13593
  resolve({ result: respMsg.result, error: respMsg.error });
13379
13594
  });
13380
- this.broadcastFleetMessage({ type: WEB_THEME_IPC[tool], payload, meta: { instance_name: this.name }, fleetRequestId: fleetReqId });
13595
+ sendFleet({ type: WEB_THEME_IPC[tool], payload, meta: { instance_name: this.name }, fleetRequestId: fleetReqId });
13381
13596
  });
13382
13597
  void (async () => {
13383
13598
  if (tool === "preview_web_appearance") {
@@ -13456,7 +13671,7 @@ export class Daemon extends EventEmitter {
13456
13671
  clearTimeout(timeout);
13457
13672
  resolve({ result: respMsg.result, error: respMsg.error });
13458
13673
  });
13459
- this.broadcastFleetMessage({
13674
+ sendFleet({
13460
13675
  type: "fleet_task",
13461
13676
  payload,
13462
13677
  meta: { instance_name: this.name },
@@ -13489,7 +13704,7 @@ export class Daemon extends EventEmitter {
13489
13704
  clearTimeout(timeout);
13490
13705
  respond(respMsg.result, respMsg.error);
13491
13706
  });
13492
- this.broadcastFleetMessage({
13707
+ sendFleet({
13493
13708
  type: typeMap[tool],
13494
13709
  payload: args,
13495
13710
  meta: { instance_name: this.name, working_directory: this.config.working_directory },
@@ -13516,7 +13731,7 @@ export class Daemon extends EventEmitter {
13516
13731
  clearTimeout(timeout);
13517
13732
  respond(respMsg.result, respMsg.error);
13518
13733
  });
13519
- this.broadcastFleetMessage({
13734
+ sendFleet({
13520
13735
  type: typeMap[tool],
13521
13736
  payload: args,
13522
13737
  meta: {
@@ -13547,7 +13762,7 @@ export class Daemon extends EventEmitter {
13547
13762
  clearTimeout(timeout);
13548
13763
  respond(respMsg.result, respMsg.error);
13549
13764
  });
13550
- this.broadcastFleetMessage({
13765
+ sendFleet({
13551
13766
  type: "fleet_outbound",
13552
13767
  tool,
13553
13768
  args,
@@ -13606,7 +13821,7 @@ export class Daemon extends EventEmitter {
13606
13821
  // Register the waiter before broadcasting. A fast/mock adapter can settle
13607
13822
  // immediately; broadcasting first left a response-before-registration
13608
13823
  // window that degraded into a timeout despite a completed POST.
13609
- this.broadcastFleetMessage({
13824
+ sendFleet({
13610
13825
  type: "fleet_outbound",
13611
13826
  tool,
13612
13827
  args,