@opengeni/react 4.0.2 → 4.0.5-canary.39120434730001

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 (916) hide show
  1. package/README.md +787 -26
  2. package/dist/accounts.js +2 -0
  3. package/dist/accounts.js.map +1 -1
  4. package/dist/approvals.d.ts +2 -1
  5. package/dist/artifacts-document.js +6 -3
  6. package/dist/artifacts-presentation.js +6 -3
  7. package/dist/artifacts-spreadsheet.d.ts +1 -1
  8. package/dist/artifacts-spreadsheet.js +6 -3
  9. package/dist/artifacts.d.ts +5 -1
  10. package/dist/artifacts.js +542 -278
  11. package/dist/artifacts.js.map +1 -1
  12. package/dist/browser-viewer-GEHX3KYE.js +20 -0
  13. package/dist/capability-catalog-row.d.ts +20 -0
  14. package/dist/capability-logo-fallback.d.ts +3 -0
  15. package/dist/chat-interactive-block-5V3BGLXT.js +15 -0
  16. package/dist/chunk-2DDJ6YH6.js +41 -0
  17. package/dist/chunk-2DDJ6YH6.js.map +1 -0
  18. package/dist/chunk-2EGXXUG4.js +1161 -0
  19. package/dist/chunk-2EGXXUG4.js.map +1 -0
  20. package/dist/chunk-2XKRY4GF.js +302 -0
  21. package/dist/chunk-2XKRY4GF.js.map +1 -0
  22. package/dist/chunk-2ZUUIMBY.js +343 -0
  23. package/dist/chunk-2ZUUIMBY.js.map +1 -0
  24. package/dist/chunk-4F4FGCH2.js +34 -0
  25. package/dist/chunk-4F4FGCH2.js.map +1 -0
  26. package/dist/{chunk-Z7WBDB4E.js → chunk-4M2MJLY3.js} +848 -867
  27. package/dist/chunk-4M2MJLY3.js.map +1 -0
  28. package/dist/chunk-4U7SHFQ2.js +193 -0
  29. package/dist/chunk-4U7SHFQ2.js.map +1 -0
  30. package/dist/chunk-5I4VRWBB.js +56 -0
  31. package/dist/chunk-5I4VRWBB.js.map +1 -0
  32. package/dist/{chunk-24M4YBCL.js → chunk-62XZ3IX3.js} +1751 -845
  33. package/dist/chunk-62XZ3IX3.js.map +1 -0
  34. package/dist/chunk-77THWHSU.js +308 -0
  35. package/dist/chunk-77THWHSU.js.map +1 -0
  36. package/dist/chunk-7CZLTFXF.js +466 -0
  37. package/dist/chunk-7CZLTFXF.js.map +1 -0
  38. package/dist/chunk-7N5AD2TC.js +327 -0
  39. package/dist/chunk-7N5AD2TC.js.map +1 -0
  40. package/dist/chunk-7SZ7MMCY.js +325 -0
  41. package/dist/chunk-7SZ7MMCY.js.map +1 -0
  42. package/dist/chunk-7TG6KTR2.js +3153 -0
  43. package/dist/chunk-7TG6KTR2.js.map +1 -0
  44. package/dist/chunk-AIX25FIQ.js +409 -0
  45. package/dist/chunk-AIX25FIQ.js.map +1 -0
  46. package/dist/chunk-AT2HD6RQ.js +1936 -0
  47. package/dist/chunk-AT2HD6RQ.js.map +1 -0
  48. package/dist/chunk-B27E3V37.js +29 -0
  49. package/dist/chunk-B27E3V37.js.map +1 -0
  50. package/dist/{chunk-5M6VTFJ5.js → chunk-B4EDAXMC.js} +37 -13
  51. package/dist/chunk-B4EDAXMC.js.map +1 -0
  52. package/dist/chunk-BOG2FED3.js +35 -0
  53. package/dist/chunk-BOG2FED3.js.map +1 -0
  54. package/dist/chunk-BQYQU5QW.js +109 -0
  55. package/dist/chunk-BQYQU5QW.js.map +1 -0
  56. package/dist/{chunk-PAJU5KKL.js → chunk-BRIOXCLH.js} +68 -25
  57. package/dist/chunk-BRIOXCLH.js.map +1 -0
  58. package/dist/chunk-CM7LVUKC.js +35 -0
  59. package/dist/chunk-CM7LVUKC.js.map +1 -0
  60. package/dist/{chunk-KCGXPP5V.js → chunk-CXIGFHVL.js} +35 -23
  61. package/dist/chunk-CXIGFHVL.js.map +1 -0
  62. package/dist/chunk-DHXKEJBH.js +71 -0
  63. package/dist/chunk-DHXKEJBH.js.map +1 -0
  64. package/dist/{chunk-NOSYBS2D.js → chunk-DN3TKURW.js} +12 -9
  65. package/dist/chunk-DN3TKURW.js.map +1 -0
  66. package/dist/chunk-DNJ23AWQ.js +35 -0
  67. package/dist/chunk-DNJ23AWQ.js.map +1 -0
  68. package/dist/chunk-ESAMXNBZ.js +3237 -0
  69. package/dist/chunk-ESAMXNBZ.js.map +1 -0
  70. package/dist/{chunk-4MDLEHXL.js → chunk-EWATYP5L.js} +64 -44
  71. package/dist/chunk-EWATYP5L.js.map +1 -0
  72. package/dist/{chunk-YBM6CQRU.js → chunk-FQ5CXNUG.js} +65 -42
  73. package/dist/chunk-FQ5CXNUG.js.map +1 -0
  74. package/dist/chunk-FVROZ7HR.js +14396 -0
  75. package/dist/chunk-FVROZ7HR.js.map +1 -0
  76. package/dist/chunk-HEVQKE27.js +150 -0
  77. package/dist/chunk-HEVQKE27.js.map +1 -0
  78. package/dist/chunk-HZ47S3DP.js +1086 -0
  79. package/dist/chunk-HZ47S3DP.js.map +1 -0
  80. package/dist/chunk-I5BJ7ENY.js +174 -0
  81. package/dist/chunk-I5BJ7ENY.js.map +1 -0
  82. package/dist/chunk-IGFZFLI2.js +1390 -0
  83. package/dist/chunk-IGFZFLI2.js.map +1 -0
  84. package/dist/chunk-IGVL3ELX.js +46 -0
  85. package/dist/chunk-IGVL3ELX.js.map +1 -0
  86. package/dist/chunk-IOD24LGR.js +384 -0
  87. package/dist/chunk-IOD24LGR.js.map +1 -0
  88. package/dist/chunk-IOYHDEP3.js +38 -0
  89. package/dist/chunk-IOYHDEP3.js.map +1 -0
  90. package/dist/chunk-IQL77TMM.js +803 -0
  91. package/dist/chunk-IQL77TMM.js.map +1 -0
  92. package/dist/chunk-IZV5FTJC.js +55 -0
  93. package/dist/chunk-IZV5FTJC.js.map +1 -0
  94. package/dist/{chunk-H5YGYNXS.js → chunk-JAYYFOOB.js} +75 -28
  95. package/dist/chunk-JAYYFOOB.js.map +1 -0
  96. package/dist/chunk-KN2MYSCC.js +409 -0
  97. package/dist/chunk-KN2MYSCC.js.map +1 -0
  98. package/dist/{chunk-PEI6RANI.js → chunk-KYVJMTXL.js} +434 -145
  99. package/dist/chunk-KYVJMTXL.js.map +1 -0
  100. package/dist/{chunk-ZYRGEKWS.js → chunk-LJUMYUBO.js} +3 -1
  101. package/dist/{chunk-ZYRGEKWS.js.map → chunk-LJUMYUBO.js.map} +1 -1
  102. package/dist/{chunk-ICA6R6TW.js → chunk-LNUD3JNI.js} +1532 -395
  103. package/dist/chunk-LNUD3JNI.js.map +1 -0
  104. package/dist/chunk-M357MHH3.js +2 -0
  105. package/dist/{chunk-BV5A4OTE.js → chunk-MEL6PH2I.js} +1218 -537
  106. package/dist/chunk-MEL6PH2I.js.map +1 -0
  107. package/dist/chunk-MF6WS2XF.js +386 -0
  108. package/dist/chunk-MF6WS2XF.js.map +1 -0
  109. package/dist/chunk-MK2TQO4Y.js +24 -0
  110. package/dist/chunk-MK2TQO4Y.js.map +1 -0
  111. package/dist/chunk-N7S72EXK.js +25 -0
  112. package/dist/chunk-N7S72EXK.js.map +1 -0
  113. package/dist/{chunk-KZ73RL76.js → chunk-NAWXARTY.js} +58 -9
  114. package/dist/chunk-NAWXARTY.js.map +1 -0
  115. package/dist/chunk-NX4ADH73.js +14 -0
  116. package/dist/chunk-NX4ADH73.js.map +1 -0
  117. package/dist/chunk-OYQQJL3J.js +16 -0
  118. package/dist/chunk-OYQQJL3J.js.map +1 -0
  119. package/dist/chunk-P4MKPCTC.js +51 -0
  120. package/dist/chunk-P4MKPCTC.js.map +1 -0
  121. package/dist/{chunk-JVYQRRC4.js → chunk-PEHTX3V7.js} +21 -1
  122. package/dist/chunk-PEHTX3V7.js.map +1 -0
  123. package/dist/chunk-PMV53IMM.js +26 -0
  124. package/dist/chunk-PMV53IMM.js.map +1 -0
  125. package/dist/{chunk-HUIKIDM5.js → chunk-QOEWDOFW.js} +295 -156
  126. package/dist/chunk-QOEWDOFW.js.map +1 -0
  127. package/dist/chunk-QV3DJVRZ.js +11 -0
  128. package/dist/chunk-QV3DJVRZ.js.map +1 -0
  129. package/dist/{chunk-HUMIRRYI.js → chunk-QYUYVSNG.js} +1103 -1699
  130. package/dist/chunk-QYUYVSNG.js.map +1 -0
  131. package/dist/{chunk-6J56T3MG.js → chunk-RRAQ5FV5.js} +186 -60
  132. package/dist/chunk-RRAQ5FV5.js.map +1 -0
  133. package/dist/{chunk-5YK2ZDIG.js → chunk-TNEZNMSN.js} +4 -10
  134. package/dist/chunk-TNEZNMSN.js.map +1 -0
  135. package/dist/{chunk-22KP6LR5.js → chunk-TXS65BB2.js} +3 -1
  136. package/dist/{chunk-22KP6LR5.js.map → chunk-TXS65BB2.js.map} +1 -1
  137. package/dist/chunk-UIWIOB4U.js +2215 -0
  138. package/dist/chunk-UIWIOB4U.js.map +1 -0
  139. package/dist/chunk-UNJPZGNK.js +63 -0
  140. package/dist/chunk-UNJPZGNK.js.map +1 -0
  141. package/dist/chunk-V7UGCQHQ.js +86 -0
  142. package/dist/chunk-V7UGCQHQ.js.map +1 -0
  143. package/dist/chunk-VU4QUISJ.js +3405 -0
  144. package/dist/chunk-VU4QUISJ.js.map +1 -0
  145. package/dist/chunk-WEY5J52U.js +467 -0
  146. package/dist/chunk-WEY5J52U.js.map +1 -0
  147. package/dist/chunk-WH2CBESG.js +409 -0
  148. package/dist/chunk-WH2CBESG.js.map +1 -0
  149. package/dist/{chunk-VZTQ73XT.js → chunk-XEA5BCMA.js} +3 -1
  150. package/dist/{chunk-VZTQ73XT.js.map → chunk-XEA5BCMA.js.map} +1 -1
  151. package/dist/{chunk-NLTS7JHI.js → chunk-XEIHS3RN.js} +834 -403
  152. package/dist/chunk-XEIHS3RN.js.map +1 -0
  153. package/dist/chunk-YNXZRE3F.js +408 -0
  154. package/dist/chunk-YNXZRE3F.js.map +1 -0
  155. package/dist/chunk-YSRBFJMQ.js +43 -0
  156. package/dist/chunk-YSRBFJMQ.js.map +1 -0
  157. package/dist/{chunk-NEXLLTP4.js → chunk-ZGFU4LVW.js} +6 -5
  158. package/dist/chunk-ZGFU4LVW.js.map +1 -0
  159. package/dist/chunk-ZO35BAMO.js +172 -0
  160. package/dist/chunk-ZO35BAMO.js.map +1 -0
  161. package/dist/chunk-ZUWF4NF7.js +13 -0
  162. package/dist/chunk-ZUWF4NF7.js.map +1 -0
  163. package/dist/client.d.ts +15 -6
  164. package/dist/clipboard.js +3 -1
  165. package/dist/commands/registry.d.ts +2 -1
  166. package/dist/commands/types.d.ts +2 -0
  167. package/dist/components/anthropic-mark.d.ts +3 -0
  168. package/dist/components/approval-surface.d.ts +21 -7
  169. package/dist/components/artifacts/artifact-chrome.d.ts +121 -0
  170. package/dist/components/artifacts/artifact-sandbox.d.ts +30 -0
  171. package/dist/components/artifacts/artifact-surface.d.ts +4 -2
  172. package/dist/components/artifacts/chat-interactive-block.d.ts +29 -0
  173. package/dist/components/artifacts/deferred-chat-media.d.ts +15 -0
  174. package/dist/components/artifacts/document-editor.d.ts +4 -2
  175. package/dist/components/artifacts/editable-artifact-ui.d.ts +4 -2
  176. package/dist/components/artifacts/editable-artifact-view.d.ts +48 -0
  177. package/dist/components/artifacts/editable-document.d.ts +3 -2
  178. package/dist/components/artifacts/editable-presentation.d.ts +4 -3
  179. package/dist/components/artifacts/editable-spreadsheet.d.ts +8 -3
  180. package/dist/components/artifacts/index.d.ts +8 -1
  181. package/dist/components/artifacts/inline-html-document.d.ts +2 -0
  182. package/dist/components/artifacts/latest-task-runner.d.ts +15 -0
  183. package/dist/components/artifacts/presentation-editor.d.ts +6 -2
  184. package/dist/components/artifacts/published-html-artifact-frame.d.ts +17 -40
  185. package/dist/components/artifacts/session-artifact-viewer.d.ts +39 -0
  186. package/dist/components/artifacts/site-view.d.ts +26 -0
  187. package/dist/components/artifacts/spreadsheet-command-queue.d.ts +20 -0
  188. package/dist/components/artifacts/spreadsheet-download.d.ts +7 -0
  189. package/dist/components/artifacts/spreadsheet-general-display.d.ts +24 -0
  190. package/dist/components/artifacts/spreadsheet-grid.d.ts +11 -4
  191. package/dist/components/artifacts/spreadsheet-resize.d.ts +50 -0
  192. package/dist/components/artifacts/spreadsheet-submissions.d.ts +9 -0
  193. package/dist/components/artifacts/visualization-assets.gen.d.ts +2 -0
  194. package/dist/components/browser-select-control.d.ts +16 -0
  195. package/dist/components/browser-viewer.d.ts +11 -2
  196. package/dist/components/chat-composer.d.ts +21 -3
  197. package/dist/components/child-session-link.d.ts +5 -1
  198. package/dist/components/claude-mark.d.ts +3 -0
  199. package/dist/components/code-editor.d.ts +1 -4
  200. package/dist/components/command-palette.d.ts +1 -1
  201. package/dist/components/composer-transcription-control.d.ts +7 -0
  202. package/dist/components/composer.d.ts +30 -67
  203. package/dist/components/computer-viewer.d.ts +1 -1
  204. package/dist/components/copy-button.d.ts +3 -1
  205. package/dist/components/desktop-viewer.d.ts +1 -1
  206. package/dist/components/generated-video-player.d.ts +1 -1
  207. package/dist/components/grok-mark.d.ts +26 -0
  208. package/dist/components/human-input-form.d.ts +26 -32
  209. package/dist/components/human-input-surface.d.ts +5 -1
  210. package/dist/components/linkified-text.d.ts +18 -0
  211. package/dist/components/machine-input-display.d.ts +25 -3
  212. package/dist/components/machine-status-pill.d.ts +3 -2
  213. package/dist/components/machines/agent-status-icon.d.ts +6 -0
  214. package/dist/components/machines/health.d.ts +2 -1
  215. package/dist/components/machines/machine-detail.d.ts +7 -1
  216. package/dist/components/machines/machine-status.d.ts +49 -0
  217. package/dist/components/machines/metric-history-chart.d.ts +1 -1
  218. package/dist/components/machines/series.d.ts +3 -2
  219. package/dist/components/markdown-table-layout.d.ts +11 -2
  220. package/dist/components/markdown.d.ts +37 -4
  221. package/dist/components/message-timeline.d.ts +79 -7
  222. package/dist/components/model-mark.d.ts +29 -0
  223. package/dist/components/model-picker.d.ts +1 -1
  224. package/dist/components/model-policy-picker.d.ts +31 -22
  225. package/dist/components/new-conversation.d.ts +32 -0
  226. package/dist/components/open-geni-chat.d.ts +73 -0
  227. package/dist/components/open-geni-links.d.ts +69 -0
  228. package/dist/components/openrouter-mark.d.ts +6 -0
  229. package/dist/components/opper-mark.d.ts +7 -0
  230. package/dist/components/preview-loading.d.ts +2 -0
  231. package/dist/components/provider-recovery-notice.d.ts +17 -0
  232. package/dist/components/queue-item-content.d.ts +10 -0
  233. package/dist/components/rehype-secret-refs.d.ts +23 -0
  234. package/dist/components/remark-soft-line-breaks.d.ts +38 -0
  235. package/dist/components/sandbox-workspace.d.ts +18 -0
  236. package/dist/components/secret-question-field.d.ts +31 -0
  237. package/dist/components/secret-ref-chip.d.ts +35 -0
  238. package/dist/components/session-capability-frame.d.ts +37 -0
  239. package/dist/components/session-chrome.d.ts +20 -7
  240. package/dist/components/session-commands.d.ts +6 -0
  241. package/dist/components/session-connection-request.d.ts +8 -0
  242. package/dist/components/session-conversation.d.ts +147 -6
  243. package/dist/components/session-list.d.ts +39 -0
  244. package/dist/components/session-mcp-capability-card.d.ts +41 -0
  245. package/dist/components/session-proxy-scope.d.ts +35 -0
  246. package/dist/components/session-status.d.ts +6 -2
  247. package/dist/components/session-usage-limit-notice.d.ts +39 -0
  248. package/dist/components/this-computer/illustrations.d.ts +38 -0
  249. package/dist/components/this-computer/labels.d.ts +111 -0
  250. package/dist/components/this-computer/this-computer-card.d.ts +40 -0
  251. package/dist/components/this-computer/this-computer-setup.d.ts +35 -0
  252. package/dist/components/this-computer/this-computer-status.d.ts +42 -0
  253. package/dist/components/this-computer/use-this-computer.d.ts +29 -0
  254. package/dist/components/timeline-anchor.d.ts +3 -0
  255. package/dist/components/timeline-annotation-shared.d.ts +3 -2
  256. package/dist/components/timeline-annotations-dialog.d.ts +2 -1
  257. package/dist/components/timeline-annotations.d.ts +5 -1
  258. package/dist/components/timeline-reading-progress.d.ts +11 -0
  259. package/dist/components/timeline-search.d.ts +34 -0
  260. package/dist/components/timeline-settlement.d.ts +16 -0
  261. package/dist/components/tool-action-review.d.ts +48 -0
  262. package/dist/components/tool-review-history.d.ts +25 -0
  263. package/dist/components/usage-limit-notice.d.ts +50 -0
  264. package/dist/components/usage-member-list.d.ts +92 -0
  265. package/dist/components/usage-meter.d.ts +74 -0
  266. package/dist/components/use-viewer-menu-dismiss.d.ts +2 -0
  267. package/dist/components/user-message-body.d.ts +10 -1
  268. package/dist/components/workbench-changes.d.ts +2 -1
  269. package/dist/composer-messages.d.ts +75 -0
  270. package/dist/composer-messages.js +9 -0
  271. package/dist/composer-messages.js.map +1 -0
  272. package/dist/composer-voice-events.d.ts +8 -0
  273. package/dist/composer.d.ts +3 -3
  274. package/dist/composer.js +25 -12
  275. package/dist/computer-viewer-VOIOZGVZ.js +21 -0
  276. package/dist/computer-viewer-VOIOZGVZ.js.map +1 -0
  277. package/dist/connect-account-identity.d.ts +8 -0
  278. package/dist/connect-accounts.d.ts +15 -0
  279. package/dist/connect-chooser.d.ts +18 -0
  280. package/dist/connect-panel.d.ts +18 -0
  281. package/dist/connect-setup.d.ts +18 -0
  282. package/dist/connect.d.ts +21 -0
  283. package/dist/connect.js +2216 -0
  284. package/dist/connect.js.map +1 -0
  285. package/dist/connection-catalog.d.ts +38 -0
  286. package/dist/connection-discovery.d.ts +12 -0
  287. package/dist/connection-installed.d.ts +17 -0
  288. package/dist/connection-logo.d.ts +9 -0
  289. package/dist/connection-service-logo.d.ts +8 -0
  290. package/dist/connection-service-presentation.d.ts +13 -0
  291. package/dist/connection-skeleton.d.ts +5 -0
  292. package/dist/connection-type-picker.d.ts +6 -0
  293. package/dist/conversation-timeline.d.ts +1 -1
  294. package/dist/desktop.d.ts +7 -0
  295. package/dist/desktop.js +28 -0
  296. package/dist/desktop.js.map +1 -0
  297. package/dist/device-authorization.d.ts +23 -0
  298. package/dist/diffs.d.ts +8 -0
  299. package/dist/diffs.js +15 -0
  300. package/dist/diffs.js.map +1 -0
  301. package/dist/discovery-cache.d.ts +5 -0
  302. package/dist/editor.d.ts +7 -0
  303. package/dist/editor.js +23 -0
  304. package/dist/editor.js.map +1 -0
  305. package/dist/embedded-new-voice-KPLC5UJZ.js +19 -0
  306. package/dist/embedded-new-voice-KPLC5UJZ.js.map +1 -0
  307. package/dist/embedded-voice-V2RFSLIU.js +19 -0
  308. package/dist/embedded-voice-V2RFSLIU.js.map +1 -0
  309. package/dist/fleet-decision-row-FE73NSQ6.js +361 -0
  310. package/dist/fleet-decision-row-FE73NSQ6.js.map +1 -0
  311. package/dist/hooks/internal.d.ts +27 -2
  312. package/dist/hooks/latest-question.d.ts +26 -0
  313. package/dist/hooks/session-view-cache.d.ts +38 -0
  314. package/dist/hooks/shared-machines-list.d.ts +4 -0
  315. package/dist/hooks/shared-query.d.ts +123 -0
  316. package/dist/hooks/use-attached-browsers.d.ts +1 -1
  317. package/dist/hooks/use-auth-runs.d.ts +1 -4
  318. package/dist/hooks/use-available-models.d.ts +8 -3
  319. package/dist/hooks/use-browser-frame-stream.d.ts +1 -1
  320. package/dist/hooks/use-browser-session.d.ts +12 -1
  321. package/dist/hooks/use-client-config-flags.d.ts +49 -0
  322. package/dist/hooks/use-codex-accounts.d.ts +48 -9
  323. package/dist/hooks/use-composer.d.ts +24 -3
  324. package/dist/hooks/use-computer-frame-stream.d.ts +1 -1
  325. package/dist/hooks/use-computer-input-posture.d.ts +13 -0
  326. package/dist/hooks/use-computer-session.d.ts +5 -0
  327. package/dist/hooks/use-connect.d.ts +23 -0
  328. package/dist/hooks/use-desktop-stream.d.ts +1 -1
  329. package/dist/hooks/use-file-attachments.d.ts +4 -0
  330. package/dist/hooks/use-goal.d.ts +2 -1
  331. package/dist/hooks/use-last-started-turn-policy.d.ts +5 -1
  332. package/dist/hooks/use-machine-chip.d.ts +3 -2
  333. package/dist/hooks/use-new-conversation.d.ts +56 -0
  334. package/dist/hooks/use-new-session-draft.d.ts +74 -0
  335. package/dist/hooks/use-realtime-voice-models.d.ts +7 -0
  336. package/dist/hooks/use-sandbox-files.d.ts +3 -2
  337. package/dist/hooks/use-session-conversation.d.ts +49 -0
  338. package/dist/hooks/use-session-events.d.ts +21 -2
  339. package/dist/hooks/use-session-mcp-approval-policy.d.ts +2 -2
  340. package/dist/hooks/use-session-model-account.d.ts +48 -0
  341. package/dist/hooks/use-supergrok-accounts.d.ts +7 -1
  342. package/dist/hooks/use-terminal-stream.d.ts +11 -5
  343. package/dist/hooks/use-transcription.d.ts +2 -1
  344. package/dist/hooks/use-usage.d.ts +40 -0
  345. package/dist/hooks/use-vaults.d.ts +53 -0
  346. package/dist/hooks/use-voice-input.d.ts +8 -1
  347. package/dist/hooks/use-workspace-sessions.d.ts +24 -5
  348. package/dist/human-input-model.d.ts +123 -0
  349. package/dist/identity-link-accounts.d.ts +11 -0
  350. package/dist/identity-link-consent.d.ts +18 -0
  351. package/dist/index.d.ts +83 -18
  352. package/dist/index.js +2317 -6453
  353. package/dist/index.js.map +1 -1
  354. package/dist/interaction.d.ts +1 -1
  355. package/dist/interaction.js +20 -29
  356. package/dist/interaction.js.map +1 -1
  357. package/dist/latest-question-SXBXROBT.js +118 -0
  358. package/dist/latest-question-SXBXROBT.js.map +1 -0
  359. package/dist/lib/client-config-read.d.ts +31 -0
  360. package/dist/lib/clipboard.d.ts +7 -0
  361. package/dist/lib/error-message.d.ts +7 -0
  362. package/dist/lib/format.d.ts +59 -9
  363. package/dist/lib/host-theme.d.ts +77 -0
  364. package/dist/lib/interaction-errors.d.ts +3 -0
  365. package/dist/lib/menu-styles.d.ts +22 -0
  366. package/dist/lib/notify-observer.d.ts +2 -0
  367. package/dist/lib/pierre-diffs-loader.d.ts +20 -0
  368. package/dist/lib/provider-recovery.d.ts +56 -0
  369. package/dist/lib/scrollbars.d.ts +11 -0
  370. package/dist/lib/terminal-input-readiness.d.ts +11 -0
  371. package/dist/lib/transient-retry.d.ts +26 -0
  372. package/dist/lib/workbench-peers.d.ts +36 -0
  373. package/dist/lib/xterm-theme.d.ts +7 -5
  374. package/dist/machines.js +12 -6
  375. package/dist/{markdown-table-layout-3Z3AWBY7.js → markdown-table-layout-3PV2UAAH.js} +51 -9
  376. package/dist/markdown-table-layout-3PV2UAAH.js.map +1 -0
  377. package/dist/mcp-connection-status.d.ts +15 -0
  378. package/dist/messages/en.d.ts +3328 -0
  379. package/dist/messages/runtime.d.ts +69 -0
  380. package/dist/messages.d.ts +3 -0
  381. package/dist/messages.js +16 -0
  382. package/dist/messages.js.map +1 -0
  383. package/dist/model-mark-paths.d.ts +34 -0
  384. package/dist/model-mark-paths.js +16 -0
  385. package/dist/model-mark-paths.js.map +1 -0
  386. package/dist/model-picker-model.d.ts +112 -0
  387. package/dist/model-picker-model.js +25 -0
  388. package/dist/model-picker-model.js.map +1 -0
  389. package/dist/model-policy-picker-menu-NWIETWSR.js +18 -0
  390. package/dist/model-policy-picker-menu-NWIETWSR.js.map +1 -0
  391. package/dist/model-policy.d.ts +35 -10
  392. package/dist/model-policy.js +12 -1
  393. package/dist/native-previews.d.ts +29 -0
  394. package/dist/native-previews.js +82 -0
  395. package/dist/native-previews.js.map +1 -0
  396. package/dist/new-session-draft.d.ts +7 -0
  397. package/dist/new-session-draft.js +639 -0
  398. package/dist/new-session-draft.js.map +1 -0
  399. package/dist/notification-text.d.ts +27 -0
  400. package/dist/{noto-sans-arabic-loader-IA2T4X2A.js → noto-sans-arabic-loader-XSH2KYWJ.js} +3 -1
  401. package/dist/{noto-sans-arabic-loader-IA2T4X2A.js.map → noto-sans-arabic-loader-XSH2KYWJ.js.map} +1 -1
  402. package/dist/{noto-sans-jp-loader.generated-HFGLYBR3.js → noto-sans-jp-loader.generated-MR5L6V7K.js} +3 -1
  403. package/dist/{noto-sans-jp-loader.generated-HFGLYBR3.js.map → noto-sans-jp-loader.generated-MR5L6V7K.js.map} +1 -1
  404. package/dist/organization-model.d.ts +33 -0
  405. package/dist/organization-model.js +65 -0
  406. package/dist/organization-model.js.map +1 -0
  407. package/dist/platform-activity-row-VSQ2FZ5T.js +119 -0
  408. package/dist/platform-activity-row-VSQ2FZ5T.js.map +1 -0
  409. package/dist/plugin-details.d.ts +14 -0
  410. package/dist/plugin-discovery.d.ts +25 -0
  411. package/dist/preview-loading-paint.d.ts +20 -0
  412. package/dist/provider.d.ts +37 -2
  413. package/dist/queue-presentation-model.d.ts +73 -0
  414. package/dist/queue-presentation-model.js +38 -0
  415. package/dist/queue-presentation-model.js.map +1 -0
  416. package/dist/{queue-surface-implementation-LK3S4BIW.js → queue-surface-implementation-MEKXXWGR.js} +189 -343
  417. package/dist/queue-surface-implementation-MEKXXWGR.js.map +1 -0
  418. package/dist/realtime/embedded-new-voice.d.ts +1 -0
  419. package/dist/realtime/embedded-voice.d.ts +1 -0
  420. package/dist/realtime/realtime-control.d.ts +4 -65
  421. package/dist/realtime/session-realtime.d.ts +79 -0
  422. package/dist/realtime.js +26 -1333
  423. package/dist/realtime.js.map +1 -1
  424. package/dist/sandbox-files-5NRC2QUT.js +24 -0
  425. package/dist/sandbox-files-5NRC2QUT.js.map +1 -0
  426. package/dist/sandbox-label-model.d.ts +31 -0
  427. package/dist/sandbox-label-model.js +20 -0
  428. package/dist/sandbox-label-model.js.map +1 -0
  429. package/dist/scrollbars.d.ts +1 -0
  430. package/dist/scrollbars.js +10 -0
  431. package/dist/scrollbars.js.map +1 -0
  432. package/dist/secret-reference-label.d.ts +15 -0
  433. package/dist/secrets-ui.d.ts +57 -0
  434. package/dist/session-agents-model.d.ts +11 -0
  435. package/dist/session-agents-model.js +25 -0
  436. package/dist/session-agents-model.js.map +1 -0
  437. package/dist/session-attention-model.d.ts +8 -0
  438. package/dist/session-attention-model.js +47 -0
  439. package/dist/session-attention-model.js.map +1 -0
  440. package/dist/session-auth-recommendation.d.ts +6 -0
  441. package/dist/session-capability-policy.d.ts +32 -0
  442. package/dist/session-context.d.ts +9 -1
  443. package/dist/session-feedback-model.d.ts +21 -0
  444. package/dist/session-feedback-model.js +56 -0
  445. package/dist/session-feedback-model.js.map +1 -0
  446. package/dist/session-list-model.d.ts +139 -0
  447. package/dist/session-list-model.js +274 -0
  448. package/dist/session-list-model.js.map +1 -0
  449. package/dist/session-realtime-OZCE6IKP.js +22 -0
  450. package/dist/session-realtime-OZCE6IKP.js.map +1 -0
  451. package/dist/session-realtime.d.ts +7 -0
  452. package/dist/session-realtime.js +20 -0
  453. package/dist/session-realtime.js.map +1 -0
  454. package/dist/session-status-model.d.ts +37 -0
  455. package/dist/session-ui.d.ts +40 -3
  456. package/dist/session-ui.js +127 -21
  457. package/dist/session-ui.js.map +1 -1
  458. package/dist/session.d.ts +10 -2
  459. package/dist/session.js +44 -20
  460. package/dist/site-snapshot.d.ts +14 -0
  461. package/dist/sites-ui.d.ts +24 -0
  462. package/dist/sites.d.ts +3 -0
  463. package/dist/sites.js +15 -0
  464. package/dist/sites.js.map +1 -0
  465. package/dist/skill-discovery.d.ts +47 -0
  466. package/dist/terminal.d.ts +8 -0
  467. package/dist/terminal.js +33 -0
  468. package/dist/terminal.js.map +1 -0
  469. package/dist/testing/session-scenarios.d.ts +10 -0
  470. package/dist/testing/session-scenarios.js +367 -0
  471. package/dist/testing/session-scenarios.js.map +1 -0
  472. package/dist/this-computer.d.ts +8 -0
  473. package/dist/this-computer.js +1042 -0
  474. package/dist/this-computer.js.map +1 -0
  475. package/dist/timeline/activity-rail.d.ts +12 -2
  476. package/dist/timeline/agent-identity.d.ts +30 -0
  477. package/dist/timeline/agent-row.d.ts +31 -0
  478. package/dist/timeline/allowance-exhausted-row.d.ts +24 -0
  479. package/dist/timeline/compaction-copy.d.ts +47 -0
  480. package/dist/timeline/focus-sequence.d.ts +9 -0
  481. package/dist/timeline/genie-copy.d.ts +4 -0
  482. package/dist/timeline/genie-loading.d.ts +48 -0
  483. package/dist/timeline/index.d.ts +12 -5
  484. package/dist/timeline/invoked-tool.d.ts +6 -0
  485. package/dist/timeline/knowledge-receipt.d.ts +17 -0
  486. package/dist/timeline/learning-refusal-copy.d.ts +23 -0
  487. package/dist/timeline/learning-refusal-row.d.ts +19 -0
  488. package/dist/timeline/message-sender.d.ts +19 -0
  489. package/dist/timeline/notice-presentation.d.ts +14 -0
  490. package/dist/timeline/parsers.d.ts +11 -0
  491. package/dist/timeline/patch-apply-command.d.ts +19 -0
  492. package/dist/timeline/platform-activity-presentation.d.ts +26 -0
  493. package/dist/timeline/platform-activity-row.d.ts +1 -2
  494. package/dist/timeline/presented-image.d.ts +11 -0
  495. package/dist/timeline/projection.d.ts +32 -2
  496. package/dist/timeline/provider-logo.d.ts +15 -0
  497. package/dist/timeline/question-nav-model.d.ts +23 -0
  498. package/dist/timeline/registry.d.ts +10 -1
  499. package/dist/timeline/retained-image.d.ts +18 -0
  500. package/dist/timeline/retained-loaders.d.ts +27 -0
  501. package/dist/timeline/rolling-activity.d.ts +11 -0
  502. package/dist/timeline/screenshot-lightbox.d.ts +23 -1
  503. package/dist/timeline/session-usage-limit-row.d.ts +11 -0
  504. package/dist/timeline/shared.d.ts +8 -3
  505. package/dist/timeline/startup-dispatch-details.d.ts +5 -0
  506. package/dist/timeline/startup-preference.d.ts +3 -0
  507. package/dist/timeline/startup-timings.d.ts +4 -0
  508. package/dist/timeline/tool-display-name.d.ts +6 -2
  509. package/dist/timeline/tool-presentation.d.ts +185 -0
  510. package/dist/timeline/turn-summary-model.d.ts +102 -0
  511. package/dist/timeline/turn-summary.d.ts +20 -54
  512. package/dist/timeline/types.d.ts +184 -7
  513. package/dist/timeline/work-presentation.d.ts +61 -0
  514. package/dist/{timeline-annotation-markers-DRSTLEM6.js → timeline-annotation-markers-HYLRTT6S.js} +11 -6
  515. package/dist/timeline-annotation-markers-HYLRTT6S.js.map +1 -0
  516. package/dist/{timeline-annotation-selection-IHLUGVND.js → timeline-annotation-selection-LBKW5GHA.js} +15 -5
  517. package/dist/timeline-annotation-selection-LBKW5GHA.js.map +1 -0
  518. package/dist/{timeline-annotations-dialog-6Q53N5FG.js → timeline-annotations-dialog-JKVINC42.js} +34 -19
  519. package/dist/timeline-annotations-dialog-JKVINC42.js.map +1 -0
  520. package/dist/timeline-model.d.ts +29 -0
  521. package/dist/timeline-model.js +254 -0
  522. package/dist/timeline-model.js.map +1 -0
  523. package/dist/usage/allowance-copy.d.ts +26 -0
  524. package/dist/usage/session-usage-limit.d.ts +89 -0
  525. package/dist/usage/summary.d.ts +35 -0
  526. package/dist/usage.d.ts +17 -0
  527. package/dist/usage.js +1201 -0
  528. package/dist/usage.js.map +1 -0
  529. package/dist/voice-recording-owner.d.ts +7 -0
  530. package/package.json +119 -7
  531. package/src/approvals.ts +8 -1
  532. package/src/artifacts-spreadsheet.ts +1 -0
  533. package/src/artifacts.ts +41 -0
  534. package/src/assets/README.md +8 -0
  535. package/src/assets/gmail.ico +0 -0
  536. package/src/assets/outlook.ico +0 -0
  537. package/src/capability-catalog-row.tsx +96 -0
  538. package/src/capability-logo-fallback.ts +22 -0
  539. package/src/client.ts +18 -30
  540. package/src/commands/registry.ts +46 -36
  541. package/src/commands/types.ts +2 -0
  542. package/src/components/anthropic-mark.tsx +10 -0
  543. package/src/components/approval-surface.tsx +407 -142
  544. package/src/components/artifacts/artifact-chrome.tsx +425 -0
  545. package/src/components/artifacts/artifact-sandbox.tsx +193 -0
  546. package/src/components/artifacts/artifact-surface.tsx +48 -26
  547. package/src/components/artifacts/chat-interactive-block.tsx +260 -0
  548. package/src/components/artifacts/deferred-chat-media.tsx +72 -0
  549. package/src/components/artifacts/document-editor.tsx +193 -45
  550. package/src/components/artifacts/editable-artifact-ui.tsx +23 -11
  551. package/src/components/artifacts/editable-artifact-view.tsx +199 -0
  552. package/src/components/artifacts/editable-artifact-workbench.tsx +8 -3
  553. package/src/components/artifacts/editable-document.tsx +76 -54
  554. package/src/components/artifacts/editable-presentation.tsx +86 -40
  555. package/src/components/artifacts/editable-spreadsheet.tsx +581 -121
  556. package/src/components/artifacts/index.ts +42 -0
  557. package/src/components/artifacts/inline-html-document.ts +24 -0
  558. package/src/components/artifacts/latest-task-runner.ts +49 -0
  559. package/src/components/artifacts/presentation-editor.tsx +422 -122
  560. package/src/components/artifacts/published-html-artifact-frame.tsx +79 -265
  561. package/src/components/artifacts/session-artifact-viewer.tsx +381 -0
  562. package/src/components/artifacts/site-view.tsx +129 -0
  563. package/src/components/artifacts/spreadsheet-canvas.ts +5 -10
  564. package/src/components/artifacts/spreadsheet-command-queue.ts +190 -0
  565. package/src/components/artifacts/spreadsheet-download.tsx +117 -0
  566. package/src/components/artifacts/spreadsheet-general-display.ts +43 -0
  567. package/src/components/artifacts/spreadsheet-grid.tsx +390 -172
  568. package/src/components/artifacts/spreadsheet-resize.tsx +432 -0
  569. package/src/components/artifacts/spreadsheet-submissions.tsx +46 -0
  570. package/src/components/artifacts/visualization-assets/base.css +1015 -0
  571. package/src/components/artifacts/visualization-assets/helpers.html +349 -0
  572. package/src/components/artifacts/visualization-assets.gen.ts +3 -0
  573. package/src/components/browser-select-control.tsx +320 -0
  574. package/src/components/browser-viewer.tsx +1102 -505
  575. package/src/components/chat-composer.tsx +42 -3
  576. package/src/components/child-session-link.tsx +16 -5
  577. package/src/components/claude-mark.tsx +11 -0
  578. package/src/components/code-editor.tsx +38 -27
  579. package/src/components/command-palette.tsx +4 -1
  580. package/src/components/composer-transcription-control.tsx +151 -50
  581. package/src/components/composer.tsx +281 -176
  582. package/src/components/computer-viewer.tsx +1013 -341
  583. package/src/components/copy-button.tsx +17 -7
  584. package/src/components/desktop-viewer.tsx +42 -33
  585. package/src/components/diff-view.tsx +3 -1
  586. package/src/components/enrollment-consent.tsx +39 -34
  587. package/src/components/enrollment-device-flow.tsx +31 -19
  588. package/src/components/file-browser.tsx +47 -35
  589. package/src/components/fleet-tile.tsx +8 -4
  590. package/src/components/generated-video-player.tsx +10 -5
  591. package/src/components/grok-mark.tsx +34 -0
  592. package/src/components/human-input-form.tsx +438 -251
  593. package/src/components/human-input-surface.tsx +8 -0
  594. package/src/components/interaction-intervention-banner.tsx +15 -13
  595. package/src/components/linkified-text.tsx +79 -0
  596. package/src/components/machine-card.tsx +56 -89
  597. package/src/components/machine-dock-bar.tsx +10 -4
  598. package/src/components/machine-health-pill.tsx +4 -2
  599. package/src/components/machine-input-display.ts +309 -34
  600. package/src/components/machine-metrics.tsx +10 -7
  601. package/src/components/machine-status-pill.tsx +23 -15
  602. package/src/components/machines/agent-status-icon.tsx +31 -0
  603. package/src/components/machines/health.ts +53 -10
  604. package/src/components/machines/machine-detail.tsx +230 -42
  605. package/src/components/machines/machine-operation-policy.tsx +36 -29
  606. package/src/components/machines/machine-status.ts +264 -0
  607. package/src/components/machines/metric-history-chart.tsx +8 -2
  608. package/src/components/machines/series.ts +12 -11
  609. package/src/components/machines-dashboard.tsx +16 -9
  610. package/src/components/markdown-table-layout.ts +67 -9
  611. package/src/components/markdown.tsx +470 -133
  612. package/src/components/message-timeline.tsx +2290 -752
  613. package/src/components/model-mark.tsx +102 -0
  614. package/src/components/model-picker.tsx +27 -9
  615. package/src/components/model-policy-picker-menu.tsx +204 -100
  616. package/src/components/model-policy-picker.tsx +215 -152
  617. package/src/components/new-conversation.tsx +223 -0
  618. package/src/components/open-geni-chat.tsx +311 -0
  619. package/src/components/open-geni-links.tsx +183 -0
  620. package/src/components/openrouter-mark.tsx +13 -0
  621. package/src/components/opper-mark.tsx +18 -0
  622. package/src/components/pierre-diff.tsx +47 -19
  623. package/src/components/pierre-file.tsx +38 -11
  624. package/src/components/preview-loading.tsx +111 -0
  625. package/src/components/provider-recovery-notice.tsx +51 -0
  626. package/src/components/queue-item-content.ts +16 -0
  627. package/src/components/queue-surface-implementation.tsx +185 -420
  628. package/src/components/queue-surface-state.tsx +13 -8
  629. package/src/components/queue-surface.tsx +3 -1
  630. package/src/components/rehype-secret-refs.ts +98 -0
  631. package/src/components/remark-soft-line-breaks.ts +166 -0
  632. package/src/components/sandbox-files.tsx +75 -44
  633. package/src/components/sandbox-terminal.tsx +103 -22
  634. package/src/components/sandbox-workspace.tsx +168 -78
  635. package/src/components/secret-question-field.tsx +326 -0
  636. package/src/components/secret-ref-chip.tsx +187 -0
  637. package/src/components/session-capability-frame.tsx +203 -0
  638. package/src/components/session-chrome.tsx +559 -328
  639. package/src/components/session-commands-panel.tsx +34 -17
  640. package/src/components/session-commands.tsx +18 -0
  641. package/src/components/session-connection-request.tsx +99 -0
  642. package/src/components/session-conversation.tsx +853 -118
  643. package/src/components/session-list.tsx +259 -0
  644. package/src/components/session-mcp-capability-card.tsx +681 -0
  645. package/src/components/session-proxy-scope.tsx +160 -0
  646. package/src/components/session-status.tsx +35 -21
  647. package/src/components/session-usage-limit-notice.tsx +176 -0
  648. package/src/components/this-computer/illustrations.tsx +164 -0
  649. package/src/components/this-computer/labels.ts +234 -0
  650. package/src/components/this-computer/this-computer-card.tsx +203 -0
  651. package/src/components/this-computer/this-computer-setup.tsx +433 -0
  652. package/src/components/this-computer/this-computer-status.tsx +329 -0
  653. package/src/components/this-computer/use-this-computer.ts +183 -0
  654. package/src/components/timeline-anchor.tsx +43 -15
  655. package/src/components/timeline-annotation-chrome.tsx +33 -9
  656. package/src/components/timeline-annotation-markers.tsx +4 -2
  657. package/src/components/timeline-annotation-selection.tsx +11 -2
  658. package/src/components/timeline-annotation-shared.ts +9 -8
  659. package/src/components/timeline-annotations-dialog.tsx +30 -9
  660. package/src/components/timeline-annotations.tsx +24 -7
  661. package/src/components/timeline-reading-progress.ts +80 -0
  662. package/src/components/timeline-search.tsx +168 -0
  663. package/src/components/timeline-settlement.ts +60 -0
  664. package/src/components/tool-action-review.tsx +670 -0
  665. package/src/components/tool-review-history.tsx +88 -0
  666. package/src/components/usage-limit-notice.tsx +183 -0
  667. package/src/components/usage-member-list.tsx +797 -0
  668. package/src/components/usage-meter.tsx +386 -0
  669. package/src/components/use-viewer-menu-dismiss.ts +33 -0
  670. package/src/components/user-message-body.tsx +33 -2
  671. package/src/components/workbench-changes.tsx +28 -16
  672. package/src/components/workspace-dock.tsx +45 -13
  673. package/src/composer-messages.ts +153 -0
  674. package/src/composer-voice-events.ts +12 -0
  675. package/src/composer.ts +4 -0
  676. package/src/connect-account-identity.tsx +38 -0
  677. package/src/connect-accounts.tsx +233 -0
  678. package/src/connect-chooser.tsx +339 -0
  679. package/src/connect-panel.tsx +104 -0
  680. package/src/connect-setup.tsx +354 -0
  681. package/src/connect.ts +60 -0
  682. package/src/connection-assets.d.ts +4 -0
  683. package/src/connection-catalog.tsx +175 -0
  684. package/src/connection-discovery.tsx +251 -0
  685. package/src/connection-installed.tsx +56 -0
  686. package/src/connection-logo.tsx +37 -0
  687. package/src/connection-service-logo.tsx +55 -0
  688. package/src/connection-service-presentation.ts +46 -0
  689. package/src/connection-skeleton.tsx +16 -0
  690. package/src/connection-type-picker.tsx +38 -0
  691. package/src/conversation-timeline.ts +11 -2
  692. package/src/desktop.ts +24 -0
  693. package/src/device-authorization.tsx +111 -0
  694. package/src/diffs.ts +16 -0
  695. package/src/discovery-cache.ts +42 -0
  696. package/src/editor.ts +13 -0
  697. package/src/hooks/internal.ts +93 -10
  698. package/src/hooks/latest-question.ts +168 -0
  699. package/src/hooks/session-view-cache.ts +167 -0
  700. package/src/hooks/shared-machines-list.ts +34 -1
  701. package/src/hooks/shared-query.ts +744 -0
  702. package/src/hooks/use-attached-browsers.ts +1 -1
  703. package/src/hooks/use-auth-runs.ts +0 -27
  704. package/src/hooks/use-available-models.ts +20 -10
  705. package/src/hooks/use-browser-frame-stream.ts +23 -4
  706. package/src/hooks/use-browser-session.ts +684 -206
  707. package/src/hooks/use-browser-sessions.ts +32 -1
  708. package/src/hooks/use-client-config-flags.ts +102 -0
  709. package/src/hooks/use-codex-accounts.ts +216 -43
  710. package/src/hooks/use-composer.ts +240 -59
  711. package/src/hooks/use-computer-frame-stream.ts +29 -9
  712. package/src/hooks/use-computer-input-posture.ts +96 -0
  713. package/src/hooks/use-computer-session.ts +419 -100
  714. package/src/hooks/use-connect.ts +23 -0
  715. package/src/hooks/use-desktop-stream.ts +19 -28
  716. package/src/hooks/use-file-attachments.ts +19 -3
  717. package/src/hooks/use-goal.ts +172 -21
  718. package/src/hooks/use-human-input.ts +16 -2
  719. package/src/hooks/use-last-started-turn-policy.ts +37 -11
  720. package/src/hooks/use-machine-chip.ts +13 -8
  721. package/src/hooks/use-machines.ts +24 -10
  722. package/src/hooks/use-new-conversation.ts +377 -0
  723. package/src/hooks/use-new-session-draft.ts +813 -0
  724. package/src/hooks/use-realtime-voice-models.ts +46 -0
  725. package/src/hooks/use-sandbox-files.ts +22 -16
  726. package/src/hooks/use-session-background-commands.ts +2 -2
  727. package/src/hooks/use-session-capabilities.ts +3 -2
  728. package/src/hooks/use-session-conversation.ts +150 -0
  729. package/src/hooks/use-session-events.ts +403 -64
  730. package/src/hooks/use-session-lineage.ts +47 -9
  731. package/src/hooks/use-session-mcp-approval-policy.ts +13 -5
  732. package/src/hooks/use-session-model-account.ts +174 -0
  733. package/src/hooks/use-session.ts +19 -3
  734. package/src/hooks/use-slash-commands.ts +6 -11
  735. package/src/hooks/use-supergrok-accounts.ts +22 -8
  736. package/src/hooks/use-terminal-stream.ts +153 -27
  737. package/src/hooks/use-transcription.ts +45 -19
  738. package/src/hooks/use-turn-queue.ts +25 -5
  739. package/src/hooks/use-usage.ts +100 -0
  740. package/src/hooks/use-vaults.ts +153 -0
  741. package/src/hooks/use-video-artifact-playback.ts +1 -1
  742. package/src/hooks/use-voice-input.ts +127 -19
  743. package/src/hooks/use-workspace-capture.ts +3 -2
  744. package/src/hooks/use-workspace-sessions.ts +74 -7
  745. package/src/human-input-model.ts +374 -0
  746. package/src/identity-link-accounts.tsx +149 -0
  747. package/src/identity-link-consent.tsx +193 -0
  748. package/src/index.ts +282 -16
  749. package/src/interaction.ts +1 -0
  750. package/src/lib/client-config-read.ts +76 -0
  751. package/src/lib/clipboard.ts +29 -0
  752. package/src/lib/error-message.ts +37 -0
  753. package/src/lib/format.ts +231 -36
  754. package/src/lib/host-theme.ts +529 -0
  755. package/src/lib/interaction-errors.ts +15 -0
  756. package/src/lib/menu-styles.ts +44 -0
  757. package/src/lib/notify-observer.ts +15 -0
  758. package/src/lib/pierre-diffs-loader.ts +53 -0
  759. package/src/lib/provider-recovery.ts +255 -0
  760. package/src/lib/scrollbars.ts +30 -0
  761. package/src/lib/terminal-input-readiness.ts +51 -0
  762. package/src/lib/transient-retry.ts +101 -0
  763. package/src/lib/workbench-peers.ts +62 -0
  764. package/src/lib/xterm-theme.ts +23 -21
  765. package/src/mcp-connection-status.ts +39 -0
  766. package/src/messages/en.ts +3810 -0
  767. package/src/messages/runtime.tsx +175 -0
  768. package/src/messages.ts +19 -0
  769. package/src/model-mark-paths.ts +53 -0
  770. package/src/model-picker-model.ts +343 -0
  771. package/src/model-policy.ts +301 -79
  772. package/src/native-previews.ts +104 -0
  773. package/src/new-session-draft.ts +22 -0
  774. package/src/notification-text.ts +81 -0
  775. package/src/organization-model.ts +123 -0
  776. package/src/plugin-details.tsx +192 -0
  777. package/src/plugin-discovery.tsx +209 -0
  778. package/src/preview-loading-paint.ts +68 -0
  779. package/src/provider.tsx +105 -21
  780. package/src/queue-presentation-model.ts +475 -0
  781. package/src/realtime/dropdown-menu.tsx +19 -12
  782. package/src/realtime/embedded-new-voice.tsx +1 -0
  783. package/src/realtime/embedded-voice.tsx +3 -0
  784. package/src/realtime/realtime-control.tsx +240 -609
  785. package/src/realtime/session-realtime.ts +582 -0
  786. package/src/sandbox-label-model.ts +56 -0
  787. package/src/scrollbars.ts +3 -0
  788. package/src/secret-reference-label.ts +47 -0
  789. package/src/secrets-ui.tsx +59 -0
  790. package/src/session-agents-model.ts +40 -0
  791. package/src/session-attention-model.ts +62 -0
  792. package/src/session-auth-recommendation.ts +50 -0
  793. package/src/session-capability-policy.ts +200 -0
  794. package/src/session-context.ts +13 -5
  795. package/src/session-feedback-model.ts +101 -0
  796. package/src/session-list-model.ts +437 -0
  797. package/src/session-realtime.ts +18 -0
  798. package/src/session-status-model.ts +99 -0
  799. package/src/session-ui.ts +102 -3
  800. package/src/session.ts +19 -1
  801. package/src/site-snapshot.ts +74 -0
  802. package/src/sites-ui.tsx +350 -0
  803. package/src/sites.ts +3 -0
  804. package/src/skill-discovery.tsx +221 -0
  805. package/src/terminal.ts +26 -0
  806. package/src/testing/session-scenarios.ts +404 -0
  807. package/src/this-computer.ts +62 -0
  808. package/src/timeline/activity-rail.tsx +289 -119
  809. package/src/timeline/agent-identity.tsx +84 -0
  810. package/src/timeline/agent-row.tsx +235 -0
  811. package/src/timeline/allowance-exhausted-row.tsx +90 -0
  812. package/src/timeline/compaction-copy.ts +125 -0
  813. package/src/timeline/fleet-decision-row.tsx +120 -101
  814. package/src/timeline/focus-sequence.ts +44 -0
  815. package/src/timeline/genie-copy.ts +22 -0
  816. package/src/timeline/genie-loading.tsx +158 -0
  817. package/src/timeline/index.ts +37 -2
  818. package/src/timeline/invoked-tool.ts +15 -0
  819. package/src/timeline/knowledge-receipt.tsx +104 -0
  820. package/src/timeline/learning-refusal-copy.ts +67 -0
  821. package/src/timeline/learning-refusal-row.tsx +70 -0
  822. package/src/timeline/message-sender.tsx +71 -0
  823. package/src/timeline/notice-presentation.ts +67 -0
  824. package/src/timeline/parsers.ts +42 -2
  825. package/src/timeline/patch-apply-command.tsx +139 -0
  826. package/src/timeline/platform-activity-presentation.ts +219 -0
  827. package/src/timeline/platform-activity-row.tsx +34 -98
  828. package/src/timeline/presented-image.ts +63 -0
  829. package/src/timeline/projection.ts +1556 -71
  830. package/src/timeline/provider-logo.tsx +53 -0
  831. package/src/timeline/question-nav-model.ts +28 -0
  832. package/src/timeline/registry.ts +11 -1
  833. package/src/timeline/retained-image.ts +102 -0
  834. package/src/timeline/retained-loaders.ts +91 -0
  835. package/src/timeline/rolling-activity.tsx +84 -0
  836. package/src/timeline/screenshot-lightbox.tsx +250 -10
  837. package/src/timeline/session-usage-limit-row.tsx +44 -0
  838. package/src/timeline/shared.tsx +76 -29
  839. package/src/timeline/startup-dispatch-details.tsx +43 -0
  840. package/src/timeline/startup-preference.ts +33 -0
  841. package/src/timeline/startup-timings.tsx +164 -0
  842. package/src/timeline/tool-diff.tsx +3 -1
  843. package/src/timeline/tool-display-name.ts +38 -6
  844. package/src/timeline/tool-presentation.ts +1552 -0
  845. package/src/timeline/tool-renderers.tsx +1019 -1265
  846. package/src/timeline/turn-summary-model.ts +363 -0
  847. package/src/timeline/turn-summary.tsx +288 -367
  848. package/src/timeline/types.ts +191 -7
  849. package/src/timeline/work-presentation.ts +196 -0
  850. package/src/timeline-model.ts +143 -0
  851. package/src/usage/allowance-copy.ts +70 -0
  852. package/src/usage/session-usage-limit.ts +270 -0
  853. package/src/usage/summary.ts +93 -0
  854. package/src/usage.ts +70 -0
  855. package/src/voice-recording-owner.ts +22 -0
  856. package/styles/compiled.css +2010 -651
  857. package/styles/connect.css +290 -0
  858. package/styles/connect.d.ts +1 -0
  859. package/styles/effective-tokens.css +1 -0
  860. package/styles/index.css +286 -9
  861. package/styles/responsive.css +98 -6
  862. package/styles/session-capability.css +44 -0
  863. package/styles/this-computer.css +1042 -0
  864. package/styles/this-computer.d.ts +1 -0
  865. package/styles/tokens.css +132 -64
  866. package/dist/browser-viewer-NTD6UIPR.js +0 -14
  867. package/dist/chunk-24M4YBCL.js.map +0 -1
  868. package/dist/chunk-4MDLEHXL.js.map +0 -1
  869. package/dist/chunk-5M6VTFJ5.js.map +0 -1
  870. package/dist/chunk-5PQJOCX5.js +0 -902
  871. package/dist/chunk-5PQJOCX5.js.map +0 -1
  872. package/dist/chunk-5YK2ZDIG.js.map +0 -1
  873. package/dist/chunk-6J56T3MG.js.map +0 -1
  874. package/dist/chunk-BV5A4OTE.js.map +0 -1
  875. package/dist/chunk-CQG7YUJB.js +0 -10883
  876. package/dist/chunk-CQG7YUJB.js.map +0 -1
  877. package/dist/chunk-H5YGYNXS.js.map +0 -1
  878. package/dist/chunk-HUIKIDM5.js.map +0 -1
  879. package/dist/chunk-HUMIRRYI.js.map +0 -1
  880. package/dist/chunk-ICA6R6TW.js.map +0 -1
  881. package/dist/chunk-JVYQRRC4.js.map +0 -1
  882. package/dist/chunk-KCGXPP5V.js.map +0 -1
  883. package/dist/chunk-KZ73RL76.js.map +0 -1
  884. package/dist/chunk-NEXLLTP4.js.map +0 -1
  885. package/dist/chunk-NLTS7JHI.js.map +0 -1
  886. package/dist/chunk-NOSYBS2D.js.map +0 -1
  887. package/dist/chunk-PAJU5KKL.js.map +0 -1
  888. package/dist/chunk-PEI6RANI.js.map +0 -1
  889. package/dist/chunk-PLYRL5ER.js +0 -164
  890. package/dist/chunk-PLYRL5ER.js.map +0 -1
  891. package/dist/chunk-R4KRSFGA.js +0 -290
  892. package/dist/chunk-R4KRSFGA.js.map +0 -1
  893. package/dist/chunk-UMECRJRV.js +0 -223
  894. package/dist/chunk-UMECRJRV.js.map +0 -1
  895. package/dist/chunk-VRBL3F5E.js +0 -241
  896. package/dist/chunk-VRBL3F5E.js.map +0 -1
  897. package/dist/chunk-YBM6CQRU.js.map +0 -1
  898. package/dist/chunk-Z7WBDB4E.js.map +0 -1
  899. package/dist/computer-viewer-7TEZC6Y2.js +0 -16
  900. package/dist/fleet-decision-row-YZ3ZKWMM.js +0 -352
  901. package/dist/fleet-decision-row-YZ3ZKWMM.js.map +0 -1
  902. package/dist/hooks/use-environments.d.ts +0 -41
  903. package/dist/hooks/use-packs.d.ts +0 -32
  904. package/dist/markdown-table-layout-3Z3AWBY7.js.map +0 -1
  905. package/dist/model-policy-picker-menu-3R336DP2.js +0 -13
  906. package/dist/platform-activity-row-27LKAWZD.js +0 -169
  907. package/dist/platform-activity-row-27LKAWZD.js.map +0 -1
  908. package/dist/queue-surface-implementation-LK3S4BIW.js.map +0 -1
  909. package/dist/timeline-annotation-markers-DRSTLEM6.js.map +0 -1
  910. package/dist/timeline-annotation-selection-IHLUGVND.js.map +0 -1
  911. package/dist/timeline-annotations-dialog-6Q53N5FG.js.map +0 -1
  912. package/src/hooks/use-environments.ts +0 -182
  913. package/src/hooks/use-packs.ts +0 -157
  914. /package/dist/{browser-viewer-NTD6UIPR.js.map → browser-viewer-GEHX3KYE.js.map} +0 -0
  915. /package/dist/{computer-viewer-7TEZC6Y2.js.map → chat-interactive-block-5V3BGLXT.js.map} +0 -0
  916. /package/dist/{model-policy-picker-menu-3R336DP2.js.map → chunk-M357MHH3.js.map} +0 -0
@@ -1,13 +1,30 @@
1
1
  import {
2
+ parseCustomMcpSetupRequest,
2
3
  parseMediaGenerationResult,
4
+ parseToolDisplayMetadata,
5
+ EMPTY_FINAL_REPLY_NOTICE,
6
+ turnCompletedWithEmptyFinalReply,
3
7
  type HumanInputAnswer,
4
8
  type HumanInputQuestion,
5
9
  type HumanInputResponse,
10
+ type HumanInputSecretAnswerResult,
11
+ type HumanInputSecretSpec,
6
12
  type SessionEvent,
7
13
  type SessionStatus,
8
14
  type TimelineAnnotation,
9
15
  } from "@opengeni/sdk";
10
16
  import fleetDecisionItem from "./fleet-decision-projection";
17
+ import { learningRefusalFromToolOutput } from "@opengeni/sdk/learning-refusal";
18
+ import { learningRefusalText } from "./learning-refusal-copy";
19
+ import {
20
+ allowanceExhaustedMessage,
21
+ parseAllowanceExhaustedRefusal,
22
+ } from "@opengeni/sdk/allowance-refusal";
23
+ import {
24
+ parseSessionUsageLimitReachedRefusal,
25
+ SESSION_USAGE_LIMIT_SEGMENT,
26
+ sessionUsageLimitReachedMessage,
27
+ } from "@opengeni/sdk/session-usage-limits";
11
28
  import {
12
29
  CREDIT_EXHAUSTION_MESSAGE,
13
30
  presentFailure,
@@ -15,6 +32,7 @@ import {
15
32
  tryParseJson,
16
33
  } from "../lib/format";
17
34
  import { mcpToolLeaf, toolMatchesLeaf } from "./tool-display-name";
35
+ import { presentTurnFailureText } from "./compaction-copy";
18
36
  import type {
19
37
  AgentMessageItem,
20
38
  ActivityItem,
@@ -24,7 +42,9 @@ import type {
24
42
  HumanInputAnswerSummary,
25
43
  HumanInputItem,
26
44
  MachineInputBatchItem,
45
+ MachineInputMember,
27
46
  MemoryItem,
47
+ NoticeItem,
28
48
  SandboxItem,
29
49
  StartupPhase,
30
50
  StartupPhaseItem,
@@ -36,9 +56,18 @@ import type {
36
56
  ToolCallTruncation,
37
57
  WorkerItem,
38
58
  } from "./types";
59
+ import { type OpenGeniText } from "../messages/runtime";
39
60
 
40
61
  export { toolDisplayName, mcpToolLeaf, toolMatchesLeaf } from "./tool-display-name";
41
62
 
63
+ /** Message identity only: queue placement needs the surrounding turn history. */
64
+ export function isTimelineUserQuestion(event: SessionEvent): boolean {
65
+ return (
66
+ event.type === "user.message" &&
67
+ workerCompletionPayload(asRecord(event.payload).childCompletion) === null
68
+ );
69
+ }
70
+
42
71
  /* ----------------------------------------------------------------------------
43
72
  Timeline projection
44
73
 
@@ -53,7 +82,7 @@ export { toolDisplayName, mcpToolLeaf, toolMatchesLeaf } from "./tool-display-na
53
82
  memoized, unit-tested, and re-run incrementally as new events stream in.
54
83
  -------------------------------------------------------------------------- */
55
84
 
56
- /** Tool leaves on the first-party OpenGeni MCP server that operate on sessions. */
85
+ /** Tool leaves on the first-party Opengeni MCP server that operate on sessions. */
57
86
  const WORKER_SPAWN_TOOL = "session_create";
58
87
  const WORKER_MESSAGE_TOOL = "session_send_message";
59
88
  const WORKER_FAILURE_CODE_MAX_LENGTH = 128;
@@ -129,10 +158,52 @@ function timelineAnnotationToolOutputText(output: unknown): string | null {
129
158
  return text.length > 0 ? text : null;
130
159
  }
131
160
 
132
- export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
161
+ export function buildTimeline(
162
+ t: OpenGeniText,
163
+ events: SessionEvent[],
164
+ options: { partialStart?: boolean } = {},
165
+ ): TimelineItem[] {
133
166
  const items: TimelineItem[] = [];
167
+ const allowanceNotices = new Set<string>();
168
+ // One "not saved" notice per turn for the same refused change, however
169
+ // often the agent retried it.
170
+ const learningRefusalNotices = new Set<string>();
171
+ const allowanceNotice = (event: SessionEvent, turnId: string | null) => {
172
+ const refusal = parseAllowanceExhaustedRefusal(event.payload);
173
+ if (!refusal) return null;
174
+ const text = allowanceExhaustedMessage(refusal);
175
+ const key = JSON.stringify([
176
+ turnId,
177
+ event.turnAttemptId,
178
+ startupRecoveryRevisionByTurn.get(turnId ?? "") ?? 0,
179
+ refusal.scope,
180
+ refusal.subjectId,
181
+ refusal.resetsAt,
182
+ ]);
183
+ if (!allowanceNotices.has(key)) {
184
+ allowanceNotices.add(key);
185
+ items.push({
186
+ kind: "notice",
187
+ id: `${event.id}-allowance`,
188
+ tone: "failed",
189
+ text,
190
+ // The canonical sentence replaces upstream prose, so a host renderer
191
+ // reading `message` never shows a wrapper's private wording.
192
+ allowance: { ...refusal, message: text },
193
+ occurredAt: event.occurredAt,
194
+ });
195
+ }
196
+ return text;
197
+ };
134
198
  const prescan = prescanTurnAnchors(events);
135
199
  const ordered = orderTimelineEvents(events, prescan);
200
+ // A bounded replay can begin halfway through a message (including inside an
201
+ // interactive fence). Never parse that suffix as a complete Markdown source.
202
+ // Keep the raw events available for pagination; a completed receipt restores
203
+ // the authoritative message without requiring an unbounded history fetch.
204
+ let completeHistoryPrefix = options.partialStart !== true;
205
+ const knownMessagePrefixTurns = new Set<string | null>();
206
+ const incompleteMessageKeys = new Set<string>();
136
207
  const pendingWaitOutcomeByTurn = new Map<string | null, PendingWaitOutcome>();
137
208
  const latestAgentResponseByTurn = new Map<string | null, TrackedAgentResponse>();
138
209
  const identifiedMessages = new Map<string, AgentMessageItem>();
@@ -142,6 +213,59 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
142
213
  .map((request) => stringValue(request.toolCallId))
143
214
  .filter(Boolean),
144
215
  );
216
+ // Delegated workers that have not reported back yet, so a recorded agent wait
217
+ // can say how many agents it is waiting for. Only a session's own workers
218
+ // report back, so a message to any other session is never awaited. Best
219
+ // effort: a bounded replay only knows the spawns and results inside its window.
220
+ const workerSessions = new Set<string>();
221
+ const pendingWorkerSessions = new Set<string>();
222
+ let openWaitNotice: NoticeItem | null = null;
223
+ // Tool results update the original tool row in place, and running lifecycle
224
+ // receipts have no row. Carry resume evidence on the attention landmarks so
225
+ // grouping cannot mistake historical approval for a live wait.
226
+ const presentationWaits = new Map<string | null, Array<NoticeItem | SessionStatusItem>>();
227
+ // Admission blocks hold the whole session, not one turn; any later status
228
+ // (a recheck, a new message, a pause) ends them.
229
+ let openAdmissionBlocks: SessionStatusItem[] = [];
230
+ const presentationFailures = new Map<string | null, SessionStatusItem[]>();
231
+ let presentationTurnId: string | null = null;
232
+ const rememberPresentationWait = (
233
+ item: NoticeItem | SessionStatusItem,
234
+ turnId: string | null,
235
+ ) => {
236
+ const key = turnId ?? presentationTurnId;
237
+ const waits = presentationWaits.get(key) ?? [];
238
+ waits.push(item);
239
+ presentationWaits.set(key, waits);
240
+ items.push(item);
241
+ };
242
+ const resolvePresentationWait = (event: SessionEvent, turnId: string | null) => {
243
+ if (event.duplicateOfEventId || (event.turnAssociation && event.turnAssociation !== "current"))
244
+ return;
245
+ const key = turnId ?? presentationTurnId;
246
+ for (const item of presentationWaits.get(key) ?? []) item.resolvedAt = event.occurredAt;
247
+ presentationWaits.delete(key);
248
+ };
249
+ // Live model-capacity waits. Later lifecycle evidence that the turn is no
250
+ // longer blocked (resume, a non-waiting status, its settlement) resolves
251
+ // them, so a recovered wait never lingers as a warning.
252
+ let openCapacityWaits: NoticeItem[] = [];
253
+ const resolveCapacityWaits = (event: SessionEvent, payload: Record<string, unknown>) => {
254
+ if (openCapacityWaits.length === 0 || !endsCapacityWait(event, payload)) return;
255
+ const eventTurnId = event.turnId ?? null;
256
+ openCapacityWaits = openCapacityWaits.filter((item) => {
257
+ const waitTurnId = item.capacityWait?.turnId ?? null;
258
+ // Status changes are session-wide; a turn settlement ends only its own wait
259
+ // (a queued follow-up being cancelled does not unblock the waiting turn).
260
+ const ends =
261
+ event.type === "session.status.changed" ||
262
+ eventTurnId === null ||
263
+ waitTurnId === null ||
264
+ eventTurnId === waitTurnId;
265
+ if (ends) item.resolvedAt = event.occurredAt;
266
+ return !ends;
267
+ });
268
+ };
145
269
  const queuedAtByTurn = new Map<string, string>();
146
270
  const startupRecoveryRevisionByTurn = new Map<string, number>();
147
271
  const startupPhases = new Map<string, readonly [StartupPhaseItem, string | null, number]>();
@@ -299,6 +423,40 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
299
423
  for (const event of ordered) {
300
424
  const payload = asRecord(event.payload);
301
425
  const turnId = event.turnId ?? null;
426
+ resolveCapacityWaits(event, payload);
427
+ if (
428
+ turnId &&
429
+ (event.type === "turn.started" ||
430
+ (presentationTurnId === null && isAgentActivityEvent(event.type)))
431
+ ) {
432
+ presentationTurnId = turnId;
433
+ }
434
+ if (
435
+ openWaitNotice &&
436
+ (event.type === "user.message" ||
437
+ event.type === "system.update.delivered" ||
438
+ event.type === "turn.started" ||
439
+ event.type === "session.control.paused" ||
440
+ (event.type === "session.status.changed" &&
441
+ (payload.status === "cancelled" || payload.status === "failed")))
442
+ ) {
443
+ // New input, a pause, or the end of the session ends a recorded wait; the
444
+ // notice keeps its wait span.
445
+ openWaitNotice.waitEndedAt = event.occurredAt;
446
+ openWaitNotice = null;
447
+ }
448
+ if (event.type === "session.created") {
449
+ completeHistoryPrefix = true;
450
+ } else if (
451
+ event.type === "turn.started" ||
452
+ (event.type === "user.message" &&
453
+ payload.delivery !== "steer" &&
454
+ payload.routing !== "accepted_for_steering")
455
+ ) {
456
+ // Accepted Steer is visible before its replacement turn starts. It says
457
+ // nothing about the prefix of a still-streaming message from the old turn.
458
+ knownMessagePrefixTurns.add(turnId);
459
+ }
302
460
  startupEvent = event;
303
461
  startupTurnId = turnId;
304
462
  startupAttemptId =
@@ -319,11 +477,39 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
319
477
  : null;
320
478
  if (setupPhase && setupStatus) {
321
479
  closeStreamingTail();
480
+ let blockedReason: StartupPhaseItem["blockedReason"];
481
+ if (setupPhase === "model_preparation" && setupStatus === "failed") {
482
+ blockedReason = startupLifecycleWaitReason(payload);
483
+ // Older preparation events omit the typed lifecycle fields. The
484
+ // sandbox span can supply them only inside the same turn attempt.
485
+ const sandbox = startupPhases.get(`${startupTurnId}:sandbox`);
486
+ const sameAttempt =
487
+ sandbox?.[1] || startupAttemptId
488
+ ? Boolean(startupAttemptId && sandbox?.[1] === startupAttemptId)
489
+ : sandbox?.[2] === startupRecoveryRevision;
490
+ if (
491
+ !blockedReason &&
492
+ payload.expectedTransition === undefined &&
493
+ payload.failureCode === undefined &&
494
+ payload.failureStage === undefined &&
495
+ payload.failureCategory === undefined &&
496
+ payload.error === undefined &&
497
+ startupTurnId &&
498
+ sameAttempt &&
499
+ sandbox?.[0].status === "cancelled"
500
+ ) {
501
+ blockedReason = sandbox[0].blockedReason;
502
+ }
503
+ }
322
504
  settleStartupPhase(
323
505
  setupPhase,
324
- setupStatus,
506
+ blockedReason ? "cancelled" : setupStatus,
325
507
  numberOrNull(payload.durationMs),
326
508
  event.type === "rig.setup.skipped" ? "skipped" : null,
509
+ 0,
510
+ undefined,
511
+ undefined,
512
+ blockedReason,
327
513
  );
328
514
  continue;
329
515
  }
@@ -336,6 +522,8 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
336
522
  closeStreamingTail();
337
523
  const childCompletion = workerCompletionPayload(payload.childCompletion);
338
524
  if (childCompletion) {
525
+ workerSessions.add(childCompletion.childSessionId);
526
+ pendingWorkerSessions.delete(childCompletion.childSessionId);
339
527
  items.push({
340
528
  kind: "worker-completion",
341
529
  id: event.id,
@@ -352,6 +540,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
352
540
  break;
353
541
  }
354
542
  const voiceMessage = realtimeVoiceMessage(payload);
543
+ const sender = messageSender(payload.initiator);
355
544
  items.push({
356
545
  kind: "user-message",
357
546
  id: event.id,
@@ -371,6 +560,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
371
560
  ...(voiceMessage ? { presentation: voiceMessage.presentation } : {}),
372
561
  resources: resourceRefs(payload.resources),
373
562
  tools: toolRefs(payload.tools),
563
+ ...(sender ? { sender } : {}),
374
564
  occurredAt: event.occurredAt,
375
565
  });
376
566
  break;
@@ -388,13 +578,50 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
388
578
  break;
389
579
  }
390
580
 
581
+ case "system.update.settled": {
582
+ // An operator retirement is a passive historical receipt, not a new
583
+ // prompt or model-input delivery. Reuse the existing agent-result row
584
+ // while ordinary turn-input settlement metadata remains quiet.
585
+ if (payload.notificationOnly !== true || payload.reason !== "operator_retirement") break;
586
+ const members = machineInputMembers(payload.members).filter(
587
+ (member) =>
588
+ member.kind === "child_terminal_result" && member.classification === "failure",
589
+ );
590
+ if (members.length === 0) break;
591
+ for (const member of members) {
592
+ workerSessions.add(member.sourceId);
593
+ pendingWorkerSessions.delete(member.sourceId);
594
+ }
595
+ items.push({
596
+ kind: "machine-input-batch",
597
+ id: event.id,
598
+ turnId: null,
599
+ members,
600
+ occurredAt: event.occurredAt,
601
+ });
602
+ break;
603
+ }
604
+
391
605
  case "system.update.delivered": {
392
606
  const inputs = machineInputMembers(payload.members);
607
+ for (const input of inputs) {
608
+ if (input.kind === "child_terminal_result") {
609
+ workerSessions.add(input.sourceId);
610
+ pendingWorkerSessions.delete(input.sourceId);
611
+ }
612
+ }
393
613
  if (inputs.length === 0) break;
394
- // Goal continuations already land as `goal.continuation` GoalRows.
395
- // A solo continuation batch would duplicate that landmark + dump the
396
- // model-facing prompt — skip chrome for that case only.
397
- if (inputs.every((member) => member.kind === "goal_continuation")) {
614
+ // Background command receipts are agent-facing inputs, not chat messages.
615
+ // The durable event remains available to the agent and audit history.
616
+ const visibleInputs = inputs.filter(
617
+ (member) => member.kind !== "background_command_result",
618
+ );
619
+ // Goal continuations already have GoalRows. A batch with no other
620
+ // visible update must not interrupt an in-flight streaming message.
621
+ if (
622
+ visibleInputs.length === 0 ||
623
+ visibleInputs.every((member) => member.kind === "goal_continuation")
624
+ ) {
398
625
  break;
399
626
  }
400
627
  closeStreamingTail();
@@ -402,7 +629,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
402
629
  kind: "machine-input-batch",
403
630
  id: event.id,
404
631
  turnId,
405
- members: inputs,
632
+ members: visibleInputs,
406
633
  occurredAt: event.occurredAt,
407
634
  });
408
635
  break;
@@ -415,10 +642,21 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
415
642
  }
416
643
  const messageId = stringValue(payload.messageId);
417
644
  const messageKey = messageId ? JSON.stringify([turnId, messageId]) : null;
645
+ // Responses providers declare the phase when they announce the item, so
646
+ // a streaming progress note is known as commentary before it completes.
647
+ const phase = assistantMessagePhase(payload.phase);
648
+ if (
649
+ (!completeHistoryPrefix && !knownMessagePrefixTurns.has(turnId)) ||
650
+ (messageKey && incompleteMessageKeys.has(messageKey))
651
+ ) {
652
+ if (messageKey) incompleteMessageKeys.add(messageKey);
653
+ break;
654
+ }
418
655
  const identified = messageKey ? identifiedMessages.get(messageKey) : undefined;
419
656
  if (identified) {
420
657
  if (identified.annotationSource?.eventType !== "agent.message.completed") {
421
658
  identified.text += text;
659
+ if (phase && !identified.phase) identified.phase = phase;
422
660
  rememberAgentResponse(turnId, identified, false);
423
661
  }
424
662
  break;
@@ -460,6 +698,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
460
698
  id: event.id,
461
699
  turnId,
462
700
  text,
701
+ ...(phase ? { phase } : {}),
463
702
  streaming: true,
464
703
  occurredAt: event.occurredAt,
465
704
  };
@@ -470,6 +709,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
470
709
  }
471
710
 
472
711
  case "agent.message.completed": {
712
+ knownMessagePrefixTurns.add(turnId);
473
713
  const text = stringValue(payload.text);
474
714
  const messageId = stringValue(payload.messageId);
475
715
  const messageKey = messageId ? JSON.stringify([turnId, messageId]) : null;
@@ -501,12 +741,15 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
501
741
  if (!open.text || (text && (messageKey || text.startsWith(open.text)))) {
502
742
  open.text = text || open.text;
503
743
  }
504
- open.streaming = false;
505
744
  // A phase-less settlement mirror (the worker's final-output receipt)
506
745
  // must not erase the provider-declared phase captured by the SDK item.
507
746
  if (phase) open.phase = phase;
508
- // Completion time is what the footer shows ("finished at"); keep the
509
- // first-delta stamp only until this event arrives.
747
+ // Completion time is what the footer shows ("finished at"); the
748
+ // first-delta stamp stays as the stream's start.
749
+ if (open.startedAt === undefined && open.occurredAt !== event.occurredAt) {
750
+ open.startedAt = open.occurredAt;
751
+ }
752
+ open.streaming = false;
510
753
  open.occurredAt = event.occurredAt;
511
754
  open.annotationSource =
512
755
  text && open.text === text
@@ -563,7 +806,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
563
806
  }
564
807
  const open = last();
565
808
  if (open?.kind === "reasoning" && open.streaming && open.turnId === turnId) {
566
- open.text += text;
809
+ open.text += reasoningDeltaJoiner(open.text, text) + text;
567
810
  break;
568
811
  }
569
812
  closeStreamingTail();
@@ -580,6 +823,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
580
823
 
581
824
  case "agent.toolCall.created": {
582
825
  const name = typeof payload.name === "string" ? payload.name : "tool";
826
+ const display = parseToolDisplayMetadata(payload.display);
583
827
  const callId = typeof payload.id === "string" ? payload.id : null;
584
828
  const args = payload.arguments ?? null;
585
829
  closeStreamingTail();
@@ -593,13 +837,16 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
593
837
  toolMatchesLeaf(name, WORKER_SPAWN_TOOL) ||
594
838
  toolMatchesLeaf(name, WORKER_MESSAGE_TOOL)
595
839
  ) {
840
+ const spawn = toolMatchesLeaf(name, WORKER_SPAWN_TOOL);
841
+ const title = spawn ? workerTitle(args) : null;
596
842
  items.push({
597
843
  kind: "worker",
598
844
  id: event.id,
599
845
  turnId,
600
846
  callId,
601
- action: toolMatchesLeaf(name, WORKER_SPAWN_TOOL) ? "spawn" : "message",
847
+ action: spawn ? "spawn" : "message",
602
848
  prompt: workerPrompt(args),
849
+ ...(title ? { title } : {}),
603
850
  workerSessionId: extractSessionRef(args),
604
851
  failure: null,
605
852
  status: "running",
@@ -621,6 +868,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
621
868
  (item): item is ToolCallItem => item.kind === "tool-call" && item.callId === callId,
622
869
  );
623
870
  if (existing) {
871
+ if (display) existing.display = display;
624
872
  if (args != null) {
625
873
  existing.arguments = args;
626
874
  }
@@ -637,6 +885,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
637
885
  turnId,
638
886
  callId,
639
887
  name,
888
+ ...(display ? { display } : {}),
640
889
  arguments: args,
641
890
  output: undefined,
642
891
  truncation: null,
@@ -655,12 +904,20 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
655
904
  if (!target) {
656
905
  break;
657
906
  }
907
+ resolvePresentationWait(event, turnId ?? target.turnId);
658
908
  if (target.kind === "worker") {
659
909
  // A worker spawn/message that returns an error flag (or an MCP
660
910
  // isError result) settles to "failed" too, so WorkerRow surfaces it.
661
911
  target.status = isErrorOutput(payload) ? "failed" : "complete";
662
912
  target.workerSessionId = target.workerSessionId ?? extractSessionRef(payload.output);
663
913
  target.failure = target.status === "failed" ? workerFailure(payload.output) : null;
914
+ // A spawned or re-messaged worker owes this session a result.
915
+ if (target.status === "complete" && target.workerSessionId) {
916
+ if (target.action === "spawn") workerSessions.add(target.workerSessionId);
917
+ if (workerSessions.has(target.workerSessionId)) {
918
+ pendingWorkerSessions.add(target.workerSessionId);
919
+ }
920
+ }
664
921
  break;
665
922
  }
666
923
  // An output carrying an explicit error flag (or an MCP isError result)
@@ -689,6 +946,29 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
689
946
  label: target.name,
690
947
  };
691
948
  }
949
+ // A refused Skill, instruction, or Knowledge change is told to the
950
+ // person outside the folded work row, whatever the agent then says.
951
+ const learningRefusal = learningRefusalFromToolOutput(payload.output);
952
+ if (learningRefusal) {
953
+ const key = JSON.stringify([
954
+ turnId ?? target.turnId,
955
+ learningRefusal.destination,
956
+ learningRefusal.reason,
957
+ learningRefusal.skillId ?? null,
958
+ ]);
959
+ if (!learningRefusalNotices.has(key)) {
960
+ learningRefusalNotices.add(key);
961
+ closeStreamingTail();
962
+ items.push({
963
+ kind: "notice",
964
+ id: `${event.id}-learning-refusal`,
965
+ tone: "failed",
966
+ text: learningRefusalText(t, learningRefusal),
967
+ learningRefusal,
968
+ occurredAt: event.occurredAt,
969
+ });
970
+ }
971
+ }
692
972
  break;
693
973
  }
694
974
 
@@ -717,7 +997,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
717
997
  null,
718
998
  0,
719
999
  queuedAt,
720
- `${event.id}-queue`,
1000
+ `${turnId}-queue`,
721
1001
  );
722
1002
  break;
723
1003
  }
@@ -750,8 +1030,11 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
750
1030
  0,
751
1031
  undefined,
752
1032
  undefined,
753
- status === "cancelled" && payload.failureCode === "rotation_in_progress"
754
- ? "rotation_in_progress"
1033
+ status === "cancelled"
1034
+ ? (startupLifecycleWaitReason(payload) ??
1035
+ (payload.failureCode === "rotation_in_progress"
1036
+ ? "rotation_in_progress"
1037
+ : undefined))
755
1038
  : undefined,
756
1039
  );
757
1040
  break;
@@ -766,8 +1049,13 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
766
1049
  // Rendering either every turn reads as churn. Only FAILURES surface, and
767
1050
  // they surface loudly — the failed event below creates its own item even
768
1051
  // without a started row.
1052
+ // - optional-repository-access: the worker's per-turn report of an
1053
+ // automatically attached repository that sat the turn out, reported
1054
+ // like a skipped optional clone (event payload + log, no row).
769
1055
  if (
770
- (name === "repository-clone" || name === "file-resource-download") &&
1056
+ (name === "repository-clone" ||
1057
+ name === "file-resource-download" ||
1058
+ name === "optional-repository-access") &&
771
1059
  status !== "failed"
772
1060
  ) {
773
1061
  break;
@@ -776,7 +1064,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
776
1064
  if (existing && status !== "running") {
777
1065
  existing.status = status;
778
1066
  if (origin) existing.origin = origin;
779
- const message = failureMessage(payload);
1067
+ const message = failureMessage(t, payload);
780
1068
  if (message) {
781
1069
  existing.output = existing.output ? `${existing.output}\n${message}` : message;
782
1070
  }
@@ -790,7 +1078,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
790
1078
  turnId,
791
1079
  name,
792
1080
  command: typeof payload.command === "string" ? payload.command : null,
793
- output: failureMessage(payload) ?? "",
1081
+ output: failureMessage(t, payload) ?? "",
794
1082
  origin,
795
1083
  status,
796
1084
  occurredAt: event.occurredAt,
@@ -855,6 +1143,12 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
855
1143
  if (!isSessionStatus(status)) {
856
1144
  break;
857
1145
  }
1146
+ const blocked = status === "requires_action" && payload.code === "admission_blocked";
1147
+ if (!blocked && openAdmissionBlocks.length > 0) {
1148
+ for (const open of openAdmissionBlocks) open.resolvedAt = event.occurredAt;
1149
+ openAdmissionBlocks = [];
1150
+ }
1151
+ if (status === "running") resolvePresentationWait(event, turnId);
858
1152
  // Only attention-worthy statuses earn a timeline divider. queued /
859
1153
  // running / idle are machinery telemetry: the header pill carries the
860
1154
  // live status, the shimmer says "running", and the turn chip's duration
@@ -866,41 +1160,94 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
866
1160
  const previous = [...items]
867
1161
  .reverse()
868
1162
  .find((item): item is SessionStatusItem => item.kind === "session-status");
869
- if (previous?.status === status) {
1163
+ if (
1164
+ previous?.status === status &&
1165
+ !previous.resolvedAt &&
1166
+ Boolean(previous.blocked) === blocked
1167
+ ) {
870
1168
  break;
871
1169
  }
872
- items.push({
1170
+ const item: SessionStatusItem = {
873
1171
  kind: "session-status",
874
1172
  id: event.id,
875
1173
  status,
876
1174
  occurredAt: event.occurredAt,
877
- });
1175
+ ...(blocked ? { blocked: true as const } : {}),
1176
+ };
1177
+ if (blocked) {
1178
+ openAdmissionBlocks.push(item);
1179
+ items.push(item);
1180
+ } else if (status === "requires_action") rememberPresentationWait(item, turnId);
1181
+ else {
1182
+ items.push(item);
1183
+ if (status === "failed") {
1184
+ const key = turnId ?? presentationTurnId;
1185
+ const failures = presentationFailures.get(key) ?? [];
1186
+ failures.push(item);
1187
+ presentationFailures.set(key, failures);
1188
+ }
1189
+ }
878
1190
  break;
879
1191
  }
880
1192
 
881
- case "codex.capacity.waiting": {
1193
+ case "subscription.account.switched": {
1194
+ // One neutral receipt, not its provider-specific compatibility alias.
1195
+ // Never expose connection ids, personal labels, or provider error text.
1196
+ const text =
1197
+ payload.reason === "return_to_preferred"
1198
+ ? t("timeline.projection.returnedToYourPreferredModel")
1199
+ : payload.reason === "failover_cross_provider"
1200
+ ? t("timeline.projection.switchedToAFallbackModel")
1201
+ : t("timeline.projection.switchedToAnotherSubscriptionAccount");
882
1202
  items.push({
883
1203
  kind: "notice",
884
1204
  id: event.id,
885
- tone: "waiting",
886
- text:
887
- stringValue(payload.detail) ??
888
- stringValue(payload.error) ??
889
- "Waiting for Codex capacity.",
1205
+ tone: "input",
1206
+ text,
890
1207
  occurredAt: event.occurredAt,
891
1208
  });
892
1209
  break;
893
1210
  }
894
1211
 
895
- case "session.requiresAction": {
896
- finalizeOpen(turnId, "complete", event.occurredAt);
897
- items.push({
1212
+ case "codex.capacity.waiting":
1213
+ case "turn.capacity_waiting": {
1214
+ const capacityWait = capacityWaitPresentation(t, event.type, payload, turnId);
1215
+ const item: NoticeItem = {
898
1216
  kind: "notice",
899
1217
  id: event.id,
900
1218
  tone: "waiting",
901
- text: "Approval needed — the turn is paused until someone decides.",
1219
+ text: capacityWait.text,
1220
+ capacityWait: {
1221
+ turnId: capacityWait.turnId,
1222
+ label: capacityWait.label,
1223
+ detail: capacityWait.detail,
1224
+ },
902
1225
  occurredAt: event.occurredAt,
1226
+ };
1227
+ // A re-armed wait continues the same blocked span; one live wait per turn.
1228
+ openCapacityWaits = openCapacityWaits.filter((open) => {
1229
+ if ((open.capacityWait?.turnId ?? null) !== turnId) return true;
1230
+ open.resolvedAt = event.occurredAt;
1231
+ return false;
903
1232
  });
1233
+ items.push(item);
1234
+ openCapacityWaits.push(item);
1235
+ break;
1236
+ }
1237
+
1238
+ case "session.requiresAction": {
1239
+ finalizeOpen(turnId, "complete", event.occurredAt);
1240
+ rememberPresentationWait(
1241
+ {
1242
+ kind: "notice",
1243
+ id: event.id,
1244
+ tone: "waiting",
1245
+ text: t("timeline.projection.approvalNeededTheTurnIs"),
1246
+ approval: true,
1247
+ occurredAt: event.occurredAt,
1248
+ },
1249
+ turnId,
1250
+ );
904
1251
  break;
905
1252
  }
906
1253
 
@@ -915,6 +1262,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
915
1262
  estimatedTokensBefore: numberOrNull(payload.estimatedTokensBefore),
916
1263
  estimatedTokensAfter: null,
917
1264
  skipReason: null,
1265
+ providerRejection: null,
918
1266
  implementation:
919
1267
  typeof payload.implementation === "string" ? payload.implementation : null,
920
1268
  occurredAt: event.occurredAt,
@@ -932,6 +1280,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
932
1280
  estimatedTokensBefore: numberOrNull(payload.estimatedTokensBefore),
933
1281
  estimatedTokensAfter: numberOrNull(payload.estimatedTokensAfter),
934
1282
  skipReason: null,
1283
+ providerRejection: null,
935
1284
  implementation:
936
1285
  typeof payload.implementation === "string" ? payload.implementation : null,
937
1286
  occurredAt: event.occurredAt,
@@ -949,6 +1298,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
949
1298
  estimatedTokensBefore: numberOrNull(payload.estimatedTokensBefore),
950
1299
  estimatedTokensAfter: null,
951
1300
  skipReason: typeof payload.reason === "string" ? payload.reason : null,
1301
+ providerRejection: compactionProviderRejection(payload),
952
1302
  implementation:
953
1303
  typeof payload.implementation === "string" ? payload.implementation : null,
954
1304
  occurredAt: event.occurredAt,
@@ -965,6 +1315,23 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
965
1315
  turnId,
966
1316
  (startupRecoveryRevisionByTurn.get(turnId) ?? 0) + 1,
967
1317
  );
1318
+ if (
1319
+ !event.duplicateOfEventId &&
1320
+ (!event.turnAssociation || event.turnAssociation === "current")
1321
+ ) {
1322
+ // Human Retry reopens the existing logical turn, unlike a new
1323
+ // prompt. Keep failure evidence, but do not let its old settlement
1324
+ // close the recovered turn's work surface.
1325
+ for (const item of items) {
1326
+ if (item.kind === "turn-end" && item.turnId === turnId && item.outcome === "failed") {
1327
+ item.resumedAt ??= event.occurredAt;
1328
+ }
1329
+ }
1330
+ for (const item of presentationFailures.get(turnId) ?? []) {
1331
+ item.resolvedAt = event.occurredAt;
1332
+ }
1333
+ presentationFailures.delete(turnId);
1334
+ }
968
1335
  }
969
1336
  break;
970
1337
  }
@@ -979,6 +1346,7 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
979
1346
  case "tool.auth_needed":
980
1347
  case "credential.auth_needed": {
981
1348
  const capability = capabilityAuthorizationRequest(payload.capability);
1349
+ const setupRequest = customMcpSetupRequest(payload.setupRequest);
982
1350
  if (
983
1351
  event.type === "tool.auth_needed" &&
984
1352
  !stringValue(payload.toolName) &&
@@ -1001,11 +1369,19 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
1001
1369
  id: event.id,
1002
1370
  turnId,
1003
1371
  serverId: typeof payload.serverId === "string" ? payload.serverId : null,
1004
- source: capability
1005
- ? "capability"
1006
- : event.type === "tool.auth_needed"
1007
- ? "tool"
1008
- : "credential",
1372
+ canonicalServerId:
1373
+ typeof payload.canonicalServerId === "string" ? payload.canonicalServerId : null,
1374
+ connectionSubjectScope:
1375
+ payload.connectionSubjectScope === "subject" ||
1376
+ payload.connectionSubjectScope === "workspace"
1377
+ ? payload.connectionSubjectScope
1378
+ : null,
1379
+ source:
1380
+ capability || setupRequest
1381
+ ? "capability"
1382
+ : event.type === "tool.auth_needed"
1383
+ ? "tool"
1384
+ : "credential",
1009
1385
  providerDomain: stringValue(payload.providerDomain),
1010
1386
  connectionId: typeof payload.connectionId === "string" ? payload.connectionId : null,
1011
1387
  authoritySource: payload.authoritySource === "host" ? "host" : null,
@@ -1020,11 +1396,17 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
1020
1396
  authorizationUrl:
1021
1397
  typeof payload.authorizationUrl === "string" ? payload.authorizationUrl : null,
1022
1398
  capability,
1399
+ setupRequest,
1023
1400
  occurredAt: event.occurredAt,
1024
1401
  });
1025
1402
  break;
1026
1403
  }
1027
1404
 
1405
+ case "usage.exhausted": {
1406
+ allowanceNotice(event, turnId);
1407
+ break;
1408
+ }
1409
+
1028
1410
  case "turn.completed": {
1029
1411
  // A standalone manual compaction uses the turn ledger for fencing and
1030
1412
  // recovery, but it is maintenance rather than a conversational turn.
@@ -1038,21 +1420,41 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
1038
1420
  break;
1039
1421
  }
1040
1422
  // Credit exhaustion arrives as a NOMINALLY completed turn (`detail:
1041
- // "insufficient OpenGeni credits"`, `segmentLimit: "budget_exhausted"`)
1423
+ // "insufficient Opengeni credits"`, `segmentLimit: "budget_exhausted"`)
1042
1424
  // — the engine ended the segment early, it did not finish the work.
1043
1425
  // Rendering it as a clean "complete" turn is a lie that leaves the
1044
1426
  // session looking healthy while every future turn silently dies, so it
1045
1427
  // projects exactly like a failed turn plus an explicit notice.
1428
+ const allowance = parseAllowanceExhaustedRefusal(payload);
1429
+ // The task's own usage limit refused the next model request. That is a
1430
+ // person's setting doing its job, not a failure or a billing problem:
1431
+ // the turn settles complete and one calm row says what stopped it.
1432
+ if (payload.segmentLimit === SESSION_USAGE_LIMIT_SEGMENT) {
1433
+ finalizeOpen(turnId, "complete", event.occurredAt);
1434
+ takeAgentResponse(turnId);
1435
+ takePendingWaitOutcome(turnId);
1436
+ items.push(turnEndItem(event, "complete", null));
1437
+ items.push(sessionUsageLimitNotice(t, event, payload));
1438
+ break;
1439
+ }
1440
+ if (allowance) {
1441
+ finalizeOpen(turnId, "complete", event.occurredAt);
1442
+ takeAgentResponse(turnId);
1443
+ takePendingWaitOutcome(turnId);
1444
+ items.push(turnEndItem(event, "failed", ALLOWANCE_TURN_END_TEXT(t)));
1445
+ allowanceNotice(event, turnId);
1446
+ break;
1447
+ }
1046
1448
  if (isCreditExhaustionPayload(payload)) {
1047
1449
  finalizeOpen(turnId, "complete", event.occurredAt);
1048
1450
  takeAgentResponse(turnId);
1049
1451
  takePendingWaitOutcome(turnId);
1050
- items.push(turnEndItem(event, "failed", CREDIT_EXHAUSTION_MESSAGE));
1452
+ items.push(turnEndItem(event, "failed", CREDIT_EXHAUSTION_MESSAGE(t)));
1051
1453
  items.push({
1052
1454
  kind: "notice",
1053
1455
  id: event.id,
1054
1456
  tone: "failed",
1055
- text: CREDIT_EXHAUSTION_MESSAGE,
1457
+ text: CREDIT_EXHAUSTION_MESSAGE(t),
1056
1458
  occurredAt: event.occurredAt,
1057
1459
  });
1058
1460
  break;
@@ -1070,10 +1472,11 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
1070
1472
  Boolean(visibleFinalOutput) && !finalOutputMirrorsCommentary;
1071
1473
  const pendingWaitOutcome = takePendingWaitOutcome(turnId);
1072
1474
  if (hasAuthoritativeFinalOutput) {
1073
- // `agent.message.completed` and `turn.completed` normally commit
1074
- // together, but legacy or partially compacted ledgers may retain only
1075
- // the terminal output receipt. Keep that authoritative response
1076
- // visible instead of leaving it trapped in raw audit data.
1475
+ // The final message normally lands as its own completion before
1476
+ // `turn.completed` (older workers commit a copy with it), but legacy or
1477
+ // partially compacted ledgers may retain only the terminal output
1478
+ // receipt. Keep that authoritative response visible instead of
1479
+ // leaving it trapped in raw audit data.
1077
1480
  if (
1078
1481
  latestAgentResponse &&
1079
1482
  !latestAgentResponse.completed &&
@@ -1081,6 +1484,12 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
1081
1484
  ) {
1082
1485
  latestAgentResponse.item.text = finalOutput;
1083
1486
  latestAgentResponse.item.streaming = false;
1487
+ if (
1488
+ latestAgentResponse.item.startedAt === undefined &&
1489
+ latestAgentResponse.item.occurredAt !== event.occurredAt
1490
+ ) {
1491
+ latestAgentResponse.item.startedAt = latestAgentResponse.item.occurredAt;
1492
+ }
1084
1493
  latestAgentResponse.item.occurredAt = event.occurredAt;
1085
1494
  const responseIndex = items.indexOf(latestAgentResponse.item);
1086
1495
  if (responseIndex >= 0 && responseIndex < items.length - 1) {
@@ -1101,6 +1510,16 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
1101
1510
  finalizeOpen(turnId, "complete", event.occurredAt);
1102
1511
  const completedTurn = turnEndItem(event, "complete", null);
1103
1512
  items.push(completedTurn);
1513
+ if (turnCompletedWithEmptyFinalReply(payload)) {
1514
+ items.push({
1515
+ kind: "notice",
1516
+ id: `${event.id}-empty-final-reply`,
1517
+ tone: "input",
1518
+ text: EMPTY_FINAL_REPLY_NOTICE,
1519
+ recordedOutcome: true,
1520
+ occurredAt: event.occurredAt,
1521
+ });
1522
+ }
1104
1523
  const hasCompletedFinalResponse =
1105
1524
  latestAgentResponse?.completed === true &&
1106
1525
  latestAgentResponse.item.phase !== "commentary" &&
@@ -1111,14 +1530,19 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
1111
1530
  completedTurn.preserveWaitResponse = true;
1112
1531
  }
1113
1532
  if (!hasAuthoritativeFinalOutput && !hasCompletedFinalResponse && pendingWaitOutcome) {
1114
- items.push({
1533
+ const notice: NoticeItem = {
1115
1534
  kind: "notice",
1116
1535
  id: `${pendingWaitOutcome.id}-visible-outcome`,
1117
1536
  tone: "waiting",
1118
- text: waitingOutcomeText(pendingWaitOutcome.reason),
1537
+ text: waitingOutcomeText(t, pendingWaitOutcome.reason),
1119
1538
  recordedOutcome: true,
1539
+ ...(pendingWorkerSessions.size > 0
1540
+ ? { waitingAgents: pendingWorkerSessions.size }
1541
+ : {}),
1120
1542
  occurredAt: pendingWaitOutcome.occurredAt,
1121
- });
1543
+ };
1544
+ items.push(notice);
1545
+ openWaitNotice = notice;
1122
1546
  }
1123
1547
  break;
1124
1548
  }
@@ -1130,32 +1554,69 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
1130
1554
  // Credit death can hide behind fields `failureMessage` doesn't read
1131
1555
  // (detail/segmentLimit), so classify the whole payload before falling
1132
1556
  // back to the generic error/message extraction.
1133
- const failureText = isCreditExhaustionPayload(payload)
1134
- ? CREDIT_EXHAUSTION_MESSAGE
1135
- : failureMessage(payload);
1557
+ const allowance = parseAllowanceExhaustedRefusal(payload);
1558
+ const failureText = allowance
1559
+ ? ALLOWANCE_TURN_END_TEXT(t)
1560
+ : isCreditExhaustionPayload(payload)
1561
+ ? CREDIT_EXHAUSTION_MESSAGE(t)
1562
+ : failureMessage(t, payload);
1136
1563
  // The TURN failed — the in-flight items did not. Chip doctrine: red is
1137
1564
  // spent once, on the turn-level outcome. Items caught mid-flight read
1138
1565
  // as calm "interrupted" (same as turn.cancelled); an item that itself
1139
1566
  // failed keeps its own failed status from its output event.
1140
1567
  finalizeOpen(turnId, "cancelled", event.occurredAt);
1141
1568
  items.push(turnEndItem(event, "failed", failureText));
1142
- if (!hadActivity) {
1569
+ // A compaction failure names its outcome and keeps the recorded
1570
+ // provider text behind Details. The turn's own failed compaction
1571
+ // landmark is the one place that shows it: it receives the recorded
1572
+ // text, and no separate notice repeats it.
1573
+ // Retry reopens the same logical turn, so only a landmark from this
1574
+ // attempt (after the turn's previous settlement) can own this failure.
1575
+ const failure = allowance ? null : presentTurnFailureText(t, failureText);
1576
+ let landmarkIndex = -1;
1577
+ if (failure?.detail !== undefined && turnId !== null) {
1578
+ // Skip the turn-end just pushed for this failure.
1579
+ for (let index = items.length - 2; index >= 0; index -= 1) {
1580
+ const item = items[index];
1581
+ if (item?.kind === "turn-end" && item.turnId === turnId) break;
1582
+ if (
1583
+ item?.kind === "context-compaction" &&
1584
+ item.turnId === turnId &&
1585
+ item.phase === "skipped" &&
1586
+ item.skipReason === "summarization_failed"
1587
+ ) {
1588
+ landmarkIndex = index;
1589
+ break;
1590
+ }
1591
+ }
1592
+ }
1593
+ const landmark = landmarkIndex >= 0 ? items[landmarkIndex] : undefined;
1594
+ if (landmark?.kind === "context-compaction" && failure?.detail !== undefined) {
1595
+ items[landmarkIndex] = { ...landmark, failureDetail: failure.detail };
1596
+ }
1597
+ if (allowance) {
1598
+ allowanceNotice(event, turnId);
1599
+ } else if (!hadActivity && !landmark) {
1143
1600
  items.push({
1144
1601
  kind: "notice",
1145
1602
  id: event.id,
1146
1603
  tone: "failed",
1147
- text: failureText ?? "The turn failed.",
1604
+ text: failure?.summary ?? t("timeline.projection.theTurnFailed"),
1605
+ ...(failure?.detail
1606
+ ? { details: { label: t("timeline.projection.details"), value: failure.detail } }
1607
+ : {}),
1148
1608
  occurredAt: event.occurredAt,
1149
1609
  });
1150
1610
  }
1151
1611
  break;
1152
1612
  }
1153
1613
 
1614
+ case "turn.superseded":
1154
1615
  case "turn.cancelled": {
1155
1616
  // A retraction of a never-started queued turn is not a turn ending —
1156
1617
  // the message was withdrawn before any work happened; show nothing.
1157
1618
  // A null turnId proves nothing, so it keeps the legacy finalize path.
1158
- if (turnId && !prescan.startedTurnIds.has(turnId)) {
1619
+ if (event.type === "turn.cancelled" && turnId && !prescan.startedTurnIds.has(turnId)) {
1159
1620
  break;
1160
1621
  }
1161
1622
  takeAgentResponse(turnId);
@@ -1168,13 +1629,52 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
1168
1629
  kind: "notice",
1169
1630
  id: event.id,
1170
1631
  tone: "cancelled",
1171
- text: "Interrupted.",
1632
+ text: t("timeline.projection.interrupted"),
1172
1633
  occurredAt: event.occurredAt,
1173
1634
  });
1174
1635
  }
1175
1636
  break;
1176
1637
  }
1177
1638
 
1639
+ case "instruction.confirmation.recovered": {
1640
+ const receipt = asRecord(payload.receipt);
1641
+ if (receipt.outcome !== "published") break;
1642
+ closeStreamingTail();
1643
+ items.push({
1644
+ kind: "notice",
1645
+ id: event.id,
1646
+ tone: "input",
1647
+ text: t("timeline.projection.yourPreviouslyApprovedWorkspaceInstruction"),
1648
+ occurredAt: event.occurredAt,
1649
+ });
1650
+ break;
1651
+ }
1652
+ case "knowledge.confirmation.recovered":
1653
+ case "knowledge.source.prepared":
1654
+ case "knowledge.source.failed": {
1655
+ const receipt = asRecord(payload.receipt);
1656
+ const outcome = event.type === "knowledge.source.failed" ? "failed" : receipt.outcome;
1657
+ if (
1658
+ (event.type !== "knowledge.confirmation.recovered" &&
1659
+ typeof payload.fileId !== "string") ||
1660
+ !["published", "pending", "rejected", "archived", "failed"].includes(String(outcome))
1661
+ )
1662
+ break;
1663
+ closeStreamingTail();
1664
+ items.push({
1665
+ kind: "knowledge",
1666
+ id: event.id,
1667
+ turnId,
1668
+ fileId: typeof payload.fileId === "string" ? payload.fileId : undefined,
1669
+ filename: typeof payload.filename === "string" ? payload.filename : undefined,
1670
+ entryId: typeof receipt.entryId === "string" ? receipt.entryId : undefined,
1671
+ status: outcome === "failed" ? "failed" : "complete",
1672
+ outcome: outcome as "published" | "pending" | "rejected" | "archived" | "failed",
1673
+ occurredAt: event.occurredAt,
1674
+ });
1675
+ break;
1676
+ }
1677
+
1178
1678
  case "memory.saved":
1179
1679
  case "memory.corrected": {
1180
1680
  // A first-party memory write is a discrete step, not streamed text, so it
@@ -1238,7 +1738,16 @@ export function buildTimeline(events: SessionEvent[]): TimelineItem[] {
1238
1738
  }
1239
1739
  }
1240
1740
 
1741
+ const sourceEventsById = new Map(events.map((event) => [event.id, event]));
1241
1742
  for (const item of items) {
1743
+ const source = sourceEventsById.get(item.id);
1744
+ const canonical = "annotationSource" in item ? item.annotationSource : undefined;
1745
+ item.sourceEvents = [
1746
+ ...(source ? [{ eventId: source.id, sequence: source.sequence }] : []),
1747
+ ...(canonical && canonical.eventId !== source?.id
1748
+ ? [{ eventId: canonical.eventId, sequence: canonical.sequence }]
1749
+ : []),
1750
+ ];
1242
1751
  if (item.kind === "agent-message") {
1243
1752
  item.text = stripOpaqueCitationTokens(item.text);
1244
1753
  }
@@ -1334,10 +1843,13 @@ function humanInputQuestions(value: unknown): HumanInputQuestion[] {
1334
1843
  if (
1335
1844
  !id ||
1336
1845
  !prompt ||
1337
- (kind !== "text" && kind !== "single_select" && kind !== "multi_select")
1846
+ (kind !== "text" && kind !== "single_select" && kind !== "multi_select" && kind !== "secret")
1338
1847
  ) {
1339
1848
  return [];
1340
1849
  }
1850
+ // Secret questions keep their spec (names and hints only; never a value).
1851
+ const secret = kind === "secret" ? humanInputSecretSpec(question.secret) : null;
1852
+ if (kind === "secret" && !secret) return [];
1341
1853
  const options = Array.isArray(question.options)
1342
1854
  ? question.options.map(asRecord).flatMap((option) => {
1343
1855
  const optionId = stringValue(option.id);
@@ -1357,20 +1869,54 @@ function humanInputQuestions(value: unknown): HumanInputQuestion[] {
1357
1869
  options,
1358
1870
  required: question.required === true,
1359
1871
  allowOther: question.allowOther === true,
1872
+ ...(secret ? { secret } : {}),
1360
1873
  },
1361
1874
  ];
1362
1875
  });
1363
1876
  }
1364
1877
 
1878
+ function humanInputSecretSpec(value: unknown): HumanInputSecretSpec | null {
1879
+ const spec = asRecord(value);
1880
+ const item = stringValue(spec.item);
1881
+ if (!item) return null;
1882
+ return spec as unknown as HumanInputSecretSpec;
1883
+ }
1884
+
1885
+ function humanInputSecretResult(value: unknown): HumanInputSecretAnswerResult | null {
1886
+ if (value === undefined || value === null) return null;
1887
+ const result = asRecord(value);
1888
+ const reference = stringValue(result.reference);
1889
+ const vaultName = stringValue(result.vaultName);
1890
+ const itemName = stringValue(result.itemName);
1891
+ const saveTo = result.saveTo;
1892
+ if (
1893
+ !reference ||
1894
+ !vaultName ||
1895
+ !itemName ||
1896
+ (saveTo !== "user" && saveTo !== "task" && saveTo !== "workspace")
1897
+ ) {
1898
+ return null;
1899
+ }
1900
+ return {
1901
+ reference,
1902
+ username: stringValue(result.username) || null,
1903
+ vaultName,
1904
+ itemName,
1905
+ saveTo,
1906
+ };
1907
+ }
1908
+
1365
1909
  function humanInputAnswer(value: Record<string, unknown>): HumanInputAnswer | null {
1366
1910
  const questionId = stringValue(value.questionId);
1367
1911
  if (!questionId) return null;
1912
+ const secret = humanInputSecretResult(value.secret);
1368
1913
  return {
1369
1914
  questionId,
1370
1915
  values: Array.isArray(value.values)
1371
1916
  ? value.values.filter((answer): answer is string => typeof answer === "string")
1372
1917
  : [],
1373
1918
  ...(typeof value.other === "string" && value.other ? { other: value.other } : {}),
1919
+ ...(secret ? { secret } : {}),
1374
1920
  };
1375
1921
  }
1376
1922
 
@@ -1389,6 +1935,7 @@ function humanInputAnswerSummary(
1389
1935
  label: question?.label || question?.prompt || fallbackLabel,
1390
1936
  prompt: question?.prompt || fallbackLabel,
1391
1937
  values,
1938
+ ...(answer.secret ? { secret: answer.secret } : {}),
1392
1939
  };
1393
1940
  }
1394
1941
 
@@ -1452,8 +1999,16 @@ export function stripOpaqueCitationTokens(text: string): string {
1452
1999
  return text.replace(/\s*cite(?:[^]+)+/gu, "");
1453
2000
  }
1454
2001
 
2002
+ /**
2003
+ * The turn summary's short outcome for a usage ceiling. The adjacent notice row
2004
+ * carries who can raise it and when it resets (and is host-customizable), so
2005
+ * the summary line stays a neutral fact instead of repeating remedy prose.
2006
+ */
2007
+ const ALLOWANCE_TURN_END_TEXT = (t: OpenGeniText) => t("timeline.projection.usageLimitReached");
2008
+
1455
2009
  /** The turn-end payload shape, as `isCreditExhaustion` wants it. */
1456
2010
  function isCreditExhaustionPayload(payload: Record<string, unknown>): boolean {
2011
+ if (payload.code === "allowance_exhausted") return false;
1457
2012
  return isCreditExhaustion({
1458
2013
  error: typeof payload.error === "string" ? payload.error : null,
1459
2014
  detail: typeof payload.detail === "string" ? payload.detail : null,
@@ -1504,12 +2059,16 @@ export function sessionStatusFromEvents(events: SessionEvent[]): SessionStatus |
1504
2059
  non-user span folds behind a turn group, with activity blocks nested inside.
1505
2060
  -------------------------------------------------------------------------- */
1506
2061
 
2062
+ /** Work items: every activity kind except assistant commentary. */
2063
+ type WorkActivityItem = Exclude<ActivityItem, AgentMessageItem>;
2064
+
1507
2065
  /**
1508
2066
  * Whether an item clusters into an activity block. A `switch` (not a stringly-
1509
2067
  * typed set) so adding an {@link ActivityItem} kind is a compile-time prompt to
1510
- * decide its grouping — and it narrows `item` to `ActivityItem` with no cast.
2068
+ * decide its grouping, and it narrows `item` to a work item with no cast.
2069
+ * Assistant prose stays outside activity clusters.
1511
2070
  */
1512
- function isActivityItem(item: TimelineItem): item is ActivityItem {
2071
+ function isActivityItem(item: TimelineItem): item is WorkActivityItem {
1513
2072
  switch (item.kind) {
1514
2073
  case "reasoning":
1515
2074
  case "tool-call":
@@ -1517,6 +2076,7 @@ function isActivityItem(item: TimelineItem): item is ActivityItem {
1517
2076
  case "sandbox":
1518
2077
  case "startup-phase":
1519
2078
  case "memory":
2079
+ case "knowledge":
1520
2080
  case "fleet-decision":
1521
2081
  return true;
1522
2082
  default:
@@ -1524,9 +2084,23 @@ function isActivityItem(item: TimelineItem): item is ActivityItem {
1524
2084
  }
1525
2085
  }
1526
2086
 
1527
- export function groupTimeline(items: TimelineItem[]): TimelineGroup[] {
2087
+ export type GroupTimelineOptions = {
2088
+ /** Readable assistant prose with an independent work summary for each turn. */
2089
+ readableTurns?: boolean;
2090
+ /** @deprecated Use readableTurns. Cross-turn exchange folding has been removed. */
2091
+ foldExchanges?: boolean;
2092
+ };
2093
+
2094
+ export function groupTimeline(
2095
+ t: OpenGeniText,
2096
+ items: TimelineItem[],
2097
+ options: GroupTimelineOptions = {},
2098
+ ): TimelineGroup[] {
2099
+ if (options.readableTurns || options.foldExchanges) return groupReadableTurns(t, items);
1528
2100
  const groups: TimelineGroup[] = [];
1529
2101
  for (const item of items) {
2102
+ // A recovered capacity wait is over; it leaves no warning behind.
2103
+ if (item.kind === "notice" && item.capacityWait && item.resolvedAt) continue;
1530
2104
  if (isActivityItem(item)) {
1531
2105
  const open = groups[groups.length - 1];
1532
2106
  if (open?.kind === "activity" && open.outcome === undefined) {
@@ -1550,6 +2124,647 @@ export function groupTimeline(items: TimelineItem[]): TimelineGroup[] {
1550
2124
  return groups;
1551
2125
  }
1552
2126
 
2127
+ /** Live prose stays primary; settled progress joins its own turn's work history. */
2128
+ function groupReadableTurns(t: OpenGeniText, items: TimelineItem[]): TimelineGroup[] {
2129
+ type Work = Extract<TimelineGroup, { kind: "activity" }>;
2130
+ let groups: TimelineGroup[] = [];
2131
+ const turns = new Map<string, Work>();
2132
+ // Turn identity and settlement exist even when a final-only turn has no
2133
+ // disclosure. A late receipt must not become a new turn or revive its clock.
2134
+ const seenTurns = new Set<string>();
2135
+ const settlements = new Map<
2136
+ string,
2137
+ { endedAt: string; outcome?: Work["outcome"]; failureText?: string }
2138
+ >();
2139
+ const compactionTurns = new Map<ContextCompactionItem, string>();
2140
+ const messages = new Map<string, AgentMessageItem[]>();
2141
+ // Capacity waits per turn: their spans are not work, and a live one is
2142
+ // carried by the turn's work row instead of a separate warning.
2143
+ const capacityPauses = new Map<string, Array<{ startedAt: string; endedAt?: string }>>();
2144
+ const liveCapacityWaits = new Map<string, NoticeItem>();
2145
+ const inputs = new Map<string, Extract<TimelineItem, { kind: "machine-input-batch" }>>();
2146
+ const itemOrder = new Map(items.map((item, index) => [item.id, index]));
2147
+ // Turns that answer a person's message: the first turn after it, and a live
2148
+ // turn it steered. Their replies are never folded as mere progress.
2149
+ const answersPerson = new Set<string>();
2150
+ let personAwaitingTurn = false;
2151
+ // A live turn a person's message may have steered. If it keeps working after
2152
+ // the message, the steer was absorbed and no later turn inherits it; if it is
2153
+ // superseded instead, the next turn answers the person.
2154
+ let steeredTurn: string | undefined;
2155
+ let legacyTurn = "start";
2156
+ let currentTurn = legacyTurn;
2157
+ for (const item of items) {
2158
+ if (item.kind === "user-message") {
2159
+ legacyTurn = item.id;
2160
+ personAwaitingTurn = true;
2161
+ steeredTurn = undefined;
2162
+ if (seenTurns.has(currentTurn) && !settlements.has(currentTurn)) {
2163
+ answersPerson.add(currentTurn);
2164
+ steeredTurn = currentTurn;
2165
+ }
2166
+ }
2167
+ // A capacity wait belongs to the turn it blocks, even before that turn's
2168
+ // first step.
2169
+ const itemTurnId =
2170
+ item.kind === "notice" && item.capacityWait
2171
+ ? item.capacityWait.turnId
2172
+ : "turnId" in item
2173
+ ? item.turnId
2174
+ : null;
2175
+ const key = itemTurnId || legacyTurn;
2176
+ if (
2177
+ steeredTurn !== undefined &&
2178
+ key === steeredTurn &&
2179
+ (isActivityItem(item) || (item.kind === "agent-message" && item.text.trim()))
2180
+ ) {
2181
+ personAwaitingTurn = false;
2182
+ steeredTurn = undefined;
2183
+ }
2184
+ // Legacy work still establishes a boundary using its prompt key.
2185
+ // A human message alone does not: it may be steering the existing turn.
2186
+ if (itemTurnId || isActivityItem(item) || (item.kind === "agent-message" && item.text.trim())) {
2187
+ if (key !== currentTurn && !seenTurns.has(key)) {
2188
+ const previous = turns.get(currentTurn);
2189
+ if (!settlements.has(currentTurn)) {
2190
+ settlements.set(currentTurn, { endedAt: item.occurredAt });
2191
+ }
2192
+ if (previous?.work && !previous.work.endedAt) previous.work.endedAt = item.occurredAt;
2193
+ currentTurn = key;
2194
+ if (personAwaitingTurn) answersPerson.add(key);
2195
+ personAwaitingTurn = false;
2196
+ steeredTurn = undefined;
2197
+ }
2198
+ seenTurns.add(key);
2199
+ }
2200
+ const workForTurn = () => {
2201
+ let group = turns.get(key);
2202
+ const firstMessage = messages.get(key)?.[0];
2203
+ const messageStart = firstMessage?.startedAt ?? firstMessage?.occurredAt;
2204
+ const activityStart =
2205
+ item.kind === "startup-phase"
2206
+ ? (item.loadingStartedAt ?? item.occurredAt)
2207
+ : item.occurredAt;
2208
+ const startedAt =
2209
+ messageStart && Date.parse(messageStart) < Date.parse(activityStart)
2210
+ ? messageStart
2211
+ : activityStart;
2212
+ if (!group) {
2213
+ const settlement = settlements.get(key);
2214
+ group = {
2215
+ kind: "activity",
2216
+ id: `work-${key}`,
2217
+ items: [],
2218
+ work: { startedAt, details: [] },
2219
+ };
2220
+ if (settlement) {
2221
+ group.work!.endedAt = settlement.endedAt;
2222
+ if (settlement.outcome) group.outcome = settlement.outcome;
2223
+ if (settlement.failureText) group.failureText = settlement.failureText;
2224
+ }
2225
+ turns.set(key, group);
2226
+ const firstMessageIndex =
2227
+ settlement && firstMessage
2228
+ ? groups.findIndex((entry) => entry.kind === "item" && entry.item === firstMessage)
2229
+ : -1;
2230
+ if (firstMessageIndex >= 0) groups.splice(firstMessageIndex, 0, group);
2231
+ else groups.push(group);
2232
+ } else if (Date.parse(startedAt) < Date.parse(group.work!.startedAt)) {
2233
+ // Completion-only startup receipts can reveal an earlier phase start
2234
+ // after another activity has already established the work row.
2235
+ group.work!.startedAt = startedAt;
2236
+ }
2237
+ return group;
2238
+ };
2239
+ if (isActivityItem(item)) {
2240
+ const group = workForTurn();
2241
+ group.items.push(item);
2242
+ const previous = group.work!.details.at(-1);
2243
+ const preparing = (entry: ActivityItem) =>
2244
+ entry.kind === "startup-phase" || (entry.kind === "reasoning" && !entry.text.trim());
2245
+ if (
2246
+ preparing(item) &&
2247
+ previous?.kind === "activity" &&
2248
+ previous.items.every(preparing) &&
2249
+ previous.items.at(-1) === items[(itemOrder.get(item.id) ?? 0) - 1]
2250
+ )
2251
+ previous.items.push(item);
2252
+ else
2253
+ group.work!.details.push({ kind: "activity", id: `work-item-${item.id}`, items: [item] });
2254
+ delete group.work!.waiting;
2255
+ } else if (item.kind === "notice" && item.capacityWait) {
2256
+ const pauses = capacityPauses.get(key) ?? [];
2257
+ pauses.push({
2258
+ startedAt: item.occurredAt,
2259
+ ...(item.resolvedAt ? { endedAt: item.resolvedAt } : {}),
2260
+ });
2261
+ capacityPauses.set(key, pauses);
2262
+ if (!item.resolvedAt) {
2263
+ if (settlements.has(key)) groups.push({ kind: "item", item });
2264
+ else {
2265
+ workForTurn();
2266
+ liveCapacityWaits.set(key, item);
2267
+ }
2268
+ }
2269
+ } else if (item.kind === "turn-end") {
2270
+ if (!item.resumedAt) {
2271
+ settlements.set(key, {
2272
+ endedAt: item.occurredAt,
2273
+ outcome: item.outcome,
2274
+ ...(item.failureText ? { failureText: item.failureText } : {}),
2275
+ });
2276
+ }
2277
+ const group = turns.get(key);
2278
+ if (group?.work) {
2279
+ if (item.resumedAt) {
2280
+ group.work.details.push({
2281
+ kind: "item",
2282
+ item: {
2283
+ kind: "notice",
2284
+ id: item.id,
2285
+ tone: "failed",
2286
+ text: item.failureText ?? t("timeline.projection.theTurnFailedBeforeRetrying"),
2287
+ occurredAt: item.occurredAt,
2288
+ },
2289
+ });
2290
+ continue;
2291
+ }
2292
+ group.outcome = item.outcome;
2293
+ if (item.failureText) group.failureText = item.failureText;
2294
+ group.work.endedAt = item.occurredAt;
2295
+ }
2296
+ } else if (item.kind === "context-compaction" && item.phase === "compacted") {
2297
+ // A maintenance checkpoint alone is not conversational work. Resolve its
2298
+ // attachment after real activity has established this turn's work row.
2299
+ compactionTurns.set(item, key);
2300
+ groups.push({ kind: "item", item });
2301
+ } else if (
2302
+ item.kind === "machine-input-batch" &&
2303
+ item.members.every((member) => ROUTINE_MACHINE_INPUT_KINDS.has(member.kind))
2304
+ ) {
2305
+ const previous = inputs.get(key);
2306
+ if (previous) {
2307
+ previous.members.push(
2308
+ ...item.members.filter((member) => !previous.members.some((old) => old.id === member.id)),
2309
+ );
2310
+ previous.sourceEvents = [...(previous.sourceEvents ?? []), ...(item.sourceEvents ?? [])];
2311
+ } else {
2312
+ const batch = { ...item, compact: true, members: [...item.members] };
2313
+ inputs.set(key, batch);
2314
+ groups.push({ kind: "item", item: batch });
2315
+ }
2316
+ } else if (
2317
+ item.kind === "worker-completion" ||
2318
+ (item.kind === "goal" && item.action === "continuation")
2319
+ ) {
2320
+ const group = turns.get(currentTurn);
2321
+ if (group?.work) group.work.details.push({ kind: "item", item });
2322
+ else groups.push({ kind: "item", item });
2323
+ } else {
2324
+ const current = turns.get(currentTurn)?.work;
2325
+ // A live approval wait is carried by the turn header ("Waiting for you")
2326
+ // and decided in the host's approval surface; a second in-timeline banner
2327
+ // only repeats it. Once resolved it returns as the quiet recorded marker.
2328
+ const liveApprovalWait =
2329
+ item.kind === "notice" &&
2330
+ item.tone === "waiting" &&
2331
+ !item.recordedOutcome &&
2332
+ !item.resolvedAt &&
2333
+ item.approval === true &&
2334
+ current !== undefined &&
2335
+ !current.endedAt;
2336
+ // Likewise the live "waiting on you" divider: the open turn's header
2337
+ // already reads "Waiting for you · <elapsed>". It returns, resolved, as
2338
+ // the "work resumed" divider once the session runs again.
2339
+ const liveStatusWait =
2340
+ item.kind === "session-status" &&
2341
+ item.status === "requires_action" &&
2342
+ !item.blocked &&
2343
+ !item.resolvedAt &&
2344
+ current !== undefined &&
2345
+ !current.endedAt;
2346
+ if (!liveApprovalWait && !liveStatusWait) groups.push({ kind: "item", item });
2347
+ if (current && !current.endedAt) {
2348
+ if (
2349
+ item.kind === "notice" &&
2350
+ item.tone === "waiting" &&
2351
+ !item.recordedOutcome &&
2352
+ !item.resolvedAt
2353
+ ) {
2354
+ current.waiting = {
2355
+ label:
2356
+ item.approval === true
2357
+ ? t("timeline.projection.waitingForYou")
2358
+ : t("timeline.projection.waiting"),
2359
+ since: item.occurredAt,
2360
+ };
2361
+ } else if (
2362
+ item.kind === "session-status" &&
2363
+ item.status === "requires_action" &&
2364
+ !item.blocked &&
2365
+ !item.resolvedAt
2366
+ ) {
2367
+ current.waiting = {
2368
+ label: t("timeline.projection.waitingForYou"),
2369
+ since: item.occurredAt,
2370
+ };
2371
+ } else if (
2372
+ item.kind === "session-status" &&
2373
+ ["paused", "cancelled", "failed"].includes(item.status) &&
2374
+ !item.resolvedAt
2375
+ ) {
2376
+ current.endedAt = item.occurredAt;
2377
+ delete current.waiting;
2378
+ }
2379
+ }
2380
+ if (item.kind === "agent-message" && item.text.trim()) {
2381
+ const prose = messages.get(key) ?? [];
2382
+ prose.push(item);
2383
+ messages.set(key, prose);
2384
+ // A text-only turn still has one overall activity surface. An explicit
2385
+ // final-only response does not manufacture an empty work disclosure.
2386
+ if (
2387
+ (item.phase !== "final_answer" || prose.length > 1) &&
2388
+ (turns.has(key) || !settlements.has(key))
2389
+ )
2390
+ workForTurn();
2391
+ }
2392
+ }
2393
+ }
2394
+ for (const [key, group] of turns) {
2395
+ const work = group.work!;
2396
+ const live = liveCapacityWaits.get(key);
2397
+ // Re-assert after the loop: a late receipt for the blocked turn must not
2398
+ // turn "Limit reached" back into "Working" while the wait is still open.
2399
+ if (live?.capacityWait && !work.endedAt) {
2400
+ work.waiting = {
2401
+ label: live.capacityWait.label,
2402
+ since: live.occurredAt,
2403
+ detail: live.capacityWait.detail,
2404
+ // Its span is not work and may last until a quota resets: no clock.
2405
+ untimed: true,
2406
+ };
2407
+ }
2408
+ const pausedMs = (capacityPauses.get(key) ?? []).reduce((total, pause) => {
2409
+ if (!pause.endedAt) return total;
2410
+ const start = Math.max(Date.parse(work.startedAt), Date.parse(pause.startedAt));
2411
+ const end = Math.min(
2412
+ work.endedAt ? Date.parse(work.endedAt) : Number.POSITIVE_INFINITY,
2413
+ Date.parse(pause.endedAt),
2414
+ );
2415
+ return Number.isFinite(start) && Number.isFinite(end) && end > start
2416
+ ? total + end - start
2417
+ : total;
2418
+ }, 0);
2419
+ if (pausedMs > 0) work.pausedMs = pausedMs;
2420
+ }
2421
+ groups = groups.filter((entry) => {
2422
+ if (entry.kind !== "item" || entry.item.kind !== "context-compaction") return true;
2423
+ const key = compactionTurns.get(entry.item);
2424
+ const work = key === undefined ? undefined : turns.get(key)?.work;
2425
+ if (!work) return true;
2426
+ work.details.push(entry);
2427
+ return false;
2428
+ });
2429
+ // A declared answer starts the response clock immediately. Without a phase,
2430
+ // only settlement identifies the last response; text length never does.
2431
+ const beforeRows = new Map<TimelineGroup, Work>();
2432
+ const afterRows = new Map<TimelineGroup, Work>();
2433
+ const movedRows = new Set<Work>();
2434
+ const foldedProse = new Set<AgentMessageItem>();
2435
+ const positions = new Map<TimelineGroup | TimelineItem, number>();
2436
+ const nextBoundary = new Map<Work, number>();
2437
+ let boundary = groups.length;
2438
+ for (let index = groups.length - 1; index >= 0; index -= 1) {
2439
+ const entry = groups[index]!;
2440
+ positions.set(entry.kind === "item" ? entry.item : entry, index);
2441
+ if (entry.kind === "activity" && entry.work) {
2442
+ nextBoundary.set(entry, boundary);
2443
+ boundary = index;
2444
+ } else if (
2445
+ entry.kind === "item" &&
2446
+ (entry.item.kind === "user-message" || entry.item.kind === "machine-input-batch")
2447
+ ) {
2448
+ boundary = index;
2449
+ }
2450
+ }
2451
+ for (const [key, group] of turns) {
2452
+ const prose = messages.get(key) ?? [];
2453
+ const settledAt = group.work!.endedAt;
2454
+ const responseCandidates = settledAt
2455
+ ? prose.filter(
2456
+ (message) => Date.parse(message.startedAt ?? message.occurredAt) <= Date.parse(settledAt),
2457
+ )
2458
+ : prose;
2459
+ const response =
2460
+ responseCandidates.filter((message) => message.phase === "final_answer").at(-1) ??
2461
+ (settledAt
2462
+ ? (responseCandidates.at(-1) ??
2463
+ prose.filter((message) => message.phase === "final_answer").at(-1))
2464
+ : undefined);
2465
+ const responses = new Set<AgentMessageItem>(response ? [response] : []);
2466
+ // A turn that answers a person but ends with only commentary (typically by
2467
+ // yielding to a wait) has no single authoritative reply. Its first message
2468
+ // is the immediate answer and its last is the latest word; only the
2469
+ // progress narration between them folds.
2470
+ const firstCandidate = responseCandidates[0];
2471
+ if (
2472
+ settledAt &&
2473
+ firstCandidate &&
2474
+ answersPerson.has(key) &&
2475
+ responseCandidates.every((message) => message.phase === "commentary")
2476
+ ) {
2477
+ responses.add(firstCandidate);
2478
+ }
2479
+ if (settledAt) {
2480
+ for (const message of responseCandidates) {
2481
+ // Markdown image syntax also carries retained video/audio previews.
2482
+ // Keep potential primary media visible rather than guessing whether a
2483
+ // partial/reference-style embed can safely disappear into history.
2484
+ if (responses.has(message) || message.text.includes("![")) continue;
2485
+ foldedProse.add(message);
2486
+ group.work!.details.push({ kind: "item", item: message });
2487
+ }
2488
+ } else {
2489
+ // Live progress stays primary above the work row, and is also listed in
2490
+ // the work history so an expanded disclosure reads like the settled one.
2491
+ // The timeline folds the outside copies only while that disclosure is open.
2492
+ for (const message of prose) {
2493
+ if (message.phase === "final_answer" || message.text.includes("![")) continue;
2494
+ group.work!.details.push({ kind: "item", item: message });
2495
+ (group.work!.liveNoteIds ??= []).push(message.id);
2496
+ }
2497
+ }
2498
+ // Preserve event chronology, not completion timestamps or activity kinds.
2499
+ group.work!.details.sort((a, b) => {
2500
+ const first = (entry: TimelineGroup) =>
2501
+ entry.kind === "item"
2502
+ ? entry.item.id
2503
+ : entry.kind === "activity"
2504
+ ? entry.items[0]?.id
2505
+ : undefined;
2506
+ return (itemOrder.get(first(a) ?? "") ?? 0) - (itemOrder.get(first(b) ?? "") ?? 0);
2507
+ });
2508
+ if (response) {
2509
+ const responseAt = response.startedAt ?? response.occurredAt;
2510
+ // A delayed completion-only receipt cannot extend a settled work clock.
2511
+ group.work!.responseStartedAt =
2512
+ settledAt && Date.parse(responseAt) > Date.parse(settledAt) ? settledAt : responseAt;
2513
+ // A late completion may belong to an older turn. Keep its work at its
2514
+ // original boundary rather than moving it across a newer turn's input.
2515
+ // The work row leads the first visible reply of the turn.
2516
+ const anchor = Math.min(
2517
+ ...[...responses].map((message) => positions.get(message) ?? groups.length),
2518
+ );
2519
+ if (settledAt && anchor < (nextBoundary.get(group) ?? groups.length)) {
2520
+ beforeRows.set(groups[anchor]!, group);
2521
+ movedRows.add(group);
2522
+ }
2523
+ }
2524
+ if (!settledAt) {
2525
+ // Keep the same row at the tail of this turn, after every live progress
2526
+ // message and attention surface, without crossing a newer input/turn.
2527
+ // A visible steer is not a turn boundary when later prose still belongs
2528
+ // to this turn. New input without that evidence remains a hard boundary.
2529
+ const lastProseIndex = Math.max(...prose.map((message) => positions.get(message) ?? -1));
2530
+ let tailIndex = groups.length - 1;
2531
+ for (let index = (positions.get(group) ?? 0) + 1; index <= tailIndex; index += 1) {
2532
+ const entry = groups[index]!;
2533
+ if (
2534
+ (entry.kind === "activity" && entry.work) ||
2535
+ (entry.kind === "item" &&
2536
+ (("turnId" in entry.item && entry.item.turnId && entry.item.turnId !== key) ||
2537
+ (index > lastProseIndex &&
2538
+ (entry.item.kind === "user-message" || entry.item.kind === "machine-input-batch"))))
2539
+ ) {
2540
+ tailIndex = index - 1;
2541
+ break;
2542
+ }
2543
+ }
2544
+ const tail = groups[tailIndex];
2545
+ if (tail && tail !== group) {
2546
+ afterRows.set(tail, group);
2547
+ movedRows.add(group);
2548
+ }
2549
+ }
2550
+ }
2551
+ // The work of every turn that answers a person stays visible even when it
2552
+ // said nothing; quiet-cycle folding must never take it.
2553
+ const personWork = new Set<TimelineGroup>(
2554
+ [...answersPerson].flatMap((key) => {
2555
+ const work = turns.get(key);
2556
+ return work ? [work] : [];
2557
+ }),
2558
+ );
2559
+ return compactQuietCycles(
2560
+ groups.flatMap((group) => {
2561
+ if (group.kind === "activity" && movedRows.has(group)) return [];
2562
+ const hidden =
2563
+ group.kind === "item" && group.item.kind === "agent-message" && foldedProse.has(group.item);
2564
+ const before = beforeRows.get(group);
2565
+ const after = afterRows.get(group);
2566
+ return [...(before ? [before] : []), ...(hidden ? [] : [group]), ...(after ? [after] : [])];
2567
+ }),
2568
+ personWork,
2569
+ );
2570
+ }
2571
+
2572
+ type WorkGroup = Extract<TimelineGroup, { kind: "activity" }> & {
2573
+ work: NonNullable<Extract<TimelineGroup, { kind: "activity" }>["work"]>;
2574
+ };
2575
+
2576
+ /**
2577
+ * Settled, successful work whose turn left no visible reply, image or blocker.
2578
+ * A failure it recovered from, a failed startup phase or a context compaction
2579
+ * is something to see, so that work is not quiet either.
2580
+ */
2581
+ function isQuietWork(group: TimelineGroup): group is WorkGroup {
2582
+ if (group.kind !== "activity" || !group.work?.endedAt || group.work.waiting) return false;
2583
+ if (group.work.cycles || (group.outcome && group.outcome !== "complete")) return false;
2584
+ if (
2585
+ group.items.some(
2586
+ (item) =>
2587
+ item.kind === "startup-phase" && (item.status === "failed" || item.status === "cancelled"),
2588
+ )
2589
+ ) {
2590
+ return false;
2591
+ }
2592
+ const quiet = (entry: TimelineGroup): boolean =>
2593
+ entry.kind === "item"
2594
+ ? entry.item.kind !== "auth-needed" &&
2595
+ entry.item.kind !== "context-compaction" &&
2596
+ entry.item.kind !== "human-input" &&
2597
+ !(entry.item.kind === "notice" && entry.item.tone !== "waiting") &&
2598
+ !(entry.item.kind === "agent-message" && entry.item.text.includes("!["))
2599
+ : entry.kind === "activity"
2600
+ ? isQuietDetail(entry, quiet)
2601
+ : false;
2602
+ return !publishesOutput(group) && group.work.details.every(quiet);
2603
+ }
2604
+
2605
+ function isQuietDetail(
2606
+ group: Extract<TimelineGroup, { kind: "activity" }>,
2607
+ quiet: (entry: TimelineGroup) => boolean,
2608
+ ): boolean {
2609
+ return (
2610
+ (!group.outcome || group.outcome === "complete") && (group.work?.details ?? []).every(quiet)
2611
+ );
2612
+ }
2613
+
2614
+ /**
2615
+ * Work that generated an image or published a file produced output worth
2616
+ * seeing. Checked by tool name only, so the projection stays free of the
2617
+ * renderer's image presentation rules.
2618
+ */
2619
+ function publishesOutput(group: TimelineGroup): boolean {
2620
+ if (group.kind !== "activity") return false;
2621
+ return (
2622
+ group.items.some((item) => {
2623
+ if (item.kind !== "tool-call") return false;
2624
+ const name = mcpToolLeaf(item.name);
2625
+ return (
2626
+ name === "generate_image" ||
2627
+ name === "image_generation_call" ||
2628
+ name === "sandbox_file_publish"
2629
+ );
2630
+ }) || (group.work?.details ?? []).some(publishesOutput)
2631
+ );
2632
+ }
2633
+
2634
+ /**
2635
+ * Whether the work at `index` follows a person's message or answer with only
2636
+ * routine input in between. Complements the turn bookkeeping for legacy rows.
2637
+ */
2638
+ function answersPersonAt(groups: TimelineGroup[], index: number): boolean {
2639
+ for (let cursor = index - 1; cursor >= 0; cursor -= 1) {
2640
+ const group = groups[cursor]!;
2641
+ if (
2642
+ group.kind === "item" &&
2643
+ (group.item.kind === "user-message" || group.item.kind === "human-input")
2644
+ ) {
2645
+ return true;
2646
+ }
2647
+ if (!isRoutineInput(group)) return false;
2648
+ }
2649
+ return false;
2650
+ }
2651
+
2652
+ /**
2653
+ * A routine machine input (agent update, child result, wait timeout, ...). An
2654
+ * agent that failed, paused or needs action is news, not routine.
2655
+ */
2656
+ function isRoutineInput(group: TimelineGroup): boolean {
2657
+ return (
2658
+ group.kind === "item" &&
2659
+ group.item.kind === "machine-input-batch" &&
2660
+ !!group.item.compact &&
2661
+ group.item.members.every(
2662
+ (member) =>
2663
+ member.kind !== "child_paused" &&
2664
+ member.classification !== "failure" &&
2665
+ // A parent's direction is always recorded as action_required for the
2666
+ // agent; it is routine orchestration, not something a person must do.
2667
+ (member.classification !== "action_required" || member.kind === "agent_steer_instruction"),
2668
+ )
2669
+ );
2670
+ }
2671
+
2672
+ /** A recorded wait that later input already ended. */
2673
+ function isFinishedWait(group: TimelineGroup): group is Extract<TimelineGroup, { kind: "item" }> & {
2674
+ item: NoticeItem;
2675
+ } {
2676
+ return (
2677
+ group.kind === "item" &&
2678
+ group.item.kind === "notice" &&
2679
+ group.item.tone === "waiting" &&
2680
+ !!group.item.recordedOutcome &&
2681
+ !!group.item.waitEndedAt
2682
+ );
2683
+ }
2684
+
2685
+ /**
2686
+ * Long orchestration runs repeat "agent update / worked / waited" many times
2687
+ * without saying anything. Fold two or more such consecutive quiet cycles into
2688
+ * one work row: "7 updates over 6h 12m", with the latest wait reason under it.
2689
+ * Expanding it shows the original rows unchanged. Visible replies, people's
2690
+ * messages, failures, approvals, live work and the current wait are never folded
2691
+ * and end a run.
2692
+ */
2693
+ function compactQuietCycles(
2694
+ groups: TimelineGroup[],
2695
+ personWork: ReadonlySet<TimelineGroup>,
2696
+ ): TimelineGroup[] {
2697
+ const result: TimelineGroup[] = [];
2698
+ let index = 0;
2699
+ while (index < groups.length) {
2700
+ // A run starts at routine input, never at a leading wait (it belongs to
2701
+ // the reply before it) or at bare work (it belongs to the visible row
2702
+ // before it, such as an agent's failure). Later cycles may lack input,
2703
+ // for example after a wait timeout.
2704
+ let end = index;
2705
+ let lastCycleEnd = index;
2706
+ let cycles = 0;
2707
+ while (end < groups.length) {
2708
+ const input = isRoutineInput(groups[end]!) ? end : -1;
2709
+ if (input < 0 && cycles === 0) break;
2710
+ const workIndex = input >= 0 ? end + 1 : end;
2711
+ const work = groups[workIndex];
2712
+ if (!work || !isQuietWork(work)) break;
2713
+ // Work that follows a person's message is that message's turn, even
2714
+ // when it said nothing; it stays visible.
2715
+ if (personWork.has(work) || answersPersonAt(groups, workIndex)) break;
2716
+ const next = groups[workIndex + 1];
2717
+ // Work directly followed by its reply is not quiet.
2718
+ if (next?.kind === "item" && next.item.kind === "agent-message") break;
2719
+ if (!next || !isFinishedWait(next)) break;
2720
+ cycles += 1;
2721
+ end = workIndex + 2;
2722
+ lastCycleEnd = end;
2723
+ }
2724
+ if (cycles < 2) {
2725
+ result.push(groups[index]!);
2726
+ index += 1;
2727
+ continue;
2728
+ }
2729
+ const run = groups.slice(index, lastCycleEnd);
2730
+ const works = run.filter((group): group is WorkGroup => isQuietWork(group));
2731
+ const waits = run.filter(isFinishedWait);
2732
+ const first = works[0]!;
2733
+ const lastWait = waits.at(-1)!;
2734
+ result.push({
2735
+ kind: "activity",
2736
+ id: `cycles-${first.id}`,
2737
+ items: works.flatMap((group) => group.items),
2738
+ outcome: "complete",
2739
+ work: {
2740
+ startedAt: first.work.startedAt,
2741
+ endedAt: lastWait.item.waitEndedAt!,
2742
+ details: run,
2743
+ cycles: {
2744
+ count: cycles,
2745
+ ...(lastWait.item.text.trim() ? { summary: lastWait.item.text.trim() } : {}),
2746
+ },
2747
+ },
2748
+ });
2749
+ index = lastCycleEnd;
2750
+ }
2751
+ return result;
2752
+ }
2753
+
2754
+ /** Machine inputs that continue the current exchange rather than start one. */
2755
+ const ROUTINE_MACHINE_INPUT_KINDS: ReadonlySet<MachineInputMember["kind"]> = new Set([
2756
+ "goal_continuation",
2757
+ "background_command_result",
2758
+ "session_wait_timeout",
2759
+ "agent_message",
2760
+ "agent_steer_instruction",
2761
+ "child_terminal_result",
2762
+ "child_requires_action_resolved",
2763
+ "child_paused",
2764
+ "child_waiting_capacity",
2765
+ "child_progress",
2766
+ ]);
2767
+
1553
2768
  /* --- helpers ---------------------------------------------------------------- */
1554
2769
 
1555
2770
  type TurnAnchorPrescan = {
@@ -1561,6 +2776,22 @@ type TurnAnchorPrescan = {
1561
2776
  startedTurnIds: Set<string>;
1562
2777
  };
1563
2778
 
2779
+ /** Navigation uses the same queue/start/withdrawal rules as transcript ordering. */
2780
+ export function timelineQuestionPlacement(question: SessionEvent, evidence: SessionEvent[]) {
2781
+ const anchors = prescanTurnAnchors([question, ...evidence]);
2782
+ const direct = anchors.directChatSequenceByTrigger.get(question.id);
2783
+ if (direct !== undefined) return { kind: "visible" as const, sequence: direct };
2784
+ if (anchors.cancelledBeforeStartTriggers.has(question.id)) return { kind: "withdrawn" as const };
2785
+ const start = anchors.startSeqByTrigger.get(question.id);
2786
+ if (start !== undefined) return { kind: "visible" as const, sequence: start };
2787
+ if (
2788
+ anchors.queuedTurnByTrigger.has(question.id) ||
2789
+ anchors.explicitQueuedTriggers.has(question.id)
2790
+ )
2791
+ return { kind: "pending" as const };
2792
+ return { kind: "visible" as const, sequence: question.sequence };
2793
+ }
2794
+
1564
2795
  function prescanTurnAnchors(events: SessionEvent[]): TurnAnchorPrescan {
1565
2796
  const ordered = [...events].sort((a, b) => a.sequence - b.sequence);
1566
2797
  const queuedTurnByTrigger = new Map<string, string>();
@@ -1749,7 +2980,12 @@ function pushInsertion(
1749
2980
  }
1750
2981
 
1751
2982
  function isAgentActivityEvent(type: string): boolean {
1752
- return type.startsWith("agent.") || type.startsWith("sandbox.");
2983
+ return (
2984
+ type.startsWith("agent.") ||
2985
+ type.startsWith("sandbox.") ||
2986
+ type === "subscription.account.selected" ||
2987
+ type === "subscription.account.switched"
2988
+ );
1753
2989
  }
1754
2990
 
1755
2991
  /**
@@ -1759,11 +2995,15 @@ function isAgentActivityEvent(type: string): boolean {
1759
2995
  * steering, or deleting a waiting row must never make its prompt appear in the
1760
2996
  * transcript as though inference had begun.
1761
2997
  */
1762
- function isTurnExecutionEvidence(type: string): boolean {
2998
+ export function isTurnExecutionEvidence(type: string): boolean {
1763
2999
  return (
1764
3000
  isAgentActivityEvent(type) ||
1765
3001
  type === "turn.completed" ||
1766
3002
  type === "turn.failed" ||
3003
+ // An admission refusal can settle a queued turn before it ever starts:
3004
+ // its prompt still belongs above the "usage limit reached" row.
3005
+ type === "usage.exhausted" ||
3006
+ type === "turn.superseded" ||
1767
3007
  type === "turn.recovery.requested" ||
1768
3008
  type === "turn.capacity_waiting" ||
1769
3009
  type === "session.requiresAction" ||
@@ -1792,6 +3032,36 @@ function turnEndItem(
1792
3032
  };
1793
3033
  }
1794
3034
 
3035
+ /** Plain text for a usage-limit stop whose marker carried no readable amounts. */
3036
+ const SESSION_USAGE_LIMIT_STOP_TEXT = (t: OpenGeniText) =>
3037
+ t("timeline.projection.thisTaskSUsageLimit");
3038
+
3039
+ /**
3040
+ * The stop row for a `segmentLimit: "session_usage_limit"` completion. Only the
3041
+ * typed amounts are kept (never upstream prose), and a malformed marker still
3042
+ * reads as the same neutral stop instead of a credit or failure notice.
3043
+ */
3044
+ function sessionUsageLimitNotice(
3045
+ t: OpenGeniText,
3046
+ event: SessionEvent,
3047
+ payload: Record<string, unknown>,
3048
+ ): NoticeItem {
3049
+ const refusal = parseSessionUsageLimitReachedRefusal(payload);
3050
+ return {
3051
+ kind: "notice",
3052
+ id: `${event.id}-session-usage-limit`,
3053
+ // Neutral: not a failure, and not an open wait the turn header should claim.
3054
+ tone: "cancelled",
3055
+ text: refusal ? sessionUsageLimitReachedMessage(refusal) : SESSION_USAGE_LIMIT_STOP_TEXT(t),
3056
+ sessionUsageLimit: {
3057
+ rootSessionId: refusal?.rootSessionId ?? null,
3058
+ limitMicros: refusal?.limitMicros ?? null,
3059
+ usedMicros: refusal?.usedMicros ?? null,
3060
+ },
3061
+ occurredAt: event.occurredAt,
3062
+ };
3063
+ }
3064
+
1795
3065
  function hasTurnActivity(items: TimelineItem[], turnId: string | null): boolean {
1796
3066
  if (turnId) {
1797
3067
  return items.some((item) => isActivityItem(item) && item.turnId === turnId);
@@ -1873,6 +3143,7 @@ function foldSettledTurn(groups: TimelineGroup[], turnEnd: TurnEndItem): void {
1873
3143
  if (collected.length === 0) {
1874
3144
  return;
1875
3145
  }
3146
+ const collectedLength = collected.length;
1876
3147
 
1877
3148
  // Resolve only inside this turn's collected suffix. A user/machine-input
1878
3149
  // boundary or an interleaved foreign turn must never donate its answer.
@@ -1904,7 +3175,34 @@ function foldSettledTurn(groups: TimelineGroup[], turnEnd: TurnEndItem): void {
1904
3175
  ? null
1905
3176
  : extractLatestCompletedCommentary(collected, turnEnd);
1906
3177
  const visibleMessage = finalMessage ?? fallbackMessage;
1907
- const body = visibleMessage ? collected.filter((group) => group !== visibleMessage) : collected;
3178
+ const visibleMessages = visibleMessage ? [visibleMessage] : [];
3179
+ // A turn that answers a person but declares no final answer (typically one
3180
+ // that yields to a wait) keeps its first message visible beside the latest:
3181
+ // that is the immediate answer, not progress narration.
3182
+ if (
3183
+ visibleMessage &&
3184
+ !hasOrdinaryFinalAgentMessage(collected, turnEnd) &&
3185
+ turnAnswersPerson(groups, startIndex)
3186
+ ) {
3187
+ const first = collected.find(
3188
+ (group): group is Extract<TimelineGroup, { kind: "item" }> =>
3189
+ group.kind === "item" &&
3190
+ group.item.kind === "agent-message" &&
3191
+ !group.item.streaming &&
3192
+ group.item.text.trim().length > 0 &&
3193
+ belongsToTurn(group.item, turnEnd.turnId),
3194
+ );
3195
+ if (first && first !== visibleMessage) visibleMessages.unshift(first);
3196
+ }
3197
+ // A change the person asked to keep that was not saved stays in view beside
3198
+ // the answer, whatever the agent said about it.
3199
+ const keptNotices = collected.filter(
3200
+ (group) =>
3201
+ group.kind === "item" && group.item.kind === "notice" && !!group.item.learningRefusal,
3202
+ );
3203
+ const body = collected.filter(
3204
+ (group) => !visibleMessages.includes(group as never) && !keptNotices.includes(group),
3205
+ );
1908
3206
  if (body.length === 0) {
1909
3207
  return;
1910
3208
  }
@@ -1930,11 +3228,25 @@ function foldSettledTurn(groups: TimelineGroup[], turnEnd: TurnEndItem): void {
1930
3228
  turnGroup.failureText = turnEnd.failureText;
1931
3229
  }
1932
3230
 
1933
- groups.splice(
1934
- startIndex,
1935
- collected.length,
1936
- ...(visibleMessage ? [turnGroup, visibleMessage] : [turnGroup]),
1937
- );
3231
+ groups.splice(startIndex, collectedLength, turnGroup, ...keptNotices, ...visibleMessages);
3232
+ }
3233
+
3234
+ /** Whether the input boundary before a turn includes a person's message. */
3235
+ function turnAnswersPerson(groups: TimelineGroup[], startIndex: number): boolean {
3236
+ for (let index = startIndex - 1; index >= 0; index -= 1) {
3237
+ const group = groups[index];
3238
+ if (group?.kind !== "item") return false;
3239
+ if (group.item.kind === "user-message") return true;
3240
+ if (
3241
+ group.item.kind !== "machine-input-batch" &&
3242
+ group.item.kind !== "session-status" &&
3243
+ group.item.kind !== "context-compaction" &&
3244
+ !(group.item.kind === "notice" && group.item.tone === "input")
3245
+ ) {
3246
+ return false;
3247
+ }
3248
+ }
3249
+ return false;
1938
3250
  }
1939
3251
 
1940
3252
  function isTurnBoundary(group: TimelineGroup | undefined): boolean {
@@ -2056,6 +3368,29 @@ function numberOrNull(value: unknown): number | null {
2056
3368
  return typeof value === "number" && Number.isFinite(value) ? value : null;
2057
3369
  }
2058
3370
 
3371
+ /**
3372
+ * Read the closed provider-rejection record a `summarization_failed` skip
3373
+ * carries. Only bounded identifiers are accepted; a provider message is never
3374
+ * part of the payload and would be ignored here anyway.
3375
+ */
3376
+ function compactionProviderRejection(
3377
+ payload: Record<string, unknown>,
3378
+ ): ContextCompactionItem["providerRejection"] {
3379
+ const record = asRecord(payload.providerRejection);
3380
+ if (typeof record.httpStatus !== "number" || !Number.isFinite(record.httpStatus)) {
3381
+ return null;
3382
+ }
3383
+ const text = (value: unknown): string | null =>
3384
+ typeof value === "string" && value.trim() ? value : null;
3385
+ return {
3386
+ httpStatus: record.httpStatus,
3387
+ type: text(record.type),
3388
+ code: text(record.code),
3389
+ param: text(record.param),
3390
+ requestId: text(record.requestId),
3391
+ };
3392
+ }
3393
+
2059
3394
  function compactionTrigger(payload: Record<string, unknown>): ContextCompactionItem["trigger"] {
2060
3395
  const trigger = payload.trigger;
2061
3396
  return trigger === "auto" ||
@@ -2195,6 +3530,15 @@ function resourceRefs(value: unknown): import("@opengeni/sdk").ResourceRef[] {
2195
3530
  });
2196
3531
  }
2197
3532
 
3533
+ /** The person behind a message, when its initiator is a signed-in subject. */
3534
+ function messageSender(value: unknown): import("./types").MessageSender | undefined {
3535
+ const record = asRecord(value);
3536
+ if (record.kind !== "subject" || typeof record.subjectId !== "string" || !record.subjectId)
3537
+ return undefined;
3538
+ const label = typeof record.label === "string" && record.label.trim() ? record.label : null;
3539
+ return { subjectId: record.subjectId, label };
3540
+ }
3541
+
2198
3542
  function timelineAnnotations(value: unknown): TimelineAnnotation[] {
2199
3543
  if (!Array.isArray(value)) return [];
2200
3544
  return value.filter((candidate): candidate is TimelineAnnotation => {
@@ -2342,6 +3686,34 @@ function startupPhaseFromPayload(value: unknown): StartupPhase | null {
2342
3686
  : null;
2343
3687
  }
2344
3688
 
3689
+ function startupLifecycleWaitReason(
3690
+ payload: Record<string, unknown>,
3691
+ ): StartupPhaseItem["blockedReason"] {
3692
+ // The first model request waited for context compaction: an expected step
3693
+ // of preparation that reopens after compacting, never a failure.
3694
+ if (
3695
+ payload.expectedTransition === true &&
3696
+ payload.failureStage === "context_compaction" &&
3697
+ payload.failureCategory === "context_compaction" &&
3698
+ payload.failureCode === "compaction_required"
3699
+ ) {
3700
+ return "compaction_required";
3701
+ }
3702
+ if (
3703
+ payload.expectedTransition !== true ||
3704
+ payload.failureStage !== "lifecycle_wait" ||
3705
+ payload.failureCategory !== "drain_capture_wait"
3706
+ ) {
3707
+ return undefined;
3708
+ }
3709
+ const code = payload.failureCode;
3710
+ return code === "capture_in_progress" ||
3711
+ code === "rotation_in_progress" ||
3712
+ code === "provider_recovery_in_progress"
3713
+ ? code
3714
+ : undefined;
3715
+ }
3716
+
2345
3717
  const SANDBOX_STARTUP_PHASES: Record<string, StartupPhase> = {
2346
3718
  "sandbox.provision": "sandbox",
2347
3719
  "repository-clone": "repository",
@@ -2364,8 +3736,8 @@ function elapsedDurationMs(startedAt: string, completedAt: string): number | nul
2364
3736
  return Number.isFinite(start) && Number.isFinite(end) ? Math.max(0, end - start) : null;
2365
3737
  }
2366
3738
 
2367
- function failureMessage(payload: Record<string, unknown>): string | null {
2368
- return presentFailure(payload).reason;
3739
+ function failureMessage(t: OpenGeniText, payload: Record<string, unknown>): string | null {
3740
+ return presentFailure(t, payload).reason;
2369
3741
  }
2370
3742
 
2371
3743
  function goalText(payload: Record<string, unknown>): string | null {
@@ -2395,8 +3767,89 @@ function rememberPendingWaitOutcome(
2395
3767
  pending.set(turnId, { id: event.id, reason, occurredAt: event.occurredAt });
2396
3768
  }
2397
3769
 
2398
- function waitingOutcomeText(reason: string): string {
2399
- return /^waiting\b/i.test(reason) ? reason : `Waiting: ${reason}`;
3770
+ /** Wait reasons that need a person or a policy change, not only time. */
3771
+ const ACTION_CAPACITY_WAIT_REASONS: ReadonlySet<string> = new Set([
3772
+ "pinned_account_disabled",
3773
+ "pinned_account_ineligible",
3774
+ "model_not_allowed",
3775
+ // Only sending the work again ends it (design 5.3 decision 4).
3776
+ "accepted_authority_unavailable",
3777
+ ]);
3778
+
3779
+ /**
3780
+ * Recorded wait codes, for any subscription provider, that a person must
3781
+ * resolve: every account disabled for allocation, or the serving account
3782
+ * needing reconnection or refusing the request. None of them is a limit.
3783
+ */
3784
+ const ACTION_CAPACITY_WAIT_CODE = /_(?:allocator_disabled|relogin_required|account_forbidden)$/;
3785
+
3786
+ /**
3787
+ * A quota or capacity wait reads as "Usage limit reached" with one plain line
3788
+ * of guidance. It never promises that the work continues by itself: the
3789
+ * reader decides whether to wait for the quota to reset or to switch. Only a
3790
+ * wait that a person must resolve (reconnect, re-enable, choose another
3791
+ * account) keeps its recorded, actionable reason and is not labelled a limit.
3792
+ */
3793
+ function capacityWaitPresentation(
3794
+ t: OpenGeniText,
3795
+ type: string,
3796
+ payload: Record<string, unknown>,
3797
+ turnId: string | null,
3798
+ ): { turnId: string | null; label: string; detail: string; text: string } {
3799
+ if (
3800
+ ACTION_CAPACITY_WAIT_REASONS.has(stringValue(payload.waitReason)) ||
3801
+ ACTION_CAPACITY_WAIT_CODE.test(stringValue(payload.code))
3802
+ ) {
3803
+ // Claude/SuperGrok waits record the readable sentence as `error` and an
3804
+ // internal note as `detail`; Codex waits keep their recorded order.
3805
+ const [first, second] =
3806
+ type === "turn.capacity_waiting"
3807
+ ? [payload.error, payload.detail]
3808
+ : [payload.detail, payload.error];
3809
+ const detail =
3810
+ stringValue(first) || stringValue(second) || t("timeline.projection.waitingForAnAccount");
3811
+ return {
3812
+ turnId,
3813
+ label:
3814
+ stringValue(payload.waitReason) === "pinned_account_disabled"
3815
+ ? t("timeline.projection.needsYou")
3816
+ : t("timeline.projection.waiting"),
3817
+ detail,
3818
+ text: detail,
3819
+ };
3820
+ }
3821
+ return {
3822
+ turnId,
3823
+ label: CAPACITY_LIMIT_LABEL(t),
3824
+ detail: CAPACITY_LIMIT_DETAIL(t),
3825
+ text: `${CAPACITY_LIMIT_LABEL(t)}. ${CAPACITY_LIMIT_DETAIL(t)}`,
3826
+ };
3827
+ }
3828
+
3829
+ const CAPACITY_LIMIT_LABEL = (t: OpenGeniText) => t("timeline.projection.usageLimitReached");
3830
+ const CAPACITY_LIMIT_DETAIL = (t: OpenGeniText) => t("timeline.projection.tryAgainAfterYourQuota");
3831
+
3832
+ /** Lifecycle evidence that a capacity wait is over. */
3833
+ function endsCapacityWait(event: SessionEvent, payload: Record<string, unknown>): boolean {
3834
+ if (event.duplicateOfEventId || (event.turnAssociation && event.turnAssociation !== "current"))
3835
+ return false;
3836
+ switch (event.type) {
3837
+ case "codex.capacity.resumed":
3838
+ case "codex.capacity.superseded":
3839
+ case "turn.completed":
3840
+ case "turn.failed":
3841
+ case "turn.cancelled":
3842
+ case "turn.superseded":
3843
+ return true;
3844
+ case "session.status.changed":
3845
+ return isSessionStatus(payload.status) && payload.status !== "waiting_capacity";
3846
+ default:
3847
+ return false;
3848
+ }
3849
+ }
3850
+
3851
+ function waitingOutcomeText(t: OpenGeniText, reason: string): string {
3852
+ return /^waiting\b/i.test(reason) ? reason : t("timeline.projection.waitingReason", { reason });
2400
3853
  }
2401
3854
 
2402
3855
  /**
@@ -2468,6 +3921,7 @@ const AUTH_NEEDED_REASONS: ReadonlySet<string> = new Set([
2468
3921
  "personal_authority_unavailable",
2469
3922
  "unsupported_auth",
2470
3923
  "resource_scope_unavailable",
3924
+ "designated_credential_unavailable",
2471
3925
  ]);
2472
3926
 
2473
3927
  function authNeededReason(value: unknown): AuthNeededItem["reason"] {
@@ -2487,7 +3941,7 @@ function capabilityAuthorizationRequest(
2487
3941
  if (
2488
3942
  typeof record.id !== "string" ||
2489
3943
  typeof record.name !== "string" ||
2490
- !["pack", "mcp", "api", "skill", "plugin"].includes(String(kind)) ||
3944
+ !["mcp", "api", "skill", "plugin"].includes(String(kind)) ||
2491
3945
  !["built_in", "library", "configured", "public_registry", "registry", "manual"].includes(
2492
3946
  String(source),
2493
3947
  ) ||
@@ -2507,12 +3961,30 @@ function capabilityAuthorizationRequest(
2507
3961
  };
2508
3962
  }
2509
3963
 
3964
+ function customMcpSetupRequest(value: unknown): NonNullable<AuthNeededItem["setupRequest"]> | null {
3965
+ return parseCustomMcpSetupRequest(value);
3966
+ }
3967
+
2510
3968
  function stringList(value: unknown): string[] {
2511
3969
  return Array.isArray(value)
2512
3970
  ? value.filter((entry): entry is string => typeof entry === "string" && entry.trim().length > 0)
2513
3971
  : [];
2514
3972
  }
2515
3973
 
3974
+ /**
3975
+ * Some providers stream each reasoning summary part as its own delta
3976
+ * ("**Checking the workspace**", then "**Inspecting guidance**"). Joined
3977
+ * as-is the parts run together and their bold markers collide ("****"), so a
3978
+ * new part that opens bold right after one that closed bold starts a new
3979
+ * paragraph. Ordinary token deltas are joined unchanged. The worker's
3980
+ * write-time merge and the read-side coalescer apply the same rule
3981
+ * (`reasoningDeltaSeparator` in @opengeni/events), so stored, coalesced and
3982
+ * live fragments render identically.
3983
+ */
3984
+ function reasoningDeltaJoiner(previous: string, next: string): string {
3985
+ return previous.endsWith("**") && next.startsWith("**") ? "\n\n" : "";
3986
+ }
3987
+
2516
3988
  function reasoningText(payload: unknown): string {
2517
3989
  const record = asRecord(payload);
2518
3990
  if (typeof record.text === "string") {
@@ -2542,6 +4014,19 @@ function workerPrompt(args: unknown): string | null {
2542
4014
  return null;
2543
4015
  }
2544
4016
 
4017
+ const WORKER_TITLE_MAX_LENGTH = 120;
4018
+
4019
+ /** The optional `session_create` title, as one bounded display line. */
4020
+ function workerTitle(args: unknown): string | null {
4021
+ const record = asRecord(typeof args === "string" ? tryParseJson(args) : args);
4022
+ if (typeof record.title !== "string") return null;
4023
+ const title = record.title.replace(/\s+/g, " ").trim();
4024
+ if (!title) return null;
4025
+ return title.length > WORKER_TITLE_MAX_LENGTH
4026
+ ? `${title.slice(0, WORKER_TITLE_MAX_LENGTH - 1).trimEnd()}…`
4027
+ : title;
4028
+ }
4029
+
2545
4030
  function boundedWorkerFailureMessage(value: string): string | null {
2546
4031
  const normalized = value.replace(/[\u0000-\u001f\u007f]+/g, " ").trim();
2547
4032
  if (!normalized) return null;