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
@@ -13,6 +13,12 @@
13
13
  * notifications go out at once (the store batches transcript events per
14
14
  * frame), a run's end neither appends an error row nor drops pending echoes,
15
15
  * and long messages split at the reducer's default size.
16
+ *
17
+ * Every write that follows the stream goes through the store's transcript
18
+ * reducers (a delta copies the open exchange, a run's end finishes the
19
+ * exchanges still live), and a transcript's state carries the store's
20
+ * transcript (`TranscriptState.transcript`): no write or read of the
21
+ * stream makes a whole-session array.
16
22
  */
17
23
  import { ChatAttachment, ChatEvent, ChatInteraction, ChatSession, ChatSessionStatus, Transcript, TranscriptState } from "../chat/headless/host.js";
18
24
  import { Readable, Writable } from "../chat/headless/store.js";
@@ -63,6 +69,8 @@ export interface LiveState {
63
69
  tailDue: (sessionId: string) => boolean;
64
70
  /** A live event from the agent; `echo` marks the host repeating a prompt (dropped when this client echoed it). */
65
71
  apply: (sessionId: string, event: ChatEvent, echo?: boolean) => void;
72
+ /** The loop changed a turn's text after it streamed (`turn:end.text`): its streamed rows become the saved text blocks. `childId`: a subagent's turn. */
73
+ replaceTurnText: (sessionId: string, turnId: string, text: readonly string[], childId?: string) => void;
66
74
  /** Show the user's prompt at once (with its attachment previews); the host's echo of it is then dropped. */
67
75
  echoPrompt: (sessionId: string, text: string, attachments?: readonly ChatAttachment[]) => void;
68
76
  /** A run started or ended; the session's status follows (`status` overrides: `'error'`, `'idle'` after an interrupt). */
@@ -1,7 +1,8 @@
1
1
  import { writable } from "../chat/headless/store.js";
2
- import { applyLiveEvent, finishLive } from "../chat/headless/streams/live-events.js";
2
+ import { applyLiveEvent, finishLive, finishLiveTranscript } from "../chat/headless/streams/live-events.js";
3
3
  import { SessionStreamStore } from "../chat/headless/streams/store.js";
4
4
  import { transcriptSnapshot } from "../chat/headless/streams/transcript.js";
5
+ import { transcriptOfArray } from "zidane/chat/pure";
5
6
  // src/adapters/live.ts
6
7
  /** Closed sessions whose windows stay, most recent first: the desktop's prewarm window (`sidebar/directory.ts`) less the open one. */
7
8
  const RECENT_KEPT = 12;
@@ -108,7 +109,9 @@ function createLiveState(options = {}) {
108
109
  const t = transcript(sessionId);
109
110
  t.echoes = [];
110
111
  t.state.set((s) => ({
111
- ...s,
112
+ running: s.running,
113
+ hasEarlier: s.hasEarlier,
114
+ loadingEarlier: s.loadingEarlier,
112
115
  ...patch,
113
116
  events: [...events],
114
117
  hydrated: true
@@ -130,16 +133,22 @@ function createLiveState(options = {}) {
130
133
  ...echo ? { echo } : {}
131
134
  });
132
135
  },
136
+ replaceTurnText(sessionId, turnId, text, childId) {
137
+ store.replaceTurnText(sessionId, childId ?? "parent", turnId, text);
138
+ },
133
139
  echoPrompt(sessionId, text, attachments) {
134
140
  transcript(sessionId);
135
141
  store.appendUserPrompt(sessionId, text, void 0, attachments ?? []);
136
142
  },
137
143
  setRunning(sessionId, running, status) {
138
- transcript(sessionId).state.set((s) => s.running === running ? s : {
139
- ...s,
140
- running,
141
- events: running ? s.events : finishLive(s.events)
142
- });
144
+ transcript(sessionId);
145
+ if (store.getRunningSnapshot(sessionId) !== running) {
146
+ const prior = store.getTranscriptSnapshot(sessionId);
147
+ store.write(sessionId, {
148
+ running,
149
+ ...!running && prior ? { transcript: finishLiveTranscript(prior) } : {}
150
+ });
151
+ }
143
152
  patchSession(sessionId, {
144
153
  status: status ?? (running ? "running" : "completed"),
145
154
  updatedAt: Date.now()
@@ -185,8 +194,10 @@ function transcriptState(store, sessionId) {
185
194
  const prev = get();
186
195
  const resolved = typeof next === "function" ? next(prev) : next;
187
196
  if (Object.is(resolved, prev)) return;
197
+ const kept = resolved.transcript === prev.transcript;
198
+ const events = resolved.transcript && !kept ? { transcript: resolved.transcript } : (prev.transcript ? transcriptOfArray(resolved.events) !== prev.transcript : resolved.events !== prev.events) ? { events: resolved.events } : null;
188
199
  store.write(sessionId, {
189
- ...resolved.events !== prev.events ? { events: resolved.events } : {},
200
+ ...events,
190
201
  running: resolved.running,
191
202
  page: resolved.hydrated ? {
192
203
  firstSeq: store.getPageSnapshot(sessionId).firstSeq,
@@ -1,7 +1,7 @@
1
1
  import { createResourceStore, readableResource } from "../app/headless/resource.js";
2
2
  import { createModelPickerPrefs } from "../chat/headless/composer/model-picker-prefs.js";
3
3
  import { createRunMeter } from "../chat/headless/composer/run-meter.js";
4
- import { fmtTokens, formatCostLabel } from "zidane/chat/pure";
4
+ import { createDraftAttachmentCodec, fmtTokens, formatCostLabel } from "zidane/chat/pure";
5
5
  // src/adapters/server-composer-host.ts
6
6
  /** A resource's data seen through `map`; each snapshot maps once, so readers see a stable value. */
7
7
  function mapped(resource, map) {
@@ -116,6 +116,11 @@ function createServerComposerHost(options) {
116
116
  return () => void listeners.delete(filtered);
117
117
  };
118
118
  let seq = 0;
119
+ /** Draft attachments are chips on the wire: each file's bytes go up or come down once. */
120
+ const draftFiles = createDraftAttachmentCodec({
121
+ put: (file) => client.call("attachments.put", file),
122
+ get: (hash) => client.call("attachments.get", { hash })
123
+ });
119
124
  /** Each session's fields a `#` reference shows: a row change that moves none of them (a write to its history, a run) reads nothing again. */
120
125
  const chatKeys = /* @__PURE__ */ new Map();
121
126
  const chatsMoved = (signal) => {
@@ -191,7 +196,13 @@ function createServerComposerHost(options) {
191
196
  };
192
197
  return {
193
198
  drafts: {
194
- get: async (sessionId) => client.call("drafts.get", { sessionId }),
199
+ get: async (sessionId) => {
200
+ const { attachments, ...draft } = await client.call("drafts.get", { sessionId });
201
+ return attachments?.length ? {
202
+ ...draft,
203
+ attachments: await draftFiles.toFiles(attachments)
204
+ } : draft;
205
+ },
195
206
  set: async (sessionId, text, shell) => {
196
207
  await client.call("drafts.set", {
197
208
  sessionId,
@@ -199,21 +210,23 @@ function createServerComposerHost(options) {
199
210
  ...shell !== void 0 ? { shell } : {}
200
211
  });
201
212
  },
202
- setAttachments: async (sessionId, attachments) => {
213
+ setAttachments: (sessionId, attachments) => draftFiles.inOrder(`published:${sessionId}`, async () => {
203
214
  await client.call("drafts.setAttachments", {
204
215
  sessionId,
205
- attachments
216
+ attachments: await draftFiles.toChips(attachments)
206
217
  });
207
- },
218
+ }),
208
219
  onChanged: (listener) => on(["draft:changed"], ({ sessionId, text, shell }) => listener({
209
220
  sessionId,
210
221
  text,
211
222
  ...shell !== void 0 ? { shell } : {}
212
223
  })),
213
- onAttachmentsChanged: (listener) => on(["draft:attachments"], ({ sessionId, attachments }) => listener({
214
- sessionId,
215
- attachments
216
- }))
224
+ onAttachmentsChanged: (listener) => on(["draft:attachments"], ({ sessionId, attachments }) => {
225
+ draftFiles.inOrder(`received:${sessionId}`, () => draftFiles.toFiles(attachments)).then((files) => listener({
226
+ sessionId,
227
+ attachments: files
228
+ }), () => void 0);
229
+ })
217
230
  },
218
231
  completions: {
219
232
  ...client.can("files.list") ? { files: async (root) => root ? resources.fetch(filesSpec(root)) : [] } : {},
@@ -138,8 +138,11 @@ function createServerGitHost(options) {
138
138
  };
139
139
  }
140
140
  },
141
- async environments({ cwd }) {
142
- return client.call("environments.list", cwd ? { cwd } : {});
141
+ async environments({ cwd, machineOnly }) {
142
+ return client.call("environments.list", {
143
+ ...cwd ? { cwd } : {},
144
+ ...machineOnly ? { machineOnly: true } : {}
145
+ });
143
146
  },
144
147
  subscribeEnvironments(_query, onChange) {
145
148
  const offSignal = client.onSignal((signal) => {
@@ -1,10 +1,12 @@
1
+ import { sliceToolOutput } from "../chat/headless/output-pager.js";
1
2
  import { promptOriginWire } from "../chat/headless/prompt-origin.js";
2
3
  import { wireOriginal } from "../chat/headless/send-flow.js";
3
4
  import { applyInboxPatch } from "../chat/headless/sidebar/inbox-state.js";
4
5
  import { writable } from "../chat/headless/store.js";
6
+ import "../chat/headless/streams/session-streams.js";
5
7
  import { createLiveState } from "./live.js";
6
8
  import { createServerClient } from "./server-client.js";
7
- import { mediaTicketOf, messageMediaAddress } from "./server-media.js";
9
+ import { blobMediaAddress, mediaTicketOf, messageMediaAddress } from "./server-media.js";
8
10
  import { createServerTranscriptMembers } from "./server-transcript-members.js";
9
11
  import { climbReconnectLadder, createRecentChanges, cursorValid, messageMediaOf } from "zidane/chat/pure";
10
12
  // src/adapters/server-host.ts
@@ -100,18 +102,43 @@ function createServerHost(options) {
100
102
  /** A session's signals that arrive while its reconnect ladder runs (`resume`), applied after what it brings. */
101
103
  const resuming = /* @__PURE__ */ new Map();
102
104
  const models = writable([]);
105
+ let subscribing = Promise.resolve();
106
+ /** The watched sessions whose run in flight the host can replay, as of the last subscription (`runReplay`). */
107
+ let runsInFlight = /* @__PURE__ */ new Set();
108
+ const syncSubscriptions = () => {
109
+ subscribing = subscribing.then(() => client.call("sessions.subscribe", { sessionIds: [...watched] }).then((result) => {
110
+ runsInFlight = new Set(result?.running ?? []);
111
+ }, onError));
112
+ return subscribing;
113
+ };
103
114
  const state = createLiveState({
104
115
  onOpen: (sessionId) => {
105
116
  watched.add(sessionId);
106
- if (client.hello()) hydrate(sessionId).catch(onError);
117
+ if (client.hello()) {
118
+ syncSubscriptions();
119
+ hydrate(sessionId).catch(onError);
120
+ }
121
+ },
122
+ onClose: (sessionId) => {
123
+ watched.delete(sessionId);
124
+ if (client.hello()) syncSubscriptions();
107
125
  },
108
- onClose: (sessionId) => watched.delete(sessionId),
109
126
  evict: true
110
127
  });
111
128
  /** The changes applied while the list is read again. They are newer than its answer (`createRecentChanges`). */
112
129
  const listChanges = createRecentChanges();
113
130
  /** Each session's folder, from its rows: a message's relative media path resolves against it. */
114
131
  const folders = /* @__PURE__ */ new Map();
132
+ const refresh = async () => {
133
+ const reading = listChanges.begin();
134
+ try {
135
+ const rows = await client.call("sessions.list", { archive: "all" });
136
+ for (const row of rows) folders.set(row.id, row.cwd ?? row.projectRoot ?? "");
137
+ state.sessions.set(listChanges.end(reading, rows.map(toChatSession), (list, session, id) => session ? withSession(list, session) : withoutSession(list, id)));
138
+ } finally {
139
+ listChanges.drop(reading);
140
+ }
141
+ };
115
142
  const changed = /* @__PURE__ */ new Set();
116
143
  const facetListeners = /* @__PURE__ */ new Set();
117
144
  const onSignal = (signal, meta) => {
@@ -123,7 +150,7 @@ function createServerHost(options) {
123
150
  });
124
151
  return;
125
152
  }
126
- if ((signal.kind === "event" || signal.kind === "run:start" || signal.kind === "run:end" || signal.kind === "history:changed") && hydrating.has(signal.sessionId)) {
153
+ if ((signal.kind === "event" || signal.kind === "run:start" || signal.kind === "run:end" || signal.kind === "turn:end" || signal.kind === "history:changed") && hydrating.has(signal.sessionId)) {
127
154
  hydrating.get(signal.sessionId).push({
128
155
  signal,
129
156
  ...meta ? { meta } : {}
@@ -143,6 +170,9 @@ function createServerHost(options) {
143
170
  if (state.takeRefetchDue(signal.sessionId) && watched.has(signal.sessionId)) reread(signal.sessionId);
144
171
  }
145
172
  return;
173
+ case "turn:end":
174
+ if (signal.text) state.replaceTurnText(signal.sessionId, signal.turnId, signal.text, signal.childId);
175
+ return;
146
176
  case "interaction:request":
147
177
  state.addInteraction(signal.sessionId, signal.request);
148
178
  return;
@@ -175,13 +205,16 @@ function createServerHost(options) {
175
205
  for (const listener of [...changed]) listener(change);
176
206
  return;
177
207
  }
208
+ case "members:changed":
209
+ refresh().catch(() => {});
210
+ return;
178
211
  case "history:changed": if (watched.has(signal.sessionId) && state.applyHistory(signal.sessionId, signal)) reread(signal.sessionId);
179
212
  }
180
213
  };
181
- const loadPage = async (sessionId, before) => {
214
+ const loadPage = async (sessionId, before, limit = PAGE_TURNS) => {
182
215
  return client.call("sessions.loadEvents", {
183
216
  sessionId,
184
- limit: PAGE_TURNS,
217
+ limit,
185
218
  ...before !== void 0 ? { before } : {}
186
219
  });
187
220
  };
@@ -189,27 +222,72 @@ function createServerHost(options) {
189
222
  const buffered = [];
190
223
  hydrating.set(sessionId, buffered);
191
224
  let stale = false;
225
+ let replay = [];
192
226
  try {
227
+ await subscribing;
228
+ const run = runReplay(sessionId);
193
229
  const page = await loadPage(sessionId);
194
230
  const running = await client.call("chat.isRunning", { sessionId });
195
231
  stale = !state.hydrate(sessionId, page.events, {
196
232
  running,
197
233
  hasEarlier: page.cursor !== void 0
198
234
  }, page.pos, page.historyId);
199
- if (!stale) cursors.set(sessionId, {
200
- before: page.cursor,
201
- ...page.pos !== void 0 ? { pos: page.pos } : {},
202
- ...page.pos !== void 0 && page.historyId !== void 0 ? { historyId: page.historyId } : {}
203
- });
235
+ if (!stale) {
236
+ cursors.set(sessionId, {
237
+ before: page.cursor,
238
+ ...page.pos !== void 0 ? { pos: page.pos } : {},
239
+ ...page.pos !== void 0 && page.historyId !== void 0 ? { historyId: page.historyId } : {}
240
+ });
241
+ replay = await run;
242
+ }
204
243
  } finally {
205
244
  if (hydrating.get(sessionId) === buffered) hydrating.delete(sessionId);
206
- for (const { signal, meta } of buffered) onSignal(signal, meta);
245
+ for (const { signal, meta } of inSeqOrder(replay, buffered)) onSignal(signal, meta);
207
246
  }
208
247
  if (stale && attempts > 1) return hydrate(sessionId, attempts - 1);
209
248
  const interactions = await client.call("interactions.list", { sessionId });
210
249
  for (const i of state.pending(sessionId).get()) state.resolveInteraction(i.requestId);
211
250
  for (const i of interactions) state.addInteraction(sessionId, i.request);
212
251
  }
252
+ /** `replay` and `buffered` merged by number, each number once (the replay's copy); an unnumbered signal keeps its place. */
253
+ function inSeqOrder(replay, buffered) {
254
+ const replayed = new Set(replay.map((entry) => entry.seq));
255
+ const out = [];
256
+ let next = 0;
257
+ for (const entry of buffered) {
258
+ if (entry.meta !== void 0) {
259
+ while (next < replay.length && replay[next].seq <= entry.meta.seq) out.push({
260
+ signal: replay[next].signal,
261
+ meta: { seq: replay[next++].seq }
262
+ });
263
+ if (replayed.has(entry.meta.seq)) continue;
264
+ }
265
+ out.push(entry);
266
+ }
267
+ for (; next < replay.length; next++) out.push({
268
+ signal: replay[next].signal,
269
+ meta: { seq: replay[next].seq }
270
+ });
271
+ return out;
272
+ }
273
+ /**
274
+ * What the session's run in flight streamed and did not save yet
275
+ * (`sessions.resume` with `run`): the text of the step in flight, which the
276
+ * page a window reads cannot hold. Its transcript events only, by number.
277
+ * Asked only for a session the subscription answered as running. Empty when
278
+ * no run is in flight, or the server has none to give.
279
+ */
280
+ async function runReplay(sessionId) {
281
+ const from = client.hello()?.signalEpoch;
282
+ if (from === void 0 || !runsInFlight.has(sessionId)) return [];
283
+ const result = await client.call("sessions.resume", {
284
+ sessionId,
285
+ epoch: from,
286
+ afterSeq: -1,
287
+ run: true
288
+ }).catch(() => null);
289
+ return result?.ok && typeof result.through === "number" ? result.signals.filter((entry) => entry.signal.kind === "event") : [];
290
+ }
213
291
  /**
214
292
  * Reads a transcript again for a signal (a rewrite, a missed write, a run's end). One such read per session is in
215
293
  * flight. A read asked for while another runs is made when the first ends, if the first did not bring the window up
@@ -249,6 +327,7 @@ function createServerHost(options) {
249
327
  for (const { signal, meta } of held) if (meta === void 0 || meta.seq > replayedTo) onSignal(signal, meta);
250
328
  }
251
329
  };
330
+ await subscribing;
252
331
  const outcome = await climbReconnectLadder(bookmark, {
253
332
  resume: async (from, afterSeq) => {
254
333
  const result = await client.call("sessions.resume", {
@@ -295,24 +374,25 @@ function createServerHost(options) {
295
374
  }
296
375
  await hydrate(sessionId);
297
376
  };
298
- const loadEarlier = async (sessionId) => {
377
+ /** Splices the page before the window in; `true` when it did. `limit`: its turns (default a page's). */
378
+ const loadEarlier = async (sessionId, limit) => {
299
379
  const cursor = cursors.get(sessionId);
300
380
  const before = cursor?.before;
301
381
  const t = state.transcript(sessionId).state;
302
- if (before === void 0 || t.get().loadingEarlier) return;
382
+ if (before === void 0 || t.get().loadingEarlier) return false;
303
383
  t.set((s) => ({
304
384
  ...s,
305
385
  loadingEarlier: true
306
386
  }));
307
387
  try {
308
- const page = await loadPage(sessionId, before);
388
+ const page = await loadPage(sessionId, before, limit);
309
389
  if (!cursorValid(cursor?.pos, page, cursor?.historyId)) {
310
390
  t.set((s) => ({
311
391
  ...s,
312
392
  loadingEarlier: false
313
393
  }));
314
394
  await hydrate(sessionId);
315
- return;
395
+ return false;
316
396
  }
317
397
  cursors.set(sessionId, {
318
398
  before: page.cursor,
@@ -325,24 +405,40 @@ function createServerHost(options) {
325
405
  hasEarlier: page.cursor !== void 0,
326
406
  loadingEarlier: false
327
407
  }));
408
+ return true;
328
409
  } catch (error) {
329
410
  t.set((s) => ({
330
411
  ...s,
331
412
  loadingEarlier: false
332
413
  }));
333
414
  onError(error);
415
+ return false;
334
416
  }
335
417
  };
336
- const refresh = async () => {
337
- const reading = listChanges.begin();
338
- try {
339
- const rows = await client.call("sessions.list", { archive: "all" });
340
- for (const row of rows) folders.set(row.id, row.cwd ?? row.projectRoot ?? "");
341
- state.sessions.set(listChanges.end(reading, rows.map(toChatSession), (list, session, id) => session ? withSession(list, session) : withoutSession(list, id)));
342
- } finally {
343
- listChanges.drop(reading);
418
+ /** Loads the earlier pages up to turn position `index`, the gap at once (`Transcript.loadThrough`). */
419
+ const loadThrough = async (sessionId, index) => {
420
+ for (;;) {
421
+ const before = cursors.get(sessionId)?.before;
422
+ if (before === void 0 || before <= index) return before === void 0 ? state.transcript(sessionId).state.get().hydrated : true;
423
+ if (!await loadEarlier(sessionId, Math.min(before - index, 1e3))) return false;
344
424
  }
345
425
  };
426
+ /** The prompt outline (`sessions.loadEvents` with `outline`); `null` from a server from before it. */
427
+ const outline = async (sessionId) => {
428
+ const page = await client.call("sessions.loadEvents", {
429
+ sessionId,
430
+ outline: true,
431
+ limit: 1
432
+ });
433
+ return page.outline ? {
434
+ prompts: page.outline,
435
+ ...page.pos !== void 0 ? { pos: page.pos } : {},
436
+ ...page.floor !== void 0 ? { floor: page.floor } : {},
437
+ ...page.historyId !== void 0 ? { historyId: page.historyId } : {}
438
+ } : null;
439
+ };
440
+ /** Each session's transcript, one object per readable the state holds (readers memo on it; an evicted one goes with it). */
441
+ const transcripts = /* @__PURE__ */ new WeakMap();
346
442
  /** A session's row from a change signal, in place (a new one first). */
347
443
  function upsertSession(session) {
348
444
  return state.sessions.set((all) => withSession(all, session));
@@ -370,6 +466,7 @@ function createServerHost(options) {
370
466
  if (epoch === void 0 || hello.signalEpoch !== epoch) seqs.clear();
371
467
  epoch = hello.signalEpoch;
372
468
  loadModels().catch(onError);
469
+ if (watched.size > 0) syncSubscriptions();
373
470
  if (!reconnected) return;
374
471
  refresh().catch(onError);
375
472
  for (const bookmark of bookmarks) resume(bookmark.sessionId, bookmark).catch(onError);
@@ -517,7 +614,19 @@ function createServerHost(options) {
517
614
  setSpace: (spaceId) => client.call("sidebar.setSpace", { spaceId })
518
615
  } } : {}
519
616
  },
520
- transcript: (sessionId) => state.readable(sessionId, { loadEarlier: () => void loadEarlier(sessionId) }),
617
+ transcript: (sessionId) => {
618
+ const readable = state.readable(sessionId, { loadEarlier: () => void loadEarlier(sessionId) });
619
+ let transcript = transcripts.get(readable);
620
+ if (!transcript) {
621
+ transcript = {
622
+ ...readable,
623
+ loadThrough: (index) => loadThrough(sessionId, index),
624
+ outline: () => outline(sessionId)
625
+ };
626
+ transcripts.set(readable, transcript);
627
+ }
628
+ return transcript;
629
+ },
521
630
  async send({ sessionId, prompt, attachments, model, thinking, activatedSkills, echo, keepDraft, delivery, origin, literal }) {
522
631
  if (echo !== false && !delivery) state.echoPrompt(sessionId, prompt, attachments?.map(({ original: _original, ...a }) => a));
523
632
  await applyChoice(sessionId, model, thinking);
@@ -582,9 +691,27 @@ function createServerHost(options) {
582
691
  }
583
692
  },
584
693
  models,
585
- toolOutput: (sessionId, callId) => client.call("sessions.getToolResult", {
694
+ toolOutput: async (sessionId, callId) => {
695
+ const text = await client.call("sessions.getToolResult", {
696
+ sessionId,
697
+ callId
698
+ });
699
+ return typeof text === "string" ? text : null;
700
+ },
701
+ toolOutputRange: async (sessionId, callId, range, turnId) => {
702
+ const answer = await client.call("sessions.getToolResult", {
703
+ sessionId,
704
+ callId,
705
+ range,
706
+ ...turnId ? { turnId } : {}
707
+ });
708
+ if (answer === null || answer === void 0) return null;
709
+ return typeof answer === "string" ? sliceToolOutput(answer, range) : answer;
710
+ },
711
+ toolCall: (sessionId, callId, turnId) => client.call("sessions.getToolCall", {
586
712
  sessionId,
587
- callId
713
+ callId,
714
+ ...turnId ? { turnId } : {}
588
715
  }),
589
716
  messageMediaUrl(sessionId, src) {
590
717
  const media = messageMediaOf(src);
@@ -594,6 +721,10 @@ function createServerHost(options) {
594
721
  const cwd = folders.get(sessionId);
595
722
  return ticket && cwd !== void 0 ? messageMediaAddress(ticket, cwd, src) : void 0;
596
723
  },
724
+ blobMediaUrl(hash) {
725
+ const ticket = mediaTicketOf(client);
726
+ return ticket ? blobMediaAddress(ticket, hash) : void 0;
727
+ },
597
728
  cancelTool(sessionId, callId) {
598
729
  client.call("chat.cancelWork", {
599
730
  sessionId,
@@ -1,4 +1,6 @@
1
1
  import { machinesError } from "../machines/headless/host.js";
2
+ import { serverLayerOver } from "../machines/headless/layer.js";
3
+ import { organizationStatusOf, serverOrganizationOver } from "../machines/headless/organization.js";
2
4
  import { createPresenceStore } from "../machines/headless/presence.js";
3
5
  import { createMachineLists, createOnlineMachines, lazyReadable } from "../machines/headless/stores.js";
4
6
  import { createHostSyncReads } from "../machines/headless/sync.js";
@@ -141,6 +143,11 @@ function createServerMachinesHost(options) {
141
143
  install: (_hostId) => guard("update", () => client.call("server.update.install", {})),
142
144
  configure: (_hostId, enabled) => guard("update", () => client.call("server.update.configure", { enabled }))
143
145
  },
146
+ organization: serverOrganizationOver(async () => organizationStatusOf(client.hello()), (_hostId, method, params) => client.call(method, params)),
147
+ layer: serverLayerOver(async (_hostId, method, params) => client.hello()?.identity ? {
148
+ signedIn: true,
149
+ result: await client.call(method, params)
150
+ } : { signedIn: false }),
144
151
  tokens: {
145
152
  list: (_hostId) => guard("tokens", () => client.call("tokens.list", {})),
146
153
  create: (_hostId, name) => guard("tokens", () => client.call("tokens.create", { name })),
@@ -19,4 +19,12 @@ export declare function mediaTicketOf(client: ServerClient): string | null;
19
19
  * @param cwd - The session's folder.
20
20
  * @param src - The `src` as the message wrote it.
21
21
  */
22
- export declare function messageMediaAddress(ticket: string, cwd: string, src: string): string;
22
+ export declare function messageMediaAddress(ticket: string, cwd: string, src: string): string;
23
+ /**
24
+ * Where a medium the server's session store holds by hash loads from: the
25
+ * same address for the same bytes, which the server marks immutable.
26
+ *
27
+ * @param ticket - The client's media ticket.
28
+ * @param hash - The blob's hash.
29
+ */
30
+ export declare function blobMediaAddress(ticket: string, hash: string): string;
@@ -35,4 +35,17 @@ function messageMediaAddress(ticket, cwd, src) {
35
35
  src
36
36
  })}`;
37
37
  }
38
- export { mediaTicketOf, messageMediaAddress };
38
+ /**
39
+ * Where a medium the server's session store holds by hash loads from: the
40
+ * same address for the same bytes, which the server marks immutable.
41
+ *
42
+ * @param ticket - The client's media ticket.
43
+ * @param hash - The blob's hash.
44
+ */
45
+ function blobMediaAddress(ticket, hash) {
46
+ return `${SERVER_MEDIA_PATH}?${new URLSearchParams({
47
+ ticket,
48
+ blob: hash
49
+ })}`;
50
+ }
51
+ export { blobMediaAddress, mediaTicketOf, messageMediaAddress };
@@ -1,9 +1,11 @@
1
1
  import { createArtifactsState, groupArtifactRows, plainArtifactRow } from "../session/headless/artifacts.js";
2
+ import { createSessionPeople } from "../session/headless/people.js";
2
3
  import { createPlansState } from "../session/headless/plans.js";
3
4
  import { createQueueState } from "../session/headless/queue.js";
4
5
  import { createRunningWorkState } from "../session/headless/running-work.js";
5
6
  import { createSchedulesState } from "../session/headless/schedules.js";
6
7
  import { createSecretsState } from "../session/headless/secrets.js";
8
+ import { createSessionTyping } from "../session/headless/typing.js";
7
9
  // src/adapters/server-session-host.ts
8
10
  /**
9
11
  * Creates a {@link SessionHost} over a zidane-server client.
@@ -27,6 +29,52 @@ function createServerSessionHost(options) {
27
29
  })
28
30
  });
29
31
  const work = createRunningWorkState((sessionId) => client.call("chat.listWork", { sessionId }));
32
+ const sharing = client.hello()?.identity && client.can("members.get") ? {
33
+ get: (sessionId) => client.call("members.get", { sessionId }),
34
+ invite: (sessionId, user, grant) => client.call("members.invite", {
35
+ sessionId,
36
+ user,
37
+ ...grant ? { grant } : {}
38
+ }),
39
+ setGrant: (sessionId, userId, grant) => client.call("members.setGrant", {
40
+ sessionId,
41
+ userId,
42
+ grant
43
+ }),
44
+ remove: (sessionId, userId) => client.call("members.remove", {
45
+ sessionId,
46
+ userId
47
+ }),
48
+ setOpen: (sessionId, open, defaultGrant) => client.call("members.setOpen", {
49
+ sessionId,
50
+ open,
51
+ ...defaultGrant ? { defaultGrant } : {}
52
+ }),
53
+ transfer: (sessionId, userId) => client.call("members.transfer", {
54
+ sessionId,
55
+ userId
56
+ }),
57
+ leave: (sessionId) => client.call("members.leave", { sessionId }),
58
+ users: () => client.call("members.users", {}),
59
+ directory: () => client.call("members.directory", {}),
60
+ join: (sessionId) => client.call("members.join", { sessionId }),
61
+ setNotify: (sessionId, notify) => client.call("members.setNotify", {
62
+ sessionId,
63
+ notify
64
+ }),
65
+ onChanged: (listener) => client.onSignal((signal) => {
66
+ if (signal.kind === "members:changed" || signal.kind === "members:directory") listener();
67
+ }),
68
+ people: createSessionPeople({
69
+ list: () => client.call("presence.list", {}),
70
+ onChanged: (listener) => client.onSignal((signal) => {
71
+ if (signal.kind === "presence:changed") listener(signal.sessions);
72
+ })
73
+ }),
74
+ typing: createSessionTyping((listener) => client.onSignal((signal) => {
75
+ if (signal.kind === "members:typing") listener(signal);
76
+ }))
77
+ } : void 0;
30
78
  const artifacts = createArtifactsState(async (sessionId) => groupArtifactRows((await client.call("sessions.artifacts", { sessionId })).map(plainArtifactRow)));
31
79
  const secrets = createSecretsState((sessionId) => client.call("secrets.list", { sessionId }));
32
80
  const schedules = client.can("schedules.status") ? createSchedulesState({
@@ -68,6 +116,7 @@ function createServerSessionHost(options) {
68
116
  }
69
117
  })];
70
118
  return {
119
+ ...sharing ? { sharing } : {},
71
120
  plans: {
72
121
  snapshot: plans.snapshot,
73
122
  refresh: plans.refresh,
@@ -123,7 +123,10 @@ function serverSettingsSections(client) {
123
123
  })
124
124
  } } : {},
125
125
  environments: {
126
- list: (cwd) => call("environments.list", cwd ? { cwd } : {}),
126
+ list: (cwd, options) => call("environments.list", {
127
+ ...cwd ? { cwd } : {},
128
+ ...options?.machineOnly ? { machineOnly: true } : {}
129
+ }),
127
130
  update: async (change) => {
128
131
  await call("environments.update", change);
129
132
  },
@@ -131,6 +131,9 @@ function createSseHost(options) {
131
131
  case "history":
132
132
  if (state.applyHistory(sessionId, record.data)) reread(sessionId);
133
133
  return true;
134
+ case "turn-text":
135
+ state.replaceTurnText(sessionId, record.data.turnId, record.data.text, record.data.childId);
136
+ return true;
134
137
  case "reset": return false;
135
138
  default: return true;
136
139
  }
@@ -27,6 +27,9 @@
27
27
  * transcript is at. `history` records (version 2) go only to a stream whose
28
28
  * request announces version 2 or later. A version 1 client gets only the
29
29
  * records it knows.
30
+ * A `turn-text` record says the loop changed a turn's text after it streamed
31
+ * (zidane's `turn:end.text`): the client's streamed rows of that turn become
32
+ * the saved text blocks, as a hydrate shows them.
30
33
  * A client ignores a record type it does not know (a later version's).
31
34
  * `seq` counts a session's records from 1 within one server process
32
35
  * (`epoch`). A client reconnecting with `Last-Event-ID` gets every record
@@ -100,6 +103,13 @@ export type StreamRecord = {
100
103
  } | {
101
104
  type: 'history';
102
105
  data: HistoryChange;
106
+ } | {
107
+ type: 'turn-text';
108
+ data: {
109
+ turnId: string;
110
+ childId?: string;
111
+ text: string[];
112
+ };
103
113
  } | {
104
114
  type: 'reset';
105
115
  data: Record<string, never>;