zidane-ui 9.2.3 → 9.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (354) hide show
  1. package/dist/adapters/live.d.ts +8 -0
  2. package/dist/adapters/live.js +19 -8
  3. package/dist/adapters/server-composer-host.js +22 -9
  4. package/dist/adapters/server-git-host.js +5 -2
  5. package/dist/adapters/server-host.js +158 -27
  6. package/dist/adapters/server-machines-host.js +7 -0
  7. package/dist/adapters/server-media.d.ts +9 -1
  8. package/dist/adapters/server-media.js +14 -1
  9. package/dist/adapters/server-session-host.js +49 -0
  10. package/dist/adapters/server-settings-sections.js +4 -1
  11. package/dist/adapters/sse-host.js +3 -0
  12. package/dist/adapters/sse-protocol.d.ts +10 -0
  13. package/dist/appearance/ZoomIndicator.js +5 -8
  14. package/dist/chat/HostTranscript.d.ts +0 -12
  15. package/dist/chat/HostTranscript.js +20 -1
  16. package/dist/chat/SessionStreamsProvider.d.ts +9 -1
  17. package/dist/chat/SessionStreamsProvider.js +11 -2
  18. package/dist/chat/Transcript.d.ts +21 -11
  19. package/dist/chat/Transcript.js +346 -161
  20. package/dist/chat/composer/ModelOptionsPicker.js +6 -2
  21. package/dist/chat/composer/ModelPicker.d.ts +1 -1
  22. package/dist/chat/composer/PlacePicker.d.ts +3 -1
  23. package/dist/chat/composer/PlacePicker.js +5 -1
  24. package/dist/chat/composer/use-draft-target.js +15 -3
  25. package/dist/chat/headless/block-runs.js +26 -1
  26. package/dist/chat/headless/chip-views.js +1 -1
  27. package/dist/chat/headless/draft-target.d.ts +28 -1
  28. package/dist/chat/headless/draft-target.js +22 -1
  29. package/dist/chat/headless/host.d.ts +43 -7
  30. package/dist/chat/headless/hosts.d.ts +4 -0
  31. package/dist/chat/headless/index.d.ts +27 -26
  32. package/dist/chat/headless/index.js +15 -14
  33. package/dist/chat/headless/labels.d.ts +17 -0
  34. package/dist/chat/headless/labels.js +17 -0
  35. package/dist/chat/headless/markdown-chunks.d.ts +2 -1
  36. package/dist/chat/headless/markdown-chunks.js +12 -20
  37. package/dist/chat/headless/markdown-scan.d.ts +64 -0
  38. package/dist/chat/headless/markdown-scan.js +119 -0
  39. package/dist/chat/headless/markdown-stream.d.ts +64 -0
  40. package/dist/chat/headless/markdown-stream.js +143 -0
  41. package/dist/chat/headless/output-pager.d.ts +68 -0
  42. package/dist/chat/headless/output-pager.js +113 -0
  43. package/dist/chat/headless/prompt-origin.d.ts +2 -0
  44. package/dist/chat/headless/prompt-origin.js +6 -2
  45. package/dist/chat/headless/session-list.d.ts +10 -0
  46. package/dist/chat/headless/sidebar/activity.d.ts +14 -0
  47. package/dist/chat/headless/sidebar/activity.js +32 -0
  48. package/dist/chat/headless/sidebar/directory.d.ts +19 -2
  49. package/dist/chat/headless/sidebar/directory.js +19 -51
  50. package/dist/chat/headless/sidebar/environment.d.ts +15 -4
  51. package/dist/chat/headless/sidebar/environment.js +27 -9
  52. package/dist/chat/headless/sidebar/index.d.ts +2 -2
  53. package/dist/chat/headless/sidebar/index.js +2 -2
  54. package/dist/chat/headless/sidebar/labels.d.ts +19 -2
  55. package/dist/chat/headless/sidebar/labels.js +8 -1
  56. package/dist/chat/headless/sidebar/prewarm.d.ts +68 -0
  57. package/dist/chat/headless/sidebar/prewarm.js +114 -0
  58. package/dist/chat/headless/streams/actions.d.ts +4 -2
  59. package/dist/chat/headless/streams/actions.js +2 -1
  60. package/dist/chat/headless/streams/event-bytes.d.ts +17 -0
  61. package/dist/chat/headless/streams/event-bytes.js +46 -0
  62. package/dist/chat/headless/streams/live-events.d.ts +25 -1
  63. package/dist/chat/headless/streams/live-events.js +53 -2
  64. package/dist/chat/headless/streams/selectors.d.ts +3 -0
  65. package/dist/chat/headless/streams/selectors.js +8 -1
  66. package/dist/chat/headless/streams/session-streams.d.ts +15 -3
  67. package/dist/chat/headless/streams/session-streams.js +31 -3
  68. package/dist/chat/headless/streams/store.d.ts +45 -6
  69. package/dist/chat/headless/streams/store.js +85 -31
  70. package/dist/chat/headless/streams/transcript-map.d.ts +57 -0
  71. package/dist/chat/headless/streams/transcript-map.js +85 -0
  72. package/dist/chat/headless/streams/transcript.d.ts +4 -2
  73. package/dist/chat/headless/streams/transcript.js +19 -7
  74. package/dist/chat/headless/streams/types.d.ts +2 -1
  75. package/dist/chat/headless/transcript/batch.js +5 -1
  76. package/dist/chat/headless/transcript/blob-media.d.ts +15 -0
  77. package/dist/chat/headless/transcript/blob-media.js +23 -0
  78. package/dist/chat/headless/transcript/collapse.d.ts +10 -0
  79. package/dist/chat/headless/transcript/collapse.js +35 -6
  80. package/dist/chat/headless/transcript/derive.d.ts +98 -0
  81. package/dist/chat/headless/transcript/derive.js +89 -0
  82. package/dist/chat/headless/transcript/exchange-media.d.ts +3 -1
  83. package/dist/chat/headless/transcript/exchange-media.js +8 -5
  84. package/dist/chat/headless/transcript/fold-attachments.d.ts +2 -0
  85. package/dist/chat/headless/transcript/fold-attachments.js +3 -2
  86. package/dist/chat/headless/transcript/fold.d.ts +2 -1
  87. package/dist/chat/headless/transcript/fold.js +16 -6
  88. package/dist/chat/headless/transcript/incremental.d.ts +53 -0
  89. package/dist/chat/headless/transcript/incremental.js +181 -0
  90. package/dist/chat/headless/transcript/index.d.ts +2 -2
  91. package/dist/chat/headless/transcript/index.js +2 -2
  92. package/dist/chat/headless/transcript/nesting.js +2 -1
  93. package/dist/chat/headless/transcript/rail.d.ts +50 -1
  94. package/dist/chat/headless/transcript/rail.js +165 -23
  95. package/dist/chat/headless/transcript/rows.d.ts +5 -1
  96. package/dist/chat/headless/transcript/run-failures.js +2 -1
  97. package/dist/chat/headless/transcript/seams.d.ts +78 -0
  98. package/dist/chat/headless/transcript/seams.js +116 -0
  99. package/dist/chat/headless/transcript/tool-media.d.ts +6 -7
  100. package/dist/chat/headless/transcript/tool-media.js +27 -9
  101. package/dist/chat/index.d.ts +9 -8
  102. package/dist/chat/index.js +18 -17
  103. package/dist/chat/sidebar/ProjectIcon.js +1 -1
  104. package/dist/chat/sidebar/RowChips.js +2 -2
  105. package/dist/chat/sidebar/SessionSidebar.d.ts +6 -0
  106. package/dist/chat/sidebar/SessionSidebar.js +23 -16
  107. package/dist/chat/sidebar/SidebarFilterMenu.js +0 -1
  108. package/dist/chat/sidebar/SidebarFold.js +17 -16
  109. package/dist/chat/sidebar/SidebarFooter.d.ts +8 -5
  110. package/dist/chat/sidebar/SidebarFooter.js +6 -6
  111. package/dist/chat/sidebar/SidebarSessionRow.d.ts +7 -1
  112. package/dist/chat/sidebar/SidebarSessionRow.js +11 -8
  113. package/dist/chat/sidebar/session-menu.d.ts +4 -0
  114. package/dist/chat/sidebar/session-menu.js +14 -2
  115. package/dist/chat/sidebar/sidebar-live.js +28 -4
  116. package/dist/chat/sidebar/useInboxRows.js +6 -6
  117. package/dist/chat/sidebar/useInboxTriage.js +50 -47
  118. package/dist/chat/sidebar/useSessionSearch.js +19 -18
  119. package/dist/chat/testing/contract.d.ts +5 -3
  120. package/dist/chat/testing/contract.js +66 -1
  121. package/dist/chat/transcript/DiffLines.d.ts +6 -1
  122. package/dist/chat/transcript/DiffLines.js +35 -20
  123. package/dist/chat/transcript/EditDiffBlock.d.ts +5 -1
  124. package/dist/chat/transcript/EditDiffBlock.js +89 -30
  125. package/dist/chat/transcript/FileChip.js +28 -0
  126. package/dist/chat/transcript/LazyRow.d.ts +40 -40
  127. package/dist/chat/transcript/LazyRow.js +100 -149
  128. package/dist/chat/transcript/MermaidDiagram.js +2 -1
  129. package/dist/chat/transcript/PromptEcho.js +3 -11
  130. package/dist/chat/transcript/SessionChip.d.ts +11 -0
  131. package/dist/chat/transcript/SessionChip.js +34 -0
  132. package/dist/chat/transcript/SubagentBlock.js +3 -2
  133. package/dist/chat/transcript/TranscriptRail.d.ts +25 -2
  134. package/dist/chat/transcript/TranscriptRail.js +175 -17
  135. package/dist/chat/transcript/TranscriptRow.d.ts +4 -7
  136. package/dist/chat/transcript/TranscriptRow.js +4 -3
  137. package/dist/chat/transcript/actions.d.ts +37 -1
  138. package/dist/chat/transcript/actions.js +27 -1
  139. package/dist/chat/transcript/chip-details.d.ts +11 -0
  140. package/dist/chat/transcript/chip-details.js +17 -1
  141. package/dist/chat/transcript/clipped-output.d.ts +58 -0
  142. package/dist/chat/transcript/clipped-output.js +131 -0
  143. package/dist/chat/transcript/fold-attachments.js +10 -5
  144. package/dist/chat/transcript/fold-worker.js +5 -3
  145. package/dist/chat/transcript/fold.js +13 -4
  146. package/dist/chat/transcript/index.d.ts +11 -10
  147. package/dist/chat/transcript/index.js +10 -9
  148. package/dist/chat/transcript/markdown-cache.d.ts +17 -2
  149. package/dist/chat/transcript/markdown-cache.js +48 -4
  150. package/dist/chat/transcript/markdown.js +110 -55
  151. package/dist/chat/transcript/media-gallery.d.ts +3 -2
  152. package/dist/chat/transcript/media-gallery.js +19 -19
  153. package/dist/chat/transcript/messages.js +5 -4
  154. package/dist/chat/transcript/notices.js +2 -1
  155. package/dist/chat/transcript/prompt.d.ts +1 -1
  156. package/dist/chat/transcript/prompt.js +6 -4
  157. package/dist/chat/transcript/prose.js +2 -1
  158. package/dist/chat/transcript/root-items.d.ts +96 -0
  159. package/dist/chat/transcript/root-items.js +180 -0
  160. package/dist/chat/transcript/row-mount.d.ts +184 -0
  161. package/dist/chat/transcript/row-mount.js +532 -0
  162. package/dist/chat/transcript/row-parking.d.ts +152 -0
  163. package/dist/chat/transcript/row-parking.js +171 -0
  164. package/dist/chat/transcript/row-ui-state.d.ts +37 -0
  165. package/dist/chat/transcript/row-ui-state.js +53 -0
  166. package/dist/chat/transcript/run-rows.js +3 -2
  167. package/dist/chat/transcript/script-input.d.ts +1 -1
  168. package/dist/chat/transcript/tasks.js +3 -2
  169. package/dist/chat/transcript/tool-media.d.ts +4 -2
  170. package/dist/chat/transcript/tool-media.js +15 -7
  171. package/dist/chat/transcript/tool-parts.d.ts +27 -4
  172. package/dist/chat/transcript/tool-parts.js +31 -6
  173. package/dist/chat/transcript/tool-payload.js +26 -11
  174. package/dist/chat/transcript/tool-row.d.ts +2 -1
  175. package/dist/chat/transcript/tool-row.js +38 -19
  176. package/dist/chat/transcript/use-transcript-rows.d.ts +25 -8
  177. package/dist/chat/transcript/use-transcript-rows.js +28 -46
  178. package/dist/chat/transcript/useHistoryBackfill.d.ts +42 -0
  179. package/dist/chat/transcript/useHistoryBackfill.js +170 -0
  180. package/dist/chat/transcript/useStickToBottom.js +2 -3
  181. package/dist/chat/transcript/useTranscriptFind.js +2 -4
  182. package/dist/chat/transcript/useTranscriptScroll.d.ts +7 -4
  183. package/dist/chat/transcript/useTranscriptScroll.js +12 -1
  184. package/dist/chat/transcript/useTranscriptSearch.d.ts +2 -2
  185. package/dist/chat/transcript/useTranscriptSearch.js +35 -19
  186. package/dist/chat/transcript/useTranscriptSelectionCopy.d.ts +5 -5
  187. package/dist/chat/transcript/useTranscriptSelectionCopy.js +28 -7
  188. package/dist/chat/transcript/view-scope.d.ts +26 -6
  189. package/dist/chat/transcript/view-scope.js +106 -20
  190. package/dist/code/editor/FileTree.d.ts +2 -0
  191. package/dist/code/editor/FileTree.js +1 -1
  192. package/dist/code/editor/FileView.js +16 -25
  193. package/dist/code/editor/find/useFind.js +17 -17
  194. package/dist/code/editor/useCodeDocument.js +22 -19
  195. package/dist/code/editor/useDetachCleanup.js +4 -3
  196. package/dist/code/use-highlighted-html.js +12 -13
  197. package/dist/components/IconButton.d.ts +3 -1
  198. package/dist/components/IconButton.js +7 -2
  199. package/dist/components/IconButtonTip.d.ts +3 -1
  200. package/dist/components/IconButtonTip.js +2 -1
  201. package/dist/components/RowActionsMenu.js +7 -14
  202. package/dist/components/Tooltip.d.ts +4 -1
  203. package/dist/components/Tooltip.js +8 -6
  204. package/dist/components/assign-ref.d.ts +8 -0
  205. package/dist/components/assign-ref.js +12 -0
  206. package/dist/components/floating/FloatingSurface.js +2 -2
  207. package/dist/components/floating/HoverCard.js +32 -14
  208. package/dist/components/floating/Popover.js +4 -7
  209. package/dist/components/floating/useAnchoredPosition.d.ts +5 -3
  210. package/dist/components/floating/useAnchoredPosition.js +7 -7
  211. package/dist/components/object-key.d.ts +7 -0
  212. package/dist/components/object-key.js +18 -0
  213. package/dist/components/palette/PaletteList.js +2 -7
  214. package/dist/components/tooltip-arming.d.ts +3 -0
  215. package/dist/components/tooltip-arming.js +8 -1
  216. package/dist/core.css +3 -3
  217. package/dist/dist/{index-E1Z0aPmi.d.ts → index-BheVJOLc.d.ts} +3 -1
  218. package/dist/dist/index.d.ts +2 -2
  219. package/dist/files/FilesTab.js +0 -1
  220. package/dist/files/TreeColumn.d.ts +2 -4
  221. package/dist/files/TreeColumn.js +0 -5
  222. package/dist/files/headless/host.d.ts +3 -7
  223. package/dist/files/headless/labels.d.ts +0 -1
  224. package/dist/files/headless/labels.js +0 -1
  225. package/dist/files/headless/workspace-diff.js +1 -1
  226. package/dist/files/useCodeReview.js +1 -3
  227. package/dist/files/useFilesDiagnostics.d.ts +1 -1
  228. package/dist/files/useFilesDiagnostics.js +4 -11
  229. package/dist/files/useOpenFiles.js +9 -12
  230. package/dist/files/useWorkspace.d.ts +5 -7
  231. package/dist/files/useWorkspace.js +4 -15
  232. package/dist/git/GitBar.js +5 -3
  233. package/dist/git/MoveSessionDialog.d.ts +18 -8
  234. package/dist/git/MoveSessionDialog.js +32 -53
  235. package/dist/git/MoveToDialog.d.ts +61 -0
  236. package/dist/git/MoveToDialog.js +240 -0
  237. package/dist/git/SandboxManager.js +9 -4
  238. package/dist/git/SyncChip.js +11 -4
  239. package/dist/git/TeleportSessionDialog.d.ts +69 -0
  240. package/dist/git/TeleportSessionDialog.js +440 -0
  241. package/dist/git/headless/host.d.ts +14 -0
  242. package/dist/git/headless/index.d.ts +2 -1
  243. package/dist/git/headless/index.js +2 -1
  244. package/dist/git/headless/labels.d.ts +44 -1
  245. package/dist/git/headless/labels.js +50 -0
  246. package/dist/git/headless/sandboxes.d.ts +1 -1
  247. package/dist/git/headless/sandboxes.js +4 -3
  248. package/dist/git/headless/teleport.d.ts +76 -0
  249. package/dist/git/headless/teleport.js +19 -0
  250. package/dist/git/index.d.ts +4 -2
  251. package/dist/git/index.js +4 -2
  252. package/dist/git/useEnvironmentChoices.d.ts +5 -2
  253. package/dist/git/useEnvironmentChoices.js +12 -4
  254. package/dist/hooks/useLatest.d.ts +8 -0
  255. package/dist/hooks/useLatest.js +17 -0
  256. package/dist/hooks/useMinuteTick.d.ts +6 -2
  257. package/dist/hooks/useMinuteTick.js +12 -6
  258. package/dist/hooks/useNearViewport.js +11 -8
  259. package/dist/index.d.ts +3 -2
  260. package/dist/index.js +2 -1
  261. package/dist/keybindings/KeybindingsProvider.js +3 -4
  262. package/dist/keybindings/headless/catalog.d.ts +1 -1
  263. package/dist/keybindings/headless/catalog.js +18 -0
  264. package/dist/machines/AddServerForm.js +55 -3
  265. package/dist/machines/Banners.d.ts +2 -2
  266. package/dist/machines/Banners.js +3 -3
  267. package/dist/machines/DaemonMenu.js +1 -3
  268. package/dist/machines/HostsSection.js +5 -1
  269. package/dist/machines/OrganizationPanel.d.ts +25 -0
  270. package/dist/machines/OrganizationPanel.js +266 -0
  271. package/dist/machines/PersonalLayerPanel.d.ts +32 -0
  272. package/dist/machines/PersonalLayerPanel.js +360 -0
  273. package/dist/machines/headless/fixture-host.d.ts +10 -0
  274. package/dist/machines/headless/fixture-host.js +44 -0
  275. package/dist/machines/headless/host.d.ts +21 -1
  276. package/dist/machines/headless/index.d.ts +3 -1
  277. package/dist/machines/headless/index.js +3 -1
  278. package/dist/machines/headless/labels.d.ts +55 -0
  279. package/dist/machines/headless/labels.js +58 -1
  280. package/dist/machines/headless/layer.d.ts +64 -0
  281. package/dist/machines/headless/layer.js +56 -0
  282. package/dist/machines/headless/organization.d.ts +38 -0
  283. package/dist/machines/headless/organization.js +44 -0
  284. package/dist/machines/index.d.ts +3 -1
  285. package/dist/machines/index.js +3 -1
  286. package/dist/machines/testing/contract.d.ts +25 -1
  287. package/dist/machines/testing/contract.js +97 -1
  288. package/dist/motion/grow.js +12 -13
  289. package/dist/motion/swap.js +2 -5
  290. package/dist/motion/use-flip-list.d.ts +14 -0
  291. package/dist/motion/use-flip-list.js +17 -12
  292. package/dist/palette/headless/app-sources.js +37 -0
  293. package/dist/palette/headless/labels.js +3 -0
  294. package/dist/server/sse-handler.js +25 -2
  295. package/dist/session/DiffFileTree.js +1 -4
  296. package/dist/session/OpenSessionsDialog.d.ts +46 -0
  297. package/dist/session/OpenSessionsDialog.js +170 -0
  298. package/dist/session/PlanTracker.js +1 -2
  299. package/dist/session/ProjectHome.js +10 -9
  300. package/dist/session/RemindersPanel.js +10 -12
  301. package/dist/session/SecretsPanel.js +2 -1
  302. package/dist/session/SessionHeader.js +1 -0
  303. package/dist/session/SessionPeopleStack.d.ts +23 -0
  304. package/dist/session/SessionPeopleStack.js +65 -0
  305. package/dist/session/SessionPlaceMenu.js +5 -4
  306. package/dist/session/ShareSessionDialog.d.ts +32 -0
  307. package/dist/session/ShareSessionDialog.js +342 -0
  308. package/dist/session/TypingLine.d.ts +22 -0
  309. package/dist/session/TypingLine.js +31 -0
  310. package/dist/session/headless/host.d.ts +40 -1
  311. package/dist/session/headless/index.d.ts +4 -2
  312. package/dist/session/headless/index.js +3 -1
  313. package/dist/session/headless/labels.d.ts +49 -0
  314. package/dist/session/headless/labels.js +56 -0
  315. package/dist/session/headless/people.d.ts +29 -0
  316. package/dist/session/headless/people.js +53 -0
  317. package/dist/session/headless/place.d.ts +5 -0
  318. package/dist/session/headless/place.js +5 -1
  319. package/dist/session/headless/typing.d.ts +37 -0
  320. package/dist/session/headless/typing.js +60 -0
  321. package/dist/session/index.d.ts +5 -1
  322. package/dist/session/index.js +5 -1
  323. package/dist/settings/headless/fixture-performance.js +4 -2
  324. package/dist/settings/headless/performance.d.ts +4 -0
  325. package/dist/settings/headless/search.d.ts +1 -1
  326. package/dist/settings/headless/sections-host.d.ts +7 -2
  327. package/dist/settings/section.d.ts +15 -3
  328. package/dist/settings/section.js +15 -3
  329. package/dist/settings/sections/environments/EnvironmentsSection.js +30 -6
  330. package/dist/settings/sections/keybindings/labels.d.ts +3 -0
  331. package/dist/settings/sections/keybindings/labels.js +3 -0
  332. package/dist/settings/sections/keybindings/rows.js +12 -0
  333. package/dist/settings/sections/logs/LogsSection.js +5 -8
  334. package/dist/settings/sections/performance/PerformanceSection.js +8 -1
  335. package/dist/settings/sections/performance/labels.d.ts +2 -0
  336. package/dist/settings/sections/performance/labels.js +2 -0
  337. package/dist/styles.css +65 -9
  338. package/dist/terminal/HostTerminalSurface.js +28 -30
  339. package/dist/terminal/TerminalPanel.js +4 -12
  340. package/dist/terminal/TerminalProvider.d.ts +10 -2
  341. package/dist/terminal/TerminalProvider.js +10 -2
  342. package/dist/terminal/headless/labels.d.ts +0 -1
  343. package/dist/terminal/headless/labels.js +1 -2
  344. package/dist/terminal/headless/store.js +5 -1
  345. package/dist/views/headless/answers.d.ts +8 -2
  346. package/dist/views/headless/answers.js +58 -1
  347. package/dist/views/headless/placement.d.ts +78 -0
  348. package/dist/views/headless/placement.js +154 -44
  349. package/dist/workspace/LayoutBudget.js +1 -7
  350. package/package.json +2 -2
  351. package/src/styles/chat.css +3 -1
  352. package/src/styles/palette.css +3 -3
  353. package/src/styles/transcript.css +50 -5
  354. /package/dist/dist/{index-De9AbmxS.d.ts → index-ttmMvjgM.d.ts} +0 -0
@@ -15,8 +15,8 @@ import { ChatAttachment, ChatEvent } from "../host.js";
15
15
  import { DrainPlan } from "./pacer.js";
16
16
  import { FrameScheduler } from "./scheduler.js";
17
17
  import { OtherStreamSignal, SessionFallbackModel, SessionPageState, SessionRetryState, SessionStreamPage, SessionStreamSignal } from "./types.js";
18
- import { HistoryChange, HistorySince, MarkdownDeltaOptions, PromptSegmentRef } from "zidane/chat/pure";
19
- import { SystemMdFile } from "zidane/chat";
18
+ import { HistoryChange, HistorySince, MarkdownDeltaOptions, PromptSegmentRef, TranscriptEvents } from "zidane/chat/pure";
19
+ import { Owner, SystemMdFile } from "zidane/chat";
20
20
  /** A prompt this client appended optimistically, awaiting its host echo (`SessionStreamStore.pendingEchoes`). */
21
21
  export interface PendingEcho {
22
22
  /** The prompt text. */
@@ -39,6 +39,8 @@ export interface SessionStreamStoreOptions {
39
39
  export interface SessionStreamWrite {
40
40
  /** Replaces the events. */
41
41
  events?: readonly ChatEvent[];
42
+ /** Replaces the events with a transcript store (one a reducer made from the current one keeps its settled chunks). Wins over `events`. */
43
+ transcript?: TranscriptEvents<ChatEvent>;
42
44
  /** Sets the run flag. */
43
45
  running?: boolean;
44
46
  /** Sets the page state (and so marks the window hydrated); `null` drops it. */
@@ -59,6 +61,7 @@ export interface SessionStreamWrite {
59
61
  * @typeParam K - The session key type (the desktop app's branded `SessionKey`). Default: `string`.
60
62
  */
61
63
  export declare class SessionStreamStore<K extends string = string> {
64
+ /** Each session's events as a transcript store: a streamed delta copies only the open exchange (`TranscriptMap`). */
62
65
  private _events;
63
66
  private _running;
64
67
  private readonly _scheduler;
@@ -90,6 +93,8 @@ export declare class SessionStreamStore<K extends string = string> {
90
93
  * guidance — and does so without erroring.
91
94
  */
92
95
  private _systemMd;
96
+ /** How many `system-md` signals each session got: a seed read that one landed during is older than it (`seedSystemMd`). */
97
+ private _systemMdSignals;
93
98
  /**
94
99
  * Per-session provider-retry state. Cleared on `run:end` rather than
95
100
  * `run:start`: a terminal stream failure never streams again, so run end is
@@ -166,6 +171,14 @@ export declare class SessionStreamStore<K extends string = string> {
166
171
  * @param sessionId - The session, or `null` for none.
167
172
  */
168
173
  getEventsSnapshot(sessionId: K | null): readonly ChatEvent[];
174
+ /**
175
+ * A session's events as a transcript store (settled exchanges and the open
176
+ * one), for a consumer that derives per exchange. `getEventsSnapshot` is
177
+ * its array (`transcriptOfArray` maps one to the other).
178
+ *
179
+ * @param sessionId - The session.
180
+ */
181
+ getTranscriptSnapshot(sessionId: K): TranscriptEvents<ChatEvent> | undefined;
169
182
  /**
170
183
  * Whether a run is in flight for the session.
171
184
  *
@@ -204,13 +217,15 @@ export declare class SessionStreamStore<K extends string = string> {
204
217
  * most common flow rather than an edge case, which is the wrong direction
205
218
  * for a warning that the built-in doctrine has been replaced.
206
219
  *
207
- * Skipped while a live signal already holds a value for the session: the
208
- * push is authoritative and may have landed while this fetch was in flight.
220
+ * Every show reads again, and the answer replaces what the store holds: a
221
+ * window not subscribed to the session missed the signals of its rebuilds
222
+ * (`SIGNAL_SCOPE`), so a value held from before can be stale. Dropped when
223
+ * a live signal landed while the read was in flight: the push is newer.
209
224
  *
210
225
  * @param sessionId - The session.
211
- * @param file - The override, or `null` for none.
226
+ * @param read - Reads the override: `null` for none, `undefined` when the host has no answer (no live agent).
212
227
  */
213
- seedSystemMd(sessionId: K, file: SystemMdFile | null): void;
228
+ seedSystemMd(sessionId: K, read: () => Promise<SystemMdFile | null | undefined>): Promise<void>;
214
229
  /**
215
230
  * Stable-reference snapshot of the active `SYSTEM.md` override, for
216
231
  * `useSyncExternalStore` (compared by identity, and the stored object is the
@@ -231,6 +246,12 @@ export declare class SessionStreamStore<K extends string = string> {
231
246
  * @param sessionId - The session, or `null` for none.
232
247
  */
233
248
  hasEvents(sessionId: K | null): boolean;
249
+ /**
250
+ * About how many bytes the session's rows hold (`eventsBytes`): what the prewarm window budgets by.
251
+ *
252
+ * @param sessionId - The session.
253
+ */
254
+ eventBytes(sessionId: K): number;
234
255
  /**
235
256
  * Whether the session's window was hydrated from DISK (`setEventsPage`),
236
257
  * as opposed to merely having a record. `markRunning` and every live
@@ -243,6 +264,12 @@ export declare class SessionStreamStore<K extends string = string> {
243
264
  * @param sessionId - The session, or `null` for none.
244
265
  */
245
266
  isHydrated(sessionId: K | null): boolean;
267
+ /**
268
+ * The sessions whose window was hydrated from disk (see `isHydrated`). An
269
+ * app keeps their live signals coming (`sessions.subscribe`): a window
270
+ * that stops getting them goes stale. `subscribeHas` fires when this changes.
271
+ */
272
+ hydratedSessions(): K[];
246
273
  /**
247
274
  * The session's scrollback bookkeeping (a shared empty state when it was never hydrated). Stable identity until a page write.
248
275
  *
@@ -535,6 +562,18 @@ export declare class SessionStreamStore<K extends string = string> {
535
562
  * turned on. A row that a reload replaced is left alone.
536
563
  */
537
564
  private _bindLocalPrompt;
565
+ /**
566
+ * The loop changed a turn's text after it streamed (`turn:end.text`): the
567
+ * owner's streamed markdown rows of the turn become the saved text blocks,
568
+ * as a reload shows them. A turn with no streamed row here is left alone.
569
+ *
570
+ * @param sessionId - The session.
571
+ * @param owner - `'parent'` or the subagent's id.
572
+ * @param turnId - The turn whose text changed.
573
+ * @param text - The saved text blocks, in order.
574
+ */
575
+ replaceTurnText(sessionId: K, owner: Owner, turnId: string, text: readonly string[]): void;
576
+ private _replaceTurnText;
538
577
  /** Drop a stalled attempt's reasoning lane: the retry (or next model) streams its own, and the saved turn never holds it. */
539
578
  private _discardThinking;
540
579
  /**
@@ -1,9 +1,10 @@
1
1
  import { inheritRowIdentity } from "../transcript/collapse.js";
2
- import { applyLiveEvent, closeThinkingSegment, finishLive } from "./live-events.js";
2
+ import { applyLiveEventToTranscript, endTurnInTranscript, finishLiveTranscript } from "./live-events.js";
3
3
  import { mergeLiveTail } from "./merge.js";
4
4
  import { mergePromptPreviews, missingPreviewData } from "./prompt-previews.js";
5
5
  import { defaultFrameScheduler } from "./scheduler.js";
6
- import { applyHistoryOp, applyHistorySince, dedupeEnvironmentSetups, discardThinking, finalizeStreamingMarkdownForOwner, readFreshness, reconcileEvents } from "zidane/chat/pure";
6
+ import { TranscriptMap } from "./transcript-map.js";
7
+ import { appendTranscriptEvent, applyHistoryOp, applyHistorySince, dedupeEnvironmentSetups, readFreshness, reconcileEvents, transcriptDiscardThinking, transcriptReplaceTurnText } from "zidane/chat/pure";
7
8
  // src/chat/headless/streams/store.ts
8
9
  const PARENT_OWNER = "parent";
9
10
  /** Numberings a window remembers leaving (`_retiredHistoryIds`). */
@@ -72,7 +73,8 @@ const NOTIFY_FALLBACK_MS = 50;
72
73
  * @typeParam K - The session key type (the desktop app's branded `SessionKey`). Default: `string`.
73
74
  */
74
75
  var SessionStreamStore = class {
75
- _events = /* @__PURE__ */ new Map();
76
+ /** Each session's events as a transcript store: a streamed delta copies only the open exchange (`TranscriptMap`). */
77
+ _events = new TranscriptMap();
76
78
  _running = /* @__PURE__ */ new Map();
77
79
  _scheduler;
78
80
  _markdown;
@@ -107,6 +109,8 @@ var SessionStreamStore = class {
107
109
  * guidance — and does so without erroring.
108
110
  */
109
111
  _systemMd = /* @__PURE__ */ new Map();
112
+ /** How many `system-md` signals each session got: a seed read that one landed during is older than it (`seedSystemMd`). */
113
+ _systemMdSignals = /* @__PURE__ */ new Map();
110
114
  /**
111
115
  * Per-session provider-retry state. Cleared on `run:end` rather than
112
116
  * `run:start`: a terminal stream failure never streams again, so run end is
@@ -187,6 +191,16 @@ var SessionStreamStore = class {
187
191
  return this._events.get(sessionId) ?? EMPTY_EVENTS;
188
192
  }
189
193
  /**
194
+ * A session's events as a transcript store (settled exchanges and the open
195
+ * one), for a consumer that derives per exchange. `getEventsSnapshot` is
196
+ * its array (`transcriptOfArray` maps one to the other).
197
+ *
198
+ * @param sessionId - The session.
199
+ */
200
+ getTranscriptSnapshot(sessionId) {
201
+ return this._events.transcript(sessionId);
202
+ }
203
+ /**
190
204
  * Whether a run is in flight for the session.
191
205
  *
192
206
  * @param sessionId - The session, or `null` for none.
@@ -241,14 +255,18 @@ var SessionStreamStore = class {
241
255
  * most common flow rather than an edge case, which is the wrong direction
242
256
  * for a warning that the built-in doctrine has been replaced.
243
257
  *
244
- * Skipped while a live signal already holds a value for the session: the
245
- * push is authoritative and may have landed while this fetch was in flight.
258
+ * Every show reads again, and the answer replaces what the store holds: a
259
+ * window not subscribed to the session missed the signals of its rebuilds
260
+ * (`SIGNAL_SCOPE`), so a value held from before can be stale. Dropped when
261
+ * a live signal landed while the read was in flight: the push is newer.
246
262
  *
247
263
  * @param sessionId - The session.
248
- * @param file - The override, or `null` for none.
264
+ * @param read - Reads the override: `null` for none, `undefined` when the host has no answer (no live agent).
249
265
  */
250
- seedSystemMd(sessionId, file) {
251
- if (this._systemMd.has(sessionId)) return;
266
+ async seedSystemMd(sessionId, read) {
267
+ const signals = this._systemMdSignals.get(sessionId) ?? 0;
268
+ const file = await read();
269
+ if (file === void 0 || (this._systemMdSignals.get(sessionId) ?? 0) !== signals || this._systemMd.get(sessionId) === file) return;
252
270
  this._systemMd.set(sessionId, file);
253
271
  this._notifySession(sessionId);
254
272
  }
@@ -282,6 +300,14 @@ var SessionStreamStore = class {
282
300
  return this._events.has(sessionId);
283
301
  }
284
302
  /**
303
+ * About how many bytes the session's rows hold (`eventsBytes`): what the prewarm window budgets by.
304
+ *
305
+ * @param sessionId - The session.
306
+ */
307
+ eventBytes(sessionId) {
308
+ return this._events.bytes(sessionId);
309
+ }
310
+ /**
285
311
  * Whether the session's window was hydrated from DISK (`setEventsPage`),
286
312
  * as opposed to merely having a record. `markRunning` and every live
287
313
  * signal seed `_events` for a session this window never loaded — a run
@@ -297,6 +323,14 @@ var SessionStreamStore = class {
297
323
  return this._pages.has(sessionId);
298
324
  }
299
325
  /**
326
+ * The sessions whose window was hydrated from disk (see `isHydrated`). An
327
+ * app keeps their live signals coming (`sessions.subscribe`): a window
328
+ * that stops getting them goes stale. `subscribeHas` fires when this changes.
329
+ */
330
+ hydratedSessions() {
331
+ return [...this._pages.keys()];
332
+ }
333
+ /**
300
334
  * The session's scrollback bookkeeping (a shared empty state when it was never hydrated). Stable identity until a page write.
301
335
  *
302
336
  * @param sessionId - The session, or `null` for none.
@@ -737,7 +771,6 @@ var SessionStreamStore = class {
737
771
  */
738
772
  appendUserPrompt(sessionId, text, refs, rawAttachments, clientMessageId) {
739
773
  const had = this._events.has(sessionId);
740
- const events = this._events.get(sessionId)?.slice() ?? [];
741
774
  const attachments = rawAttachments === void 0 || missingPreviewData(rawAttachments) ? mergePromptPreviews(rawAttachments, this.takePromptPreviews(sessionId, text)) : rawAttachments;
742
775
  const event = {
743
776
  kind: "user-prompt",
@@ -745,7 +778,6 @@ var SessionStreamStore = class {
745
778
  ...refs && refs.length > 0 ? { refs: [...refs] } : {},
746
779
  ...attachments && attachments.length > 0 ? { attachments: [...attachments] } : {}
747
780
  };
748
- events.push(event);
749
781
  const pending = this._pendingEcho.get(sessionId) ?? [];
750
782
  pending.push({
751
783
  text,
@@ -753,7 +785,7 @@ var SessionStreamStore = class {
753
785
  event
754
786
  });
755
787
  this._pendingEcho.set(sessionId, pending);
756
- this._events.set(sessionId, events);
788
+ this._events.setTranscript(sessionId, appendTranscriptEvent(this._events.transcriptOrEmpty(sessionId), event));
757
789
  this._notifySession(sessionId);
758
790
  if (!had) this._notifyHas();
759
791
  }
@@ -797,7 +829,8 @@ var SessionStreamStore = class {
797
829
  write(sessionId, patch) {
798
830
  const had = this._events.has(sessionId);
799
831
  const wasHydrated = this._pages.has(sessionId);
800
- if (patch.events !== void 0) this._events.set(sessionId, patch.events);
832
+ if (patch.transcript !== void 0) this._events.setTranscript(sessionId, patch.transcript);
833
+ else if (patch.events !== void 0) this._events.set(sessionId, patch.events);
801
834
  else if (!had) this._events.set(sessionId, []);
802
835
  if (patch.running !== void 0) this._running.set(sessionId, patch.running);
803
836
  if (patch.page === null) this._pages.delete(sessionId);
@@ -813,12 +846,10 @@ var SessionStreamStore = class {
813
846
  */
814
847
  appendErrorEvent(sessionId, text) {
815
848
  const had = this._events.has(sessionId);
816
- const events = this._events.get(sessionId)?.slice() ?? [];
817
- events.push({
849
+ this._events.setTranscript(sessionId, appendTranscriptEvent(this._events.transcriptOrEmpty(sessionId), {
818
850
  kind: "error",
819
851
  text
820
- });
821
- this._events.set(sessionId, events);
852
+ }));
822
853
  this._notifySession(sessionId);
823
854
  if (!had) this._notifyHas();
824
855
  }
@@ -845,16 +876,16 @@ var SessionStreamStore = class {
845
876
  return;
846
877
  case "run:end": {
847
878
  this.runStateVersion++;
848
- const prior = this._events.get(signal.sessionId) ?? [];
849
- let next = finishLive(prior);
850
- if (!signal.ok && signal.error) next = [...next, {
879
+ const prior = this._events.transcriptOrEmpty(signal.sessionId);
880
+ let next = finishLiveTranscript(prior);
881
+ if (!signal.ok && signal.error) next = appendTranscriptEvent(next, {
851
882
  kind: "error",
852
883
  text: signal.error,
853
884
  ...signal.detail ? { detail: signal.detail } : {}
854
- }];
885
+ });
855
886
  const had = this._events.has(signal.sessionId);
856
887
  const wasRunning = this._running.get(signal.sessionId) === true;
857
- this._events.set(signal.sessionId, next);
888
+ this._events.setTranscript(signal.sessionId, next);
858
889
  this._running.set(signal.sessionId, false);
859
890
  const sawStart = this._runStarted.delete(signal.sessionId);
860
891
  const streamed = this._runActivity.delete(signal.sessionId);
@@ -866,10 +897,11 @@ var SessionStreamStore = class {
866
897
  return;
867
898
  }
868
899
  case "turn:end": {
869
- const prior = this._events.get(signal.sessionId) ?? [];
870
900
  const owner = signal.childId ?? PARENT_OWNER;
871
901
  const had = this._events.has(signal.sessionId);
872
- this._events.set(signal.sessionId, finalizeStreamingMarkdownForOwner(closeThinkingSegment(prior, owner), owner));
902
+ if (signal.text && signal.turnId) this._replaceTurnText(signal.sessionId, owner, signal.turnId, signal.text);
903
+ const prior = this._events.transcriptOrEmpty(signal.sessionId);
904
+ this._events.setTranscript(signal.sessionId, endTurnInTranscript(prior, owner));
873
905
  this._notifySession(signal.sessionId);
874
906
  if (!had) this._notifyHas();
875
907
  return;
@@ -898,8 +930,8 @@ var SessionStreamStore = class {
898
930
  };
899
931
  }
900
932
  const had = this._events.has(signal.sessionId);
901
- const prior = this._events.get(signal.sessionId) ?? [];
902
- this._events.set(signal.sessionId, this._append(prior, event));
933
+ const prior = this._events.transcriptOrEmpty(signal.sessionId);
934
+ this._events.setTranscript(signal.sessionId, this._append(prior, event));
903
935
  this._runActivity.add(signal.sessionId);
904
936
  if (this._batch) this._notifySoon(signal.sessionId);
905
937
  else this._notifySession(signal.sessionId);
@@ -928,6 +960,7 @@ var SessionStreamStore = class {
928
960
  return;
929
961
  case "system-md":
930
962
  this._systemMd.set(signal.sessionId, signal.file);
963
+ this._systemMdSignals.set(signal.sessionId, (this._systemMdSignals.get(signal.sessionId) ?? 0) + 1);
931
964
  this._notifySession(signal.sessionId);
932
965
  }
933
966
  }
@@ -942,7 +975,7 @@ var SessionStreamStore = class {
942
975
  if (plan.length === 0) return;
943
976
  const touched = /* @__PURE__ */ new Set();
944
977
  for (const entry of plan) {
945
- const prior = this._events.get(entry.sessionId) ?? [];
978
+ const prior = this._events.transcriptOrEmpty(entry.sessionId);
946
979
  const synthetic = {
947
980
  kind: "markdown",
948
981
  text: entry.text,
@@ -951,7 +984,7 @@ var SessionStreamStore = class {
951
984
  ...entry.depth != null ? { depth: entry.depth } : {},
952
985
  ...entry.turnId ? { turnId: entry.turnId } : {}
953
986
  };
954
- this._events.set(entry.sessionId, this._append(prior, synthetic));
987
+ this._events.setTranscript(entry.sessionId, this._append(prior, synthetic));
955
988
  touched.add(entry.sessionId);
956
989
  }
957
990
  for (const sessionId of touched) this._notifySession(sessionId);
@@ -1063,12 +1096,33 @@ var SessionStreamStore = class {
1063
1096
  this._events.set(sessionId, next);
1064
1097
  this._notifySession(sessionId);
1065
1098
  }
1099
+ /**
1100
+ * The loop changed a turn's text after it streamed (`turn:end.text`): the
1101
+ * owner's streamed markdown rows of the turn become the saved text blocks,
1102
+ * as a reload shows them. A turn with no streamed row here is left alone.
1103
+ *
1104
+ * @param sessionId - The session.
1105
+ * @param owner - `'parent'` or the subagent's id.
1106
+ * @param turnId - The turn whose text changed.
1107
+ * @param text - The saved text blocks, in order.
1108
+ */
1109
+ replaceTurnText(sessionId, owner, turnId, text) {
1110
+ if (this._replaceTurnText(sessionId, owner, turnId, text)) this._notifySession(sessionId);
1111
+ }
1112
+ _replaceTurnText(sessionId, owner, turnId, text) {
1113
+ const events = this._events.transcript(sessionId);
1114
+ if (!events) return false;
1115
+ const next = transcriptReplaceTurnText(events, owner, turnId, text);
1116
+ if (next === events) return false;
1117
+ this._events.setTranscript(sessionId, next);
1118
+ return true;
1119
+ }
1066
1120
  /** Drop a stalled attempt's reasoning lane: the retry (or next model) streams its own, and the saved turn never holds it. */
1067
1121
  _discardThinking(sessionId, source, turnId) {
1068
- const events = this._events.get(sessionId);
1122
+ const events = this._events.transcript(sessionId);
1069
1123
  if (!events) return;
1070
- const next = discardThinking(events, source, turnId);
1071
- if (next !== events) this._events.set(sessionId, next);
1124
+ const next = transcriptDiscardThinking(events, source, turnId);
1125
+ if (next !== events) this._events.setTranscript(sessionId, next);
1072
1126
  }
1073
1127
  /**
1074
1128
  * Append a fresh event with the kit's live rule (`applyLiveEvent`, the
@@ -1080,7 +1134,7 @@ var SessionStreamStore = class {
1080
1134
  * timing of its own).
1081
1135
  */
1082
1136
  _append(events, event) {
1083
- return applyLiveEvent(events, event, Date.now(), this._markdown);
1137
+ return applyLiveEventToTranscript(events, event, Date.now(), this._markdown);
1084
1138
  }
1085
1139
  _notifySession(sessionId) {
1086
1140
  this._pendingNotify.delete(sessionId);
@@ -0,0 +1,57 @@
1
+ import { ChatEvent } from "../host.js";
2
+ import { TranscriptEvents } from "zidane/chat/pure";
3
+ /**
4
+ * The session stream store's events: one transcript store per session
5
+ * (`TranscriptEvents`, settled exchanges and the open one). Reads as a map of
6
+ * arrays (`get`, `set`) for the store's rare whole-window writes, and as
7
+ * transcripts (`transcript`, `setTranscript`) for the streaming hot path,
8
+ * where a delta copies only the open exchange. An array read is made once per
9
+ * write, and `set` of an array keeps it as given (`get` returns it).
10
+ */
11
+ export declare class TranscriptMap<K> {
12
+ private readonly map;
13
+ /** Sessions held. */
14
+ get size(): number;
15
+ /**
16
+ * The session's events as one array (the same array until the next write).
17
+ *
18
+ * @param sessionId - The session.
19
+ */
20
+ get(sessionId: K): ChatEvent[] | undefined;
21
+ /**
22
+ * Sets the session's events; the exchanges they keep unchanged keep their chunks.
23
+ *
24
+ * @param sessionId - The session.
25
+ * @param events - The events. Never changed afterwards.
26
+ */
27
+ set(sessionId: K, events: readonly ChatEvent[]): this;
28
+ /**
29
+ * The session's transcript store, if held.
30
+ *
31
+ * @param sessionId - The session.
32
+ */
33
+ transcript(sessionId: K): TranscriptEvents<ChatEvent> | undefined;
34
+ /**
35
+ * The session's transcript store, or an empty one.
36
+ *
37
+ * @param sessionId - The session.
38
+ */
39
+ transcriptOrEmpty(sessionId: K): TranscriptEvents<ChatEvent>;
40
+ /**
41
+ * Sets the session's transcript store.
42
+ *
43
+ * @param sessionId - The session.
44
+ * @param transcript - The transcript.
45
+ */
46
+ setTranscript(sessionId: K, transcript: TranscriptEvents<ChatEvent>): this;
47
+ /**
48
+ * About how many bytes the session's rows hold: each settled exchange is measured once.
49
+ *
50
+ * @param sessionId - The session.
51
+ */
52
+ bytes(sessionId: K): number;
53
+ has(sessionId: K): boolean;
54
+ delete(sessionId: K): boolean;
55
+ clear(): void;
56
+ keys(): IterableIterator<K>;
57
+ }
@@ -0,0 +1,85 @@
1
+ import { transcriptBytes } from "./event-bytes.js";
2
+ import { emptyTranscript, transcriptArray, transcriptFromArray } from "zidane/chat/pure";
3
+ // src/chat/headless/streams/transcript-map.ts
4
+ /**
5
+ * The session stream store's events: one transcript store per session
6
+ * (`TranscriptEvents`, settled exchanges and the open one). Reads as a map of
7
+ * arrays (`get`, `set`) for the store's rare whole-window writes, and as
8
+ * transcripts (`transcript`, `setTranscript`) for the streaming hot path,
9
+ * where a delta copies only the open exchange. An array read is made once per
10
+ * write, and `set` of an array keeps it as given (`get` returns it).
11
+ */
12
+ var TranscriptMap = class {
13
+ map = /* @__PURE__ */ new Map();
14
+ /** Sessions held. */
15
+ get size() {
16
+ return this.map.size;
17
+ }
18
+ /**
19
+ * The session's events as one array (the same array until the next write).
20
+ *
21
+ * @param sessionId - The session.
22
+ */
23
+ get(sessionId) {
24
+ const transcript = this.map.get(sessionId);
25
+ return transcript ? transcriptArray(transcript) : void 0;
26
+ }
27
+ /**
28
+ * Sets the session's events; the exchanges they keep unchanged keep their chunks.
29
+ *
30
+ * @param sessionId - The session.
31
+ * @param events - The events. Never changed afterwards.
32
+ */
33
+ set(sessionId, events) {
34
+ this.map.set(sessionId, transcriptFromArray(events, this.map.get(sessionId)));
35
+ return this;
36
+ }
37
+ /**
38
+ * The session's transcript store, if held.
39
+ *
40
+ * @param sessionId - The session.
41
+ */
42
+ transcript(sessionId) {
43
+ return this.map.get(sessionId);
44
+ }
45
+ /**
46
+ * The session's transcript store, or an empty one.
47
+ *
48
+ * @param sessionId - The session.
49
+ */
50
+ transcriptOrEmpty(sessionId) {
51
+ return this.map.get(sessionId) ?? emptyTranscript();
52
+ }
53
+ /**
54
+ * Sets the session's transcript store.
55
+ *
56
+ * @param sessionId - The session.
57
+ * @param transcript - The transcript.
58
+ */
59
+ setTranscript(sessionId, transcript) {
60
+ this.map.set(sessionId, transcript);
61
+ return this;
62
+ }
63
+ /**
64
+ * About how many bytes the session's rows hold: each settled exchange is measured once.
65
+ *
66
+ * @param sessionId - The session.
67
+ */
68
+ bytes(sessionId) {
69
+ const transcript = this.map.get(sessionId);
70
+ return transcript ? transcriptBytes(transcript) : 0;
71
+ }
72
+ has(sessionId) {
73
+ return this.map.has(sessionId);
74
+ }
75
+ delete(sessionId) {
76
+ return this.map.delete(sessionId);
77
+ }
78
+ clear() {
79
+ this.map.clear();
80
+ }
81
+ keys() {
82
+ return this.map.keys();
83
+ }
84
+ };
85
+ export { TranscriptMap };
@@ -2,8 +2,10 @@ import { Transcript, TranscriptState } from "../host.js";
2
2
  import { SessionStreamStore } from "./store.js";
3
3
  /**
4
4
  * A session's {@link TranscriptState} read off the store, reusing `prev` while
5
- * none of its parts changed (snapshots compare by identity).
5
+ * none of its parts changed (snapshots compare by identity). It carries the
6
+ * store's transcript (`transcript`); `events`, one array of it, is made on
7
+ * first read, so a reader of `transcript` never pays for a copy per delta.
6
8
  */
7
9
  export declare function transcriptSnapshot<K extends string>(store: SessionStreamStore<K>, sessionId: K, prev: TranscriptState | undefined): TranscriptState;
8
10
  /** A session's transcript as the components read it: a store over the session's slice, subscribed to that session only. */
9
- export declare function storeTranscript<K extends string>(store: SessionStreamStore<K>, sessionId: K, loadEarlier?: () => void): Transcript;
11
+ export declare function storeTranscript<K extends string>(store: SessionStreamStore<K>, sessionId: K, loadEarlier?: () => void, more?: Pick<Transcript, 'loadThrough' | 'outline'>): Transcript;
@@ -1,29 +1,41 @@
1
+ import { emptyTranscript, transcriptArray } from "zidane/chat/pure";
1
2
  // src/chat/headless/streams/transcript.ts
3
+ /** The transcript of a session the store holds nothing for: one object, so a reader's memo holds. */
4
+ const NO_TRANSCRIPT = emptyTranscript();
2
5
  /**
3
6
  * A session's {@link TranscriptState} read off the store, reusing `prev` while
4
- * none of its parts changed (snapshots compare by identity).
7
+ * none of its parts changed (snapshots compare by identity). It carries the
8
+ * store's transcript (`transcript`); `events`, one array of it, is made on
9
+ * first read, so a reader of `transcript` never pays for a copy per delta.
5
10
  */
6
11
  function transcriptSnapshot(store, sessionId, prev) {
7
- const events = store.getEventsSnapshot(sessionId);
12
+ const transcript = store.getTranscriptSnapshot(sessionId) ?? NO_TRANSCRIPT;
8
13
  const running = store.getRunningSnapshot(sessionId);
9
14
  const hydrated = store.isHydrated(sessionId);
10
15
  const page = store.getPageSnapshot(sessionId);
11
- if (prev && prev.events === events && prev.running === running && prev.hydrated === hydrated && prev.hasEarlier === page.hasMore && prev.loadingEarlier === page.loadingEarlier) return prev;
12
- return {
13
- events,
16
+ if (prev && prev.transcript === transcript && prev.running === running && prev.hydrated === hydrated && prev.hasEarlier === page.hasMore && prev.loadingEarlier === page.loadingEarlier) return prev;
17
+ const state = {
18
+ get events() {
19
+ return transcriptArray(transcript);
20
+ },
14
21
  running,
15
22
  hydrated,
16
23
  hasEarlier: page.hasMore,
17
24
  loadingEarlier: page.loadingEarlier
18
25
  };
26
+ return Object.defineProperty(state, "transcript", {
27
+ value: transcript,
28
+ enumerable: false
29
+ });
19
30
  }
20
31
  /** A session's transcript as the components read it: a store over the session's slice, subscribed to that session only. */
21
- function storeTranscript(store, sessionId, loadEarlier) {
32
+ function storeTranscript(store, sessionId, loadEarlier, more = {}) {
22
33
  let last;
23
34
  return {
24
35
  get: () => last = transcriptSnapshot(store, sessionId, last),
25
36
  subscribe: (onChange) => store.subscribeSession(sessionId, onChange),
26
- ...loadEarlier ? { loadEarlier } : {}
37
+ ...loadEarlier ? { loadEarlier } : {},
38
+ ...more
27
39
  };
28
40
  }
29
41
  export { storeTranscript, transcriptSnapshot };
@@ -69,13 +69,14 @@ export type SessionStreamSignal<K extends string = string> = {
69
69
  error?: string;
70
70
  detail?: StreamEvent['detail'];
71
71
  } |
72
- /** A turn of the parent (or of the subagent `childId`) ended: its streaming markdown is final. */
72
+ /** A turn of the parent (or of the subagent `childId`) ended: its streaming markdown is final, and is `text` when the host sends it (the saved text blocks, when the loop changed them after they streamed). */
73
73
  {
74
74
  kind: 'turn:end';
75
75
  sessionId: K;
76
76
  turnId?: string;
77
77
  childId?: string;
78
78
  depth?: number;
79
+ text?: string[];
79
80
  } |
80
81
  /** A transcript event; `echo` marks the host repeating a prompt this client may have shown already. */
81
82
  {
@@ -1,4 +1,4 @@
1
- import { spawnParents, summarizeTools } from "zidane/chat/pure";
1
+ import { noteTranscriptPass, spawnParents, summarizeTools } from "zidane/chat/pure";
2
2
  // src/chat/headless/transcript/batch.ts
3
3
  /**
4
4
  * Group contiguous rows with the same `childId` so the renderer can
@@ -14,6 +14,7 @@ import { spawnParents, summarizeTools } from "zidane/chat/pure";
14
14
  * @param rows - The transcript rows, oldest first.
15
15
  */
16
16
  function clusterByOwner(rows) {
17
+ noteTranscriptPass("cluster", rows.length);
17
18
  const out = [];
18
19
  const parents = spawnParents(rows);
19
20
  const present = /* @__PURE__ */ new Set();
@@ -243,6 +244,7 @@ function liftExchangeToolGroups(rows) {
243
244
  * @param groupToolCalls - Lifts parent-owned tool calls into one group per exchange before batching adjacent runs. Defaults to `false`.
244
245
  */
245
246
  function batchToolRuns(rows, groupToolCalls = false) {
247
+ noteTranscriptPass("batch:tools", rows.length);
246
248
  const pre = groupToolCalls ? liftExchangeToolGroups(rows) : rows;
247
249
  const out = [];
248
250
  const used = /* @__PURE__ */ new Set();
@@ -311,6 +313,7 @@ const THINKING_CHAIN_TRANSPARENT = /* @__PURE__ */ new Set(["tool", "tool-batch"
311
313
  * @param rows - The transcript rows after {@link batchToolRuns}, oldest first.
312
314
  */
313
315
  function batchThinkingRuns(rows) {
316
+ noteTranscriptPass("batch:thinking", rows.length);
314
317
  const out = [];
315
318
  const used = /* @__PURE__ */ new Set();
316
319
  let chain = [];
@@ -366,6 +369,7 @@ const TASK_BATCH_IDS = new IdHold();
366
369
  * @param rows - The transcript rows, oldest first.
367
370
  */
368
371
  function batchTaskRuns(rows) {
372
+ noteTranscriptPass("batch:tasks", rows.length);
369
373
  const out = [];
370
374
  const used = /* @__PURE__ */ new Set();
371
375
  let burst = [];
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Media the session store holds by content hash (its blob table): a turn
3
+ * names such a block `attachment://<hash>`, on a prompt's attachment
4
+ * (`ChatAttachment.ref`) and in a tool result's stand-in line
5
+ * (`[image: image/png, ref attachment://<hash>]`). An app that serves blobs
6
+ * (`TranscriptActions.blobMediaUrl`) loads them by hash: the same bytes for
7
+ * good, so the page caches them for good. Blocks still inline keep the
8
+ * app's older addresses (by call and position, by turn).
9
+ */
10
+ /**
11
+ * The blob hash an `attachment://<hash>` handle names, or `undefined` for anything else.
12
+ *
13
+ * @param ref - A block's ref.
14
+ */
15
+ export declare function blobHashOf(ref: string | undefined): string | undefined;