botmux 3.11.0-canary.1 → 3.12.0

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 (385) hide show
  1. package/dist/.runtime-build-id +1 -1
  2. package/dist/adapters/backend/riff-backend.d.ts +29 -5
  3. package/dist/adapters/backend/riff-backend.d.ts.map +1 -1
  4. package/dist/adapters/backend/riff-backend.js +313 -33
  5. package/dist/adapters/backend/riff-backend.js.map +1 -1
  6. package/dist/adapters/backend/types.d.ts +37 -3
  7. package/dist/adapters/backend/types.d.ts.map +1 -1
  8. package/dist/adapters/backend/types.js.map +1 -1
  9. package/dist/adapters/cli/coco.js +3 -3
  10. package/dist/adapters/cli/coco.js.map +1 -1
  11. package/dist/adapters/cli/codex.js +2 -2
  12. package/dist/adapters/cli/codex.js.map +1 -1
  13. package/dist/adapters/cli/read-isolation.d.ts +35 -2
  14. package/dist/adapters/cli/read-isolation.d.ts.map +1 -1
  15. package/dist/adapters/cli/read-isolation.js +88 -7
  16. package/dist/adapters/cli/read-isolation.js.map +1 -1
  17. package/dist/cli/dashboard-command.d.ts +23 -0
  18. package/dist/cli/dashboard-command.d.ts.map +1 -0
  19. package/dist/cli/dashboard-command.js +61 -0
  20. package/dist/cli/dashboard-command.js.map +1 -0
  21. package/dist/cli/dashboard-endpoint.d.ts +3 -3
  22. package/dist/cli/dashboard-endpoint.d.ts.map +1 -1
  23. package/dist/cli/dashboard-endpoint.js +1 -1
  24. package/dist/cli/fleet-shutdown.d.ts +47 -0
  25. package/dist/cli/fleet-shutdown.d.ts.map +1 -0
  26. package/dist/cli/fleet-shutdown.js +387 -0
  27. package/dist/cli/fleet-shutdown.js.map +1 -0
  28. package/dist/cli/pm2-descriptor-guard.d.ts +19 -0
  29. package/dist/cli/pm2-descriptor-guard.d.ts.map +1 -0
  30. package/dist/cli/pm2-descriptor-guard.js +122 -0
  31. package/dist/cli/pm2-descriptor-guard.js.map +1 -0
  32. package/dist/cli/pm2-exact-start.d.ts +16 -0
  33. package/dist/cli/pm2-exact-start.d.ts.map +1 -0
  34. package/dist/cli/pm2-exact-start.js +63 -0
  35. package/dist/cli/pm2-exact-start.js.map +1 -0
  36. package/dist/cli/pm2-god-admission.d.ts +8 -0
  37. package/dist/cli/pm2-god-admission.d.ts.map +1 -0
  38. package/dist/cli/pm2-god-admission.js +25 -0
  39. package/dist/cli/pm2-god-admission.js.map +1 -0
  40. package/dist/cli/pm2-jlist.d.ts +13 -0
  41. package/dist/cli/pm2-jlist.d.ts.map +1 -0
  42. package/dist/cli/pm2-jlist.js +108 -0
  43. package/dist/cli/pm2-jlist.js.map +1 -0
  44. package/dist/cli/pm2-preflight.d.ts +10 -0
  45. package/dist/cli/pm2-preflight.d.ts.map +1 -0
  46. package/dist/cli/pm2-preflight.js +23 -0
  47. package/dist/cli/pm2-preflight.js.map +1 -0
  48. package/dist/cli/pm2-shutdown-capability.d.ts +27 -0
  49. package/dist/cli/pm2-shutdown-capability.d.ts.map +1 -0
  50. package/dist/cli/pm2-shutdown-capability.js +161 -0
  51. package/dist/cli/pm2-shutdown-capability.js.map +1 -0
  52. package/dist/cli/pm2-start-transaction.d.ts +55 -0
  53. package/dist/cli/pm2-start-transaction.d.ts.map +1 -0
  54. package/dist/cli/pm2-start-transaction.js +220 -0
  55. package/dist/cli/pm2-start-transaction.js.map +1 -0
  56. package/dist/cli/send-dispatch.d.ts +12 -0
  57. package/dist/cli/send-dispatch.d.ts.map +1 -1
  58. package/dist/cli/send-dispatch.js +31 -4
  59. package/dist/cli/send-dispatch.js.map +1 -1
  60. package/dist/cli/supervisor-shutdown-client.d.ts +31 -0
  61. package/dist/cli/supervisor-shutdown-client.d.ts.map +1 -0
  62. package/dist/cli/supervisor-shutdown-client.js +146 -0
  63. package/dist/cli/supervisor-shutdown-client.js.map +1 -0
  64. package/dist/cli/vc-agent.d.ts.map +1 -1
  65. package/dist/cli/vc-agent.js +1 -1
  66. package/dist/cli/vc-agent.js.map +1 -1
  67. package/dist/cli.d.ts.map +1 -1
  68. package/dist/cli.js +1403 -440
  69. package/dist/cli.js.map +1 -1
  70. package/dist/codex-rpc-engine.d.ts +33 -3
  71. package/dist/codex-rpc-engine.d.ts.map +1 -1
  72. package/dist/codex-rpc-engine.js +182 -20
  73. package/dist/codex-rpc-engine.js.map +1 -1
  74. package/dist/codex-rpc-lifecycle.d.ts +42 -7
  75. package/dist/codex-rpc-lifecycle.d.ts.map +1 -1
  76. package/dist/codex-rpc-lifecycle.js +73 -7
  77. package/dist/codex-rpc-lifecycle.js.map +1 -1
  78. package/dist/config.d.ts +1 -1
  79. package/dist/config.js +1 -1
  80. package/dist/core/cli-session-id-publisher.d.ts +20 -0
  81. package/dist/core/cli-session-id-publisher.d.ts.map +1 -0
  82. package/dist/core/cli-session-id-publisher.js +21 -0
  83. package/dist/core/cli-session-id-publisher.js.map +1 -0
  84. package/dist/core/command-handler.d.ts +3 -2
  85. package/dist/core/command-handler.d.ts.map +1 -1
  86. package/dist/core/command-handler.js +47 -3
  87. package/dist/core/command-handler.js.map +1 -1
  88. package/dist/core/dashboard-ipc-server.d.ts +5 -0
  89. package/dist/core/dashboard-ipc-server.d.ts.map +1 -1
  90. package/dist/core/dashboard-ipc-server.js +322 -29
  91. package/dist/core/dashboard-ipc-server.js.map +1 -1
  92. package/dist/core/dispatch.d.ts +9 -10
  93. package/dist/core/dispatch.d.ts.map +1 -1
  94. package/dist/core/dispatch.js +17 -10
  95. package/dist/core/dispatch.js.map +1 -1
  96. package/dist/core/explicit-session-backing-cleanup.d.ts +49 -0
  97. package/dist/core/explicit-session-backing-cleanup.d.ts.map +1 -0
  98. package/dist/core/explicit-session-backing-cleanup.js +76 -0
  99. package/dist/core/explicit-session-backing-cleanup.js.map +1 -0
  100. package/dist/core/managed-origin-attestation.d.ts +51 -0
  101. package/dist/core/managed-origin-attestation.d.ts.map +1 -0
  102. package/dist/core/managed-origin-attestation.js +208 -0
  103. package/dist/core/managed-origin-attestation.js.map +1 -0
  104. package/dist/core/managed-origin-capability.d.ts +62 -3
  105. package/dist/core/managed-origin-capability.d.ts.map +1 -1
  106. package/dist/core/managed-origin-capability.js +419 -9
  107. package/dist/core/managed-origin-capability.js.map +1 -1
  108. package/dist/core/persistent-backend.d.ts +6 -1
  109. package/dist/core/persistent-backend.d.ts.map +1 -1
  110. package/dist/core/persistent-backend.js +12 -6
  111. package/dist/core/persistent-backend.js.map +1 -1
  112. package/dist/core/process-start-identity.d.ts +3 -0
  113. package/dist/core/process-start-identity.d.ts.map +1 -0
  114. package/dist/core/process-start-identity.js +62 -0
  115. package/dist/core/process-start-identity.js.map +1 -0
  116. package/dist/core/restart-report.d.ts +6 -1
  117. package/dist/core/restart-report.d.ts.map +1 -1
  118. package/dist/core/restart-report.js +22 -4
  119. package/dist/core/restart-report.js.map +1 -1
  120. package/dist/core/riff-shutdown-detach.d.ts +164 -0
  121. package/dist/core/riff-shutdown-detach.d.ts.map +1 -0
  122. package/dist/core/riff-shutdown-detach.js +787 -0
  123. package/dist/core/riff-shutdown-detach.js.map +1 -0
  124. package/dist/core/riff-worker-shutdown-readiness.d.ts +17 -0
  125. package/dist/core/riff-worker-shutdown-readiness.d.ts.map +1 -0
  126. package/dist/core/riff-worker-shutdown-readiness.js +21 -0
  127. package/dist/core/riff-worker-shutdown-readiness.js.map +1 -0
  128. package/dist/core/role-resolver.d.ts +5 -2
  129. package/dist/core/role-resolver.d.ts.map +1 -1
  130. package/dist/core/role-resolver.js +55 -23
  131. package/dist/core/role-resolver.js.map +1 -1
  132. package/dist/core/session-manager.d.ts +2 -0
  133. package/dist/core/session-manager.d.ts.map +1 -1
  134. package/dist/core/session-manager.js +20 -18
  135. package/dist/core/session-manager.js.map +1 -1
  136. package/dist/core/session-marker.d.ts +1 -1
  137. package/dist/core/session-marker.d.ts.map +1 -1
  138. package/dist/core/session-marker.js +2 -2
  139. package/dist/core/session-marker.js.map +1 -1
  140. package/dist/core/shutdown-budgets.d.ts +27 -0
  141. package/dist/core/shutdown-budgets.d.ts.map +1 -0
  142. package/dist/core/shutdown-budgets.js +47 -0
  143. package/dist/core/shutdown-budgets.js.map +1 -0
  144. package/dist/core/supervisor-shutdown-ipc.d.ts +10 -0
  145. package/dist/core/supervisor-shutdown-ipc.d.ts.map +1 -0
  146. package/dist/core/supervisor-shutdown-ipc.js +10 -0
  147. package/dist/core/supervisor-shutdown-ipc.js.map +1 -0
  148. package/dist/core/supervisor-shutdown-protocol.d.ts +16 -0
  149. package/dist/core/supervisor-shutdown-protocol.d.ts.map +1 -0
  150. package/dist/core/supervisor-shutdown-protocol.js +16 -0
  151. package/dist/core/supervisor-shutdown-protocol.js.map +1 -0
  152. package/dist/core/terminal-write-auth.d.ts +4 -4
  153. package/dist/core/terminal-write-auth.d.ts.map +1 -1
  154. package/dist/core/terminal-write-auth.js +18 -6
  155. package/dist/core/terminal-write-auth.js.map +1 -1
  156. package/dist/core/types.d.ts +26 -0
  157. package/dist/core/types.d.ts.map +1 -1
  158. package/dist/core/types.js +9 -0
  159. package/dist/core/types.js.map +1 -1
  160. package/dist/core/worker-pool.d.ts +20 -3
  161. package/dist/core/worker-pool.d.ts.map +1 -1
  162. package/dist/core/worker-pool.js +586 -62
  163. package/dist/core/worker-pool.js.map +1 -1
  164. package/dist/daemon.d.ts +1 -0
  165. package/dist/daemon.d.ts.map +1 -1
  166. package/dist/daemon.js +345 -111
  167. package/dist/daemon.js.map +1 -1
  168. package/dist/dashboard/auth.d.ts +21 -11
  169. package/dist/dashboard/auth.d.ts.map +1 -1
  170. package/dist/dashboard/auth.js +39 -25
  171. package/dist/dashboard/auth.js.map +1 -1
  172. package/dist/dashboard/bot-payload.d.ts +0 -1
  173. package/dist/dashboard/bot-payload.d.ts.map +1 -1
  174. package/dist/dashboard/bot-payload.js +0 -1
  175. package/dist/dashboard/bot-payload.js.map +1 -1
  176. package/dist/dashboard/dashboard-summary-endpoint.d.ts +39 -0
  177. package/dist/dashboard/dashboard-summary-endpoint.d.ts.map +1 -0
  178. package/dist/dashboard/dashboard-summary-endpoint.js +50 -0
  179. package/dist/dashboard/dashboard-summary-endpoint.js.map +1 -0
  180. package/dist/dashboard/dashboard-summary.d.ts +62 -0
  181. package/dist/dashboard/dashboard-summary.d.ts.map +1 -0
  182. package/dist/dashboard/dashboard-summary.js +106 -0
  183. package/dist/dashboard/dashboard-summary.js.map +1 -0
  184. package/dist/dashboard/feed-groups.d.ts +17 -0
  185. package/dist/dashboard/feed-groups.d.ts.map +1 -0
  186. package/dist/dashboard/feed-groups.js +75 -0
  187. package/dist/dashboard/feed-groups.js.map +1 -0
  188. package/dist/dashboard/web/feed-group-picker.d.ts +13 -0
  189. package/dist/dashboard/web/feed-group-picker.d.ts.map +1 -0
  190. package/dist/dashboard/web/feed-group-picker.js +45 -0
  191. package/dist/dashboard/web/feed-group-picker.js.map +1 -0
  192. package/dist/dashboard/web/groups-page.d.ts.map +1 -1
  193. package/dist/dashboard/web/groups-page.js +92 -2
  194. package/dist/dashboard/web/groups-page.js.map +1 -1
  195. package/dist/dashboard/web/i18n.d.ts.map +1 -1
  196. package/dist/dashboard/web/i18n.js +8 -14
  197. package/dist/dashboard/web/i18n.js.map +1 -1
  198. package/dist/dashboard/web/roles-page.d.ts.map +1 -1
  199. package/dist/dashboard/web/roles-page.js +36 -4
  200. package/dist/dashboard/web/roles-page.js.map +1 -1
  201. package/dist/dashboard/web/roles.d.ts +3 -1
  202. package/dist/dashboard/web/roles.d.ts.map +1 -1
  203. package/dist/dashboard/web/roles.js +10 -2
  204. package/dist/dashboard/web/roles.js.map +1 -1
  205. package/dist/dashboard/web/schedules-page.d.ts.map +1 -1
  206. package/dist/dashboard/web/schedules-page.js +8 -2
  207. package/dist/dashboard/web/schedules-page.js.map +1 -1
  208. package/dist/dashboard/web/sessions-page.d.ts.map +1 -1
  209. package/dist/dashboard/web/sessions-page.js +101 -2
  210. package/dist/dashboard/web/sessions-page.js.map +1 -1
  211. package/dist/dashboard/web/sessions.js +1 -1
  212. package/dist/dashboard/web/sessions.js.map +1 -1
  213. package/dist/dashboard-web/app.js +1 -1
  214. package/dist/dashboard-web/chunks/{bot-defaults-page-GED4FEMS.js → bot-defaults-page-USC6EZXP.js} +1 -1
  215. package/dist/dashboard-web/chunks/chunk-6ALR252E.js +1 -0
  216. package/dist/dashboard-web/chunks/{chunk-VBXJOJFH.js → chunk-A7VC4BXR.js} +1 -1
  217. package/dist/dashboard-web/chunks/{chunk-HK7NIBJG.js → chunk-KOPISPHN.js} +1 -1
  218. package/dist/dashboard-web/chunks/{chunk-6J5LS5AU.js → chunk-M6BHWQFO.js} +6 -6
  219. package/dist/dashboard-web/chunks/{chunk-KRHWZEXU.js → chunk-RXRJB5SO.js} +1 -1
  220. package/dist/dashboard-web/chunks/{connectors-page-EELM66G3.js → connectors-page-4Z76HWRH.js} +1 -1
  221. package/dist/dashboard-web/chunks/groups-page-C6NSDTIN.js +8 -0
  222. package/dist/dashboard-web/chunks/{insights-page-54UBPPOC.js → insights-page-UTOVYLLY.js} +1 -1
  223. package/dist/dashboard-web/chunks/{monitor-room-PORHVKRH.js → monitor-room-UKTJYTA2.js} +1 -1
  224. package/dist/dashboard-web/chunks/{monitoring-page-XGA7AXNL.js → monitoring-page-Q3CEZIVX.js} +1 -1
  225. package/dist/dashboard-web/chunks/{office-page-AO3AFG45.js → office-page-GYCZOOVJ.js} +1 -1
  226. package/dist/dashboard-web/chunks/{overview-page-F5BUTYR6.js → overview-page-W2VBJ6OH.js} +1 -1
  227. package/dist/dashboard-web/chunks/roles-page-U4SHER4K.js +1 -0
  228. package/dist/dashboard-web/chunks/schedules-page-TNPW3N3Q.js +1 -0
  229. package/dist/dashboard-web/chunks/sessions-page-YWWDDV57.js +6 -0
  230. package/dist/dashboard-web/chunks/{settings-page-OJAZLZQT.js → settings-page-VKW5ZK5K.js} +1 -1
  231. package/dist/dashboard-web/chunks/{skills-page-EFZQPWV4.js → skills-page-ZCEDFGZZ.js} +1 -1
  232. package/dist/dashboard-web/chunks/{team-federation-page-ZJVAP7HW.js → team-federation-page-OMFGGBT2.js} +1 -1
  233. package/dist/dashboard-web/chunks/{v3-page-GYWTRGO2.js → v3-page-PLXWK4KO.js} +1 -1
  234. package/dist/dashboard-web/chunks/{whiteboards-page-MSDAG6P7.js → whiteboards-page-NJQOEO2P.js} +1 -1
  235. package/dist/dashboard-web/style.css +179 -0
  236. package/dist/dashboard.js +264 -34
  237. package/dist/dashboard.js.map +1 -1
  238. package/dist/desktop/main/ipc.js +1 -1
  239. package/dist/desktop/main/runtime-service.js +2 -2
  240. package/dist/desktop/main/runtime-service.js.map +1 -1
  241. package/dist/desktop/renderer/app.js +21 -0
  242. package/dist/desktop/renderer/app.js.map +1 -1
  243. package/dist/desktop/shared/types.d.ts +1 -1
  244. package/dist/i18n/en.d.ts.map +1 -1
  245. package/dist/i18n/en.js +19 -7
  246. package/dist/i18n/en.js.map +1 -1
  247. package/dist/i18n/zh.d.ts.map +1 -1
  248. package/dist/i18n/zh.js +19 -7
  249. package/dist/i18n/zh.js.map +1 -1
  250. package/dist/im/lark/card-builder.d.ts.map +1 -1
  251. package/dist/im/lark/card-builder.js +34 -6
  252. package/dist/im/lark/card-builder.js.map +1 -1
  253. package/dist/im/lark/card-handler.d.ts.map +1 -1
  254. package/dist/im/lark/card-handler.js +28 -1
  255. package/dist/im/lark/card-handler.js.map +1 -1
  256. package/dist/im/lark/client.d.ts +7 -0
  257. package/dist/im/lark/client.d.ts.map +1 -1
  258. package/dist/im/lark/client.js +36 -23
  259. package/dist/im/lark/client.js.map +1 -1
  260. package/dist/im/lark/doc-comment.d.ts +7 -4
  261. package/dist/im/lark/doc-comment.d.ts.map +1 -1
  262. package/dist/im/lark/doc-comment.js +19 -6
  263. package/dist/im/lark/doc-comment.js.map +1 -1
  264. package/dist/im/lark/md-card.d.ts +11 -0
  265. package/dist/im/lark/md-card.d.ts.map +1 -1
  266. package/dist/im/lark/md-card.js +46 -0
  267. package/dist/im/lark/md-card.js.map +1 -1
  268. package/dist/services/adopt-input-sequence.d.ts +52 -0
  269. package/dist/services/adopt-input-sequence.d.ts.map +1 -0
  270. package/dist/services/adopt-input-sequence.js +50 -0
  271. package/dist/services/adopt-input-sequence.js.map +1 -0
  272. package/dist/services/bridge-fallback-gate.d.ts +40 -0
  273. package/dist/services/bridge-fallback-gate.d.ts.map +1 -1
  274. package/dist/services/bridge-fallback-gate.js +147 -24
  275. package/dist/services/bridge-fallback-gate.js.map +1 -1
  276. package/dist/services/codex-bridge-queue.d.ts +104 -7
  277. package/dist/services/codex-bridge-queue.d.ts.map +1 -1
  278. package/dist/services/codex-bridge-queue.js +292 -17
  279. package/dist/services/codex-bridge-queue.js.map +1 -1
  280. package/dist/services/codex-service-tier.d.ts +2 -0
  281. package/dist/services/codex-service-tier.d.ts.map +1 -1
  282. package/dist/services/codex-service-tier.js +1 -0
  283. package/dist/services/codex-service-tier.js.map +1 -1
  284. package/dist/services/codex-transcript.d.ts +31 -3
  285. package/dist/services/codex-transcript.d.ts.map +1 -1
  286. package/dist/services/codex-transcript.js +340 -2
  287. package/dist/services/codex-transcript.js.map +1 -1
  288. package/dist/services/hook-runner.d.ts +20 -1
  289. package/dist/services/hook-runner.d.ts.map +1 -1
  290. package/dist/services/hook-runner.js +17 -13
  291. package/dist/services/hook-runner.js.map +1 -1
  292. package/dist/services/open-platform-rename.d.ts.map +1 -1
  293. package/dist/services/open-platform-rename.js +1 -108
  294. package/dist/services/open-platform-rename.js.map +1 -1
  295. package/dist/services/restart-intent-store.d.ts +22 -2
  296. package/dist/services/restart-intent-store.d.ts.map +1 -1
  297. package/dist/services/restart-intent-store.js +160 -18
  298. package/dist/services/restart-intent-store.js.map +1 -1
  299. package/dist/services/sandbox-store.d.ts +22 -0
  300. package/dist/services/sandbox-store.d.ts.map +1 -1
  301. package/dist/services/sandbox-store.js +37 -8
  302. package/dist/services/sandbox-store.js.map +1 -1
  303. package/dist/services/session-store.d.ts +52 -2
  304. package/dist/services/session-store.d.ts.map +1 -1
  305. package/dist/services/session-store.js +276 -23
  306. package/dist/services/session-store.js.map +1 -1
  307. package/dist/services/structured-bridge-clis.d.ts +8 -1
  308. package/dist/services/structured-bridge-clis.d.ts.map +1 -1
  309. package/dist/services/structured-bridge-clis.js +13 -0
  310. package/dist/services/structured-bridge-clis.js.map +1 -1
  311. package/dist/services/submit-confirmation.d.ts +50 -0
  312. package/dist/services/submit-confirmation.d.ts.map +1 -1
  313. package/dist/services/submit-confirmation.js +82 -0
  314. package/dist/services/submit-confirmation.js.map +1 -1
  315. package/dist/services/submit-notification.d.ts +3 -0
  316. package/dist/services/submit-notification.d.ts.map +1 -0
  317. package/dist/services/submit-notification.js +15 -0
  318. package/dist/services/submit-notification.js.map +1 -0
  319. package/dist/services/traex-transcript.d.ts +25 -2
  320. package/dist/services/traex-transcript.d.ts.map +1 -1
  321. package/dist/services/traex-transcript.js +133 -1
  322. package/dist/services/traex-transcript.js.map +1 -1
  323. package/dist/services/voice/index.d.ts +3 -2
  324. package/dist/services/voice/index.d.ts.map +1 -1
  325. package/dist/services/voice/index.js +5 -5
  326. package/dist/services/voice/index.js.map +1 -1
  327. package/dist/services/voice/openai.d.ts +2 -1
  328. package/dist/services/voice/openai.d.ts.map +1 -1
  329. package/dist/services/voice/openai.js +2 -1
  330. package/dist/services/voice/openai.js.map +1 -1
  331. package/dist/services/voice/sami.d.ts +5 -2
  332. package/dist/services/voice/sami.d.ts.map +1 -1
  333. package/dist/services/voice/sami.js +19 -4
  334. package/dist/services/voice/sami.js.map +1 -1
  335. package/dist/setup/bots-store.d.ts.map +1 -1
  336. package/dist/setup/bots-store.js +10 -4
  337. package/dist/setup/bots-store.js.map +1 -1
  338. package/dist/setup/lark-scopes.json +2 -0
  339. package/dist/setup/open-platform-automation.d.ts +9 -1
  340. package/dist/setup/open-platform-automation.d.ts.map +1 -1
  341. package/dist/setup/open-platform-automation.js +44 -15
  342. package/dist/setup/open-platform-automation.js.map +1 -1
  343. package/dist/setup/open-platform-visibility.d.ts +42 -0
  344. package/dist/setup/open-platform-visibility.d.ts.map +1 -0
  345. package/dist/setup/open-platform-visibility.js +133 -0
  346. package/dist/setup/open-platform-visibility.js.map +1 -0
  347. package/dist/setup/verify-permissions.d.ts.map +1 -1
  348. package/dist/setup/verify-permissions.js +6 -0
  349. package/dist/setup/verify-permissions.js.map +1 -1
  350. package/dist/types.d.ts +50 -1
  351. package/dist/types.d.ts.map +1 -1
  352. package/dist/utils/async-serial-queue.d.ts +9 -0
  353. package/dist/utils/async-serial-queue.d.ts.map +1 -0
  354. package/dist/utils/async-serial-queue.js +13 -0
  355. package/dist/utils/async-serial-queue.js.map +1 -0
  356. package/dist/utils/child-env.d.ts +1 -1
  357. package/dist/utils/child-env.d.ts.map +1 -1
  358. package/dist/utils/child-env.js +6 -0
  359. package/dist/utils/child-env.js.map +1 -1
  360. package/dist/utils/idle-detector.d.ts +12 -0
  361. package/dist/utils/idle-detector.d.ts.map +1 -1
  362. package/dist/utils/idle-detector.js +19 -0
  363. package/dist/utils/idle-detector.js.map +1 -1
  364. package/dist/utils/input-gate.d.ts +87 -0
  365. package/dist/utils/input-gate.d.ts.map +1 -1
  366. package/dist/utils/input-gate.js +86 -0
  367. package/dist/utils/input-gate.js.map +1 -1
  368. package/dist/utils/runtime-screen-status.d.ts +52 -0
  369. package/dist/utils/runtime-screen-status.d.ts.map +1 -0
  370. package/dist/utils/runtime-screen-status.js +60 -0
  371. package/dist/utils/runtime-screen-status.js.map +1 -0
  372. package/dist/utils/user-token.d.ts.map +1 -1
  373. package/dist/utils/user-token.js +53 -2
  374. package/dist/utils/user-token.js.map +1 -1
  375. package/dist/worker.js +2287 -578
  376. package/dist/worker.js.map +1 -1
  377. package/dist/workflows/v3/session-relay-client.d.ts +1 -0
  378. package/dist/workflows/v3/session-relay-client.d.ts.map +1 -1
  379. package/dist/workflows/v3/session-relay-client.js +12 -3
  380. package/dist/workflows/v3/session-relay-client.js.map +1 -1
  381. package/package.json +1 -1
  382. package/dist/dashboard-web/chunks/groups-page-SGE2BNX7.js +0 -8
  383. package/dist/dashboard-web/chunks/roles-page-M5GIASJU.js +0 -1
  384. package/dist/dashboard-web/chunks/schedules-page-O232WQRR.js +0 -1
  385. package/dist/dashboard-web/chunks/sessions-page-WG4PRQXJ.js +0 -6
@@ -1 +1 @@
1
- 90b8834b47c0304b4b6eab82833f1339dc9d4e5ec0d9c1fe75f335c83e338c91
1
+ a63627355856e846a26be9f4935292c6302f4a68df15eebdd3467897f32a02ea
@@ -1,4 +1,4 @@
1
- import type { SessionBackend, SpawnOpts } from './types.js';
1
+ import type { SessionBackend, SessionDestroyResult, SessionShutdownDetachResult, SpawnOpts } from './types.js';
2
2
  /**
3
3
  * Mandatory setup commands run in the riff sandbox to ensure `botmux` is
4
4
  * available. These are ALWAYS sent to the riff API via `config.setupCommands`
@@ -173,6 +173,24 @@ export declare class RiffBackend implements SessionBackend {
173
173
  private cancelTimeoutMs;
174
174
  private createTimeoutMs;
175
175
  private destroyDeadlineMs;
176
+ /** Exact late/current task whose close cancellation failed. Retained across
177
+ * the prepare-close handshake so the daemon can persist a retry handle. */
178
+ private closeFailureTaskId;
179
+ private closeFailureError;
180
+ private closeLateTaskHandled;
181
+ private closePrepared;
182
+ private closeAttempt;
183
+ private destroyInFlight;
184
+ private cancelInFlight;
185
+ private abortInFlight;
186
+ /** Graceful daemon shutdown is a non-cancelling two-phase detach. It fences
187
+ * only writes arriving after prepare; writes already appended to writeChain
188
+ * still drain so a late child id can be durably handed to the daemon. */
189
+ private shutdownDetaching;
190
+ private shutdownDetachPrepared;
191
+ private shutdownDetachAttempt;
192
+ private shutdownDetachInFlight;
193
+ private shutdownDetachAbortInFlight;
176
194
  /** Serializes write() → createTask/followUp. Without this, a second message
177
195
  * arriving before the first task-execute HTTP returns would see
178
196
  * currentTaskId === null and create a duplicate task. */
@@ -191,12 +209,17 @@ export declare class RiffBackend implements SessionBackend {
191
209
  private resolveJwt;
192
210
  private readJwtFromBytecloudKeychain;
193
211
  spawn(_bin: string, _args: string[], _opts: SpawnOpts): void;
194
- write(data: string): void;
212
+ write(data: string): boolean;
195
213
  resize(_cols: number, _rows: number): void;
196
214
  onData(cb: (data: string) => void): void;
197
215
  onExit(cb: (code: number | null, signal: string | null) => void): void;
198
216
  kill(): void;
199
- destroySession(): Promise<void>;
217
+ destroySession(): Promise<SessionDestroyResult>;
218
+ abortDestroySession(): Promise<void>;
219
+ commitDestroySession(): void;
220
+ prepareShutdownDetach(): Promise<SessionShutdownDetachResult>;
221
+ abortShutdownDetach(): Promise<SessionShutdownDetachResult>;
222
+ commitShutdownDetach(): void;
200
223
  getChildPid(): number | null;
201
224
  captureCurrentScreen(): string;
202
225
  captureViewport(): string;
@@ -240,8 +263,8 @@ export declare class RiffBackend implements SessionBackend {
240
263
  * Post-await adoption gate for a freshly created/followed-up task id.
241
264
  * - closing(/close 竞态窗口):这个 late task 已经没有会话可服务——立即取消
242
265
  * (有界+一次重试),绝不 stream/登记,防远端 orphan;
243
- * - killed(detach:重启/休眠):登记 id 让 daemon 持久化血缘,但不 stream
244
- * (任务合法续跑,重启后 follow-up 接上);
266
+ * - killed / shutdownDetaching(detach):登记 id 让 daemon 持久化血缘,
267
+ * 但不 stream(任务合法续跑,重启后 follow-up 接上);
245
268
  * - 正常:登记 + 由调用方启动 stream。
246
269
  */
247
270
  private adoptLateTask;
@@ -251,6 +274,7 @@ export declare class RiffBackend implements SessionBackend {
251
274
  * with no UI left to clear it. */
252
275
  private buildRepos;
253
276
  private cancelTask;
277
+ private cancelTaskWithRetry;
254
278
  private streamTask;
255
279
  private handleSseEvent;
256
280
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"riff-backend.d.ts","sourceRoot":"","sources":["../../../src/adapters/backend/riff-backend.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAqC5D;;;;;;;GAOG;AACH,mEAAmE;AACnE,eAAO,MAAM,sBAAsB,6CAA8C,CAAC;AAClF,eAAO,MAAM,qBAAqB,wBAAyB,CAAC;A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nC,OAAO,CAAC,UAAU;YAIJ,UAAU;YAeV,mBAAmB;YA0BnB,UAAU;IA4ExB,OAAO,CAAC,cAAc;IA+HtB;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;IAgBvB,oFAAoF;IACpF,OAAO,CAAC,mBAAmB;IAW3B,yFAAyF;YAC3E,oBAAoB;IAsBlC,OAAO,CAAC,SAAS;YAUH,kBAAkB;CA0DjC"}
@@ -250,6 +250,24 @@ export class RiffBackend {
250
250
  cancelTimeoutMs = 4_000;
251
251
  createTimeoutMs = 10_000;
252
252
  destroyDeadlineMs = 20_000;
253
+ /** Exact late/current task whose close cancellation failed. Retained across
254
+ * the prepare-close handshake so the daemon can persist a retry handle. */
255
+ closeFailureTaskId = null;
256
+ closeFailureError = null;
257
+ closeLateTaskHandled = false;
258
+ closePrepared = false;
259
+ closeAttempt = null;
260
+ destroyInFlight = null;
261
+ cancelInFlight = null;
262
+ abortInFlight = null;
263
+ /** Graceful daemon shutdown is a non-cancelling two-phase detach. It fences
264
+ * only writes arriving after prepare; writes already appended to writeChain
265
+ * still drain so a late child id can be durably handed to the daemon. */
266
+ shutdownDetaching = false;
267
+ shutdownDetachPrepared = false;
268
+ shutdownDetachAttempt = null;
269
+ shutdownDetachInFlight = null;
270
+ shutdownDetachAbortInFlight = null;
253
271
  /** Serializes write() → createTask/followUp. Without this, a second message
254
272
  * arriving before the first task-execute HTTP returns would see
255
273
  * currentTaskId === null and create a duplicate task. */
@@ -325,8 +343,16 @@ export class RiffBackend {
325
343
  // No actual process to spawn. Task creation happens on first write().
326
344
  }
327
345
  write(data) {
328
- if (this.killed || this.closing)
329
- return;
346
+ if (this.killed)
347
+ return false;
348
+ if (this.shutdownDetaching) {
349
+ logger.warn('[riff] write rejected while graceful shutdown detach is preparing/prepared');
350
+ return false;
351
+ }
352
+ if (this.closing) {
353
+ logger.warn('[riff] write rejected while explicit close is preparing/prepared');
354
+ return false;
355
+ }
330
356
  const { text, attachments } = this.extractAttachments(data);
331
357
  this.writeChain = this.writeChain
332
358
  .then(async () => {
@@ -348,6 +374,7 @@ export class RiffBackend {
348
374
  .catch((err) => {
349
375
  logger.warn(`[riff] queued write failed: ${err}`);
350
376
  });
377
+ return true;
351
378
  }
352
379
  resize(_cols, _rows) {
353
380
  // No terminal screen to resize.
@@ -372,7 +399,7 @@ export class RiffBackend {
372
399
  this.exitCb?.(0, null);
373
400
  }
374
401
  async destroySession() {
375
- // /close(及 /restart 的替换路径)必须把远端任务真正取消掉——fire-and-forget
402
+ // /close 必须把远端任务真正取消掉——fire-and-forget
376
403
  // 在 worker 紧接 process.exit 时大概率发不出去,已关闭话题的远端 agent 会
377
404
  // 继续拿着注入的凭证发消息。有界 await + 一次重试,失败也明确留痕。
378
405
  //
@@ -380,11 +407,31 @@ export class RiffBackend {
380
407
  // currentTaskId 还是 null/旧值,直接 cancel 会漏掉 late task。先立 closing
381
408
  // 门(拒新写 + 令 in-flight 完成后自取消),再有界等 writeChain 沉降,最后
382
409
  // cancel 沉降后的 current task。
410
+ if (this.shutdownDetaching) {
411
+ return {
412
+ ok: false,
413
+ ...(this.currentTaskId ? { taskId: this.currentTaskId } : {}),
414
+ error: 'shutdown_detach_in_progress',
415
+ };
416
+ }
417
+ if (this.destroyInFlight)
418
+ return this.destroyInFlight;
419
+ if (this.closePrepared) {
420
+ return {
421
+ ok: true,
422
+ ...(this.currentTaskId ? { taskId: this.currentTaskId } : {}),
423
+ };
424
+ }
425
+ const attempt = Symbol('riff-close-prepare');
426
+ this.closeAttempt = attempt;
383
427
  this.closing = true;
428
+ this.closeFailureTaskId = null;
429
+ this.closeFailureError = null;
430
+ this.closeLateTaskHandled = false;
384
431
  // 预算层级(单调覆盖,无内层 race——writeChain 本身有界):
385
432
  // create/follow-up fetch 10s + late cancel 4s×2 = chain 最坏 18s
386
433
  // own cancel 4s×2 = 8s(与 late 情形互斥:closing 分支不登记 current)
387
- // → destroySession 总 deadline 20s → worker close/restart race 22s
434
+ // → destroySession 总 deadline 20s → worker close handshake 22s
388
435
  // → daemon SIGTERM backstop 24s / SIGKILL 29s。
389
436
  // 对 writeChain 只整体 await:单独给它小窗口会在窗口边缘掐掉链内的
390
437
  // late cancel(create 于 t≈窗口末返回 → cancel 尚 pending → teardown 提前
@@ -394,25 +441,220 @@ export class RiffBackend {
394
441
  await this.writeChain;
395
442
  }
396
443
  catch { /* writeChain never rejects (caught internally) */ }
397
- if (this.currentTaskId && !this.taskDone) {
444
+ if (this.closeAttempt !== attempt) {
445
+ return {
446
+ ok: false,
447
+ ...(this.currentTaskId ? { taskId: this.currentTaskId } : {}),
448
+ error: 'close_aborted',
449
+ };
450
+ }
451
+ if (this.closeFailureTaskId) {
452
+ return {
453
+ ok: false,
454
+ taskId: this.closeFailureTaskId,
455
+ error: this.closeFailureError ?? 'late_task_cancel_failed',
456
+ };
457
+ }
458
+ // A task materialized while closing was already cancelled inside the
459
+ // writeChain. Do not then cancel its stale parent lineage as if it were
460
+ // still the active execution.
461
+ if (!this.closeLateTaskHandled && this.currentTaskId && !this.taskDone) {
398
462
  const id = this.currentTaskId;
399
- try {
400
- await this.cancelTask(id);
463
+ const cancelled = await this.cancelTaskWithRetry(id, 'close');
464
+ // abortDestroySession invalidates the exact attempt before waiting for
465
+ // an already-issued cancellation. A late successful HTTP response must
466
+ // not resurrect that aborted generation as a prepared close.
467
+ if (this.closeAttempt !== attempt || !this.closing) {
468
+ return {
469
+ ok: false,
470
+ ...(this.currentTaskId ? { taskId: this.currentTaskId } : {}),
471
+ error: 'close_aborted',
472
+ };
473
+ }
474
+ if (cancelled) {
401
475
  logger.info(`[riff] task ${id} cancelled on close`);
402
476
  }
403
- catch (err) {
404
- try {
405
- await this.cancelTask(id);
406
- logger.info(`[riff] task ${id} cancelled on close (retry)`);
407
- }
408
- catch (err2) {
409
- logger.warn(`[riff] task-cancel failed on close (task ${id} may keep running remotely): ${err2}`);
410
- }
477
+ else {
478
+ return {
479
+ ok: false,
480
+ taskId: id,
481
+ error: this.closeFailureError ?? 'task_cancel_failed',
482
+ };
411
483
  }
412
484
  }
485
+ if (this.closeAttempt !== attempt || !this.closing) {
486
+ return {
487
+ ok: false,
488
+ ...(this.currentTaskId ? { taskId: this.currentTaskId } : {}),
489
+ error: 'close_aborted',
490
+ };
491
+ }
492
+ return {
493
+ ok: true,
494
+ ...(this.currentTaskId ? { taskId: this.currentTaskId } : {}),
495
+ };
413
496
  })();
414
- await Promise.race([teardown, new Promise((r) => setTimeout(r, this.destroyDeadlineMs))]);
415
- this.kill();
497
+ this.destroyInFlight = Promise.race([
498
+ teardown,
499
+ new Promise(resolve => setTimeout(() => resolve({
500
+ ok: false,
501
+ ...(this.closeFailureTaskId || this.currentTaskId
502
+ ? { taskId: this.closeFailureTaskId ?? this.currentTaskId }
503
+ : {}),
504
+ error: 'close_timeout',
505
+ }), this.destroyDeadlineMs)),
506
+ ]).then(async (result) => {
507
+ // Promise.race and the teardown continuation each add a microtask
508
+ // boundary. Revalidate the generation immediately before publishing the
509
+ // prepared bit so a concurrent abort can never be overwritten.
510
+ if (result.ok && (this.closeAttempt !== attempt || !this.closing)) {
511
+ result = {
512
+ ok: false,
513
+ ...(this.currentTaskId ? { taskId: this.currentTaskId } : {}),
514
+ error: 'close_aborted',
515
+ };
516
+ }
517
+ if (result.ok) {
518
+ this.closePrepared = true;
519
+ }
520
+ else {
521
+ // A failed prepare is not a terminal close. Restore admission so the
522
+ // still-active durable owner can accept a follow-up or a close retry.
523
+ await this.abortDestroySession();
524
+ }
525
+ return result;
526
+ }).finally(() => {
527
+ this.destroyInFlight = null;
528
+ });
529
+ return this.destroyInFlight;
530
+ }
531
+ async abortDestroySession() {
532
+ if (this.killed)
533
+ return;
534
+ if (this.abortInFlight)
535
+ return this.abortInFlight;
536
+ this.closeAttempt = null;
537
+ this.closePrepared = false;
538
+ const pendingCancel = this.cancelInFlight;
539
+ this.abortInFlight = (async () => {
540
+ // A close timeout can win Promise.race after task-cancel was already
541
+ // issued. Reopening admission before that request settles lets a new
542
+ // follow-up race a late successful cancellation of its parent. Keep the
543
+ // backend fenced until the exact cancellation attempt reaches terminal.
544
+ if (pendingCancel) {
545
+ try {
546
+ await pendingCancel;
547
+ }
548
+ catch { /* cancel helper returns boolean */ }
549
+ }
550
+ if (this.killed || this.closeAttempt !== null || this.closePrepared)
551
+ return;
552
+ this.closing = false;
553
+ this.closeFailureTaskId = null;
554
+ this.closeFailureError = null;
555
+ this.closeLateTaskHandled = false;
556
+ logger.info('[riff] explicit close aborted; write admission restored');
557
+ })().finally(() => {
558
+ this.abortInFlight = null;
559
+ });
560
+ return this.abortInFlight;
561
+ }
562
+ commitDestroySession() {
563
+ // The daemon has durably published the closed row. Keep admission fenced
564
+ // until the worker immediately detaches/exits.
565
+ this.closePrepared = false;
566
+ this.closeAttempt = null;
567
+ this.closing = true;
568
+ }
569
+ async prepareShutdownDetach() {
570
+ if (this.shutdownDetachInFlight)
571
+ return this.shutdownDetachInFlight;
572
+ if (this.shutdownDetachPrepared) {
573
+ return { ok: true, taskId: this.currentTaskId };
574
+ }
575
+ if (this.killed) {
576
+ return { ok: false, taskId: this.currentTaskId, error: 'backend_killed' };
577
+ }
578
+ if (this.closing || this.destroyInFlight || this.closePrepared) {
579
+ return { ok: false, taskId: this.currentTaskId, error: 'explicit_close_in_progress' };
580
+ }
581
+ const attempt = Symbol('riff-shutdown-detach');
582
+ this.shutdownDetachAttempt = attempt;
583
+ this.shutdownDetaching = true;
584
+ // Existing SSE delivery is presentation-only. Stop it now, but do not
585
+ // cancel the remote task. Any create/follow-up already accepted before the
586
+ // fence remains in writeChain and is allowed to materialize below.
587
+ this.abortController?.abort();
588
+ const drain = (async () => {
589
+ try {
590
+ await this.writeChain;
591
+ }
592
+ catch { /* writeChain catches its own failures */ }
593
+ if (this.killed || this.shutdownDetachAttempt !== attempt || !this.shutdownDetaching) {
594
+ return { ok: false, taskId: this.currentTaskId, error: 'shutdown_detach_aborted' };
595
+ }
596
+ if (this.closing || this.closePrepared) {
597
+ return { ok: false, taskId: this.currentTaskId, error: 'explicit_close_in_progress' };
598
+ }
599
+ this.shutdownDetachPrepared = true;
600
+ logger.info(`[riff] graceful shutdown detach prepared`
601
+ + `${this.currentTaskId ? ` (task ${this.currentTaskId})` : ' (no task lineage)'}`);
602
+ return { ok: true, taskId: this.currentTaskId };
603
+ })();
604
+ this.shutdownDetachInFlight = drain.finally(() => {
605
+ this.shutdownDetachInFlight = null;
606
+ });
607
+ return this.shutdownDetachInFlight;
608
+ }
609
+ async abortShutdownDetach() {
610
+ if (this.killed) {
611
+ return { ok: false, taskId: this.currentTaskId, error: 'backend_killed' };
612
+ }
613
+ if (this.shutdownDetachAbortInFlight)
614
+ return this.shutdownDetachAbortInFlight;
615
+ const pending = this.shutdownDetachInFlight;
616
+ const pendingCancel = this.cancelInFlight;
617
+ this.shutdownDetachAttempt = null;
618
+ this.shutdownDetachPrepared = false;
619
+ this.shutdownDetachAbortInFlight = (async () => {
620
+ // Normally shutdown detach never cancels a remote task. Still wait for
621
+ // any exact cancellation already issued by an overlapping explicit close
622
+ // before reopening admission, otherwise its late result could invalidate
623
+ // a newly accepted follow-up.
624
+ await Promise.all([
625
+ pending ? pending.catch(() => undefined) : Promise.resolve(),
626
+ pendingCancel ? pendingCancel.catch(() => false) : Promise.resolve(),
627
+ ]);
628
+ if (this.killed) {
629
+ return { ok: false, taskId: this.currentTaskId, error: 'backend_killed' };
630
+ }
631
+ if (this.closing || this.shutdownDetachAttempt !== null) {
632
+ return {
633
+ ok: false,
634
+ taskId: this.currentTaskId,
635
+ error: this.closing ? 'explicit_close_in_progress' : 'new_shutdown_detach_in_progress',
636
+ };
637
+ }
638
+ this.shutdownDetaching = false;
639
+ // prepare stopped SSE before the persistence ACK. If shutdown is
640
+ // aborted, reconnect the exact current task so the still-live owner
641
+ // resumes normal output and completion tracking.
642
+ if (this.currentTaskId && !this.taskDone) {
643
+ this.reconnectAttempts = 0;
644
+ void this.streamTask(this.currentTaskId);
645
+ }
646
+ logger.info('[riff] graceful shutdown detach aborted; write admission restored');
647
+ return { ok: true, taskId: this.currentTaskId };
648
+ })().finally(() => {
649
+ this.shutdownDetachAbortInFlight = null;
650
+ });
651
+ return this.shutdownDetachAbortInFlight;
652
+ }
653
+ commitShutdownDetach() {
654
+ this.shutdownDetachPrepared = false;
655
+ this.shutdownDetachAttempt = null;
656
+ // Keep admission fenced until the worker exits immediately after commit.
657
+ this.shutdownDetaching = true;
416
658
  }
417
659
  getChildPid() {
418
660
  return null;
@@ -648,8 +890,8 @@ export class RiffBackend {
648
890
  * Post-await adoption gate for a freshly created/followed-up task id.
649
891
  * - closing(/close 竞态窗口):这个 late task 已经没有会话可服务——立即取消
650
892
  * (有界+一次重试),绝不 stream/登记,防远端 orphan;
651
- * - killed(detach:重启/休眠):登记 id 让 daemon 持久化血缘,但不 stream
652
- * (任务合法续跑,重启后 follow-up 接上);
893
+ * - killed / shutdownDetaching(detach):登记 id 让 daemon 持久化血缘,
894
+ * 但不 stream(任务合法续跑,重启后 follow-up 接上);
653
895
  * - 正常:登记 + 由调用方启动 stream。
654
896
  */
655
897
  async adoptLateTask(taskId) {
@@ -657,22 +899,22 @@ export class RiffBackend {
657
899
  // 在 writeChain 内 await——destroySession 等 writeChain 沉降时就能把这次
658
900
  // 取消一起等到(void 触发会在 worker exit 时被掐断)。
659
901
  logger.info(`[riff] task ${taskId} created during close — cancelling late task`);
660
- try {
661
- await this.cancelTask(taskId);
662
- }
663
- catch {
664
- try {
665
- await this.cancelTask(taskId);
666
- }
667
- catch (err) {
668
- logger.warn(`[riff] late-task cancel failed (task ${taskId} may keep running remotely): ${err}`);
669
- }
670
- }
902
+ this.closeLateTaskHandled = true;
903
+ // Preserve the exact newest lineage even when cancellation succeeds.
904
+ // If the daemon cannot durably commit the close and sends abort, the
905
+ // next follow-up must continue from this child rather than its stale
906
+ // parent. Publishing before the cancel also makes a failed cancel
907
+ // retryable by the daemon.
908
+ this.currentTaskId = taskId;
909
+ this.taskIdCb?.(taskId);
910
+ const cancelled = await this.cancelTaskWithRetry(taskId, 'late-task close');
911
+ if (!cancelled)
912
+ this.taskDone = false;
671
913
  return false;
672
914
  }
673
915
  this.currentTaskId = taskId;
674
916
  this.taskIdCb?.(taskId);
675
- if (this.killed)
917
+ if (this.killed || this.shutdownDetaching)
676
918
  return false;
677
919
  return true;
678
920
  }
@@ -699,6 +941,35 @@ export class RiffBackend {
699
941
  if (!resp.ok)
700
942
  throw new Error(`task-cancel HTTP ${resp.status}`);
701
943
  }
944
+ async cancelTaskWithRetry(taskId, context) {
945
+ const operation = (async () => {
946
+ try {
947
+ await this.cancelTask(taskId);
948
+ return true;
949
+ }
950
+ catch {
951
+ try {
952
+ await this.cancelTask(taskId);
953
+ logger.info(`[riff] task ${taskId} cancelled on ${context} (retry)`);
954
+ return true;
955
+ }
956
+ catch (err) {
957
+ this.closeFailureTaskId = taskId;
958
+ this.closeFailureError = err instanceof Error ? err.message : String(err);
959
+ logger.warn(`[riff] ${context} cancel failed (task ${taskId} may keep running remotely): ${err}`);
960
+ return false;
961
+ }
962
+ }
963
+ })();
964
+ this.cancelInFlight = operation;
965
+ try {
966
+ return await operation;
967
+ }
968
+ finally {
969
+ if (this.cancelInFlight === operation)
970
+ this.cancelInFlight = null;
971
+ }
972
+ }
702
973
  async streamTask(taskId) {
703
974
  const url = `${this.config.baseUrl}/api2/task-stream?id=${encodeURIComponent(taskId)}`;
704
975
  const headers = {};
@@ -885,9 +1156,18 @@ export class RiffBackend {
885
1156
  const kind = data['kind'];
886
1157
  const group = data['group']
887
1158
  ?? data['payload']?.['group'];
888
- // stdout logs are the real output stream — emit as data regardless of logLevel
1159
+ // stdout logs are the real output stream — emit as data regardless of logLevel.
1160
+ // riff stores each stdout log line BARE (no trailing newline): the runner's
1161
+ // logger persists `message` verbatim (Logger.createRootLog) and the SSE `log`
1162
+ // event carries it as `text` unchanged (taskLog.ts runnerLog*→text: log.message).
1163
+ // For codex_app_server that message is one `JSON.stringify(event)` per line. Since
1164
+ // emitText only NORMALIZES existing newlines and never adds a separator, emitting
1165
+ // the bare text would butt consecutive events together into one unreadable wall.
1166
+ // Re-add the per-line separator here (safe & non-duplicating precisely because the
1167
+ // stored line has no trailing newline). NOTE: the `output`/chunk path stays raw —
1168
+ // those chunks may be partial lines, so they must NOT get a synthetic newline.
889
1169
  if (group === 'stdout' && text) {
890
- this.emitText(text);
1170
+ this.emitText(`${text}\n`);
891
1171
  }
892
1172
  else if (this.config.logLevel === 'verbose' && text) {
893
1173
  this.emitLine(`[riff:${kind ?? 'log'}] ${text}`);