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.
- package/dist/adapters/live.d.ts +8 -0
- package/dist/adapters/live.js +19 -8
- package/dist/adapters/server-composer-host.js +22 -9
- package/dist/adapters/server-git-host.js +5 -2
- package/dist/adapters/server-host.js +158 -27
- package/dist/adapters/server-machines-host.js +7 -0
- package/dist/adapters/server-media.d.ts +9 -1
- package/dist/adapters/server-media.js +14 -1
- package/dist/adapters/server-session-host.js +49 -0
- package/dist/adapters/server-settings-sections.js +4 -1
- package/dist/adapters/sse-host.js +3 -0
- package/dist/adapters/sse-protocol.d.ts +10 -0
- package/dist/appearance/ZoomIndicator.js +5 -8
- package/dist/chat/HostTranscript.d.ts +0 -12
- package/dist/chat/HostTranscript.js +20 -1
- package/dist/chat/SessionStreamsProvider.d.ts +9 -1
- package/dist/chat/SessionStreamsProvider.js +11 -2
- package/dist/chat/Transcript.d.ts +21 -11
- package/dist/chat/Transcript.js +346 -161
- package/dist/chat/composer/ModelOptionsPicker.js +6 -2
- package/dist/chat/composer/ModelPicker.d.ts +1 -1
- package/dist/chat/composer/PlacePicker.d.ts +3 -1
- package/dist/chat/composer/PlacePicker.js +5 -1
- package/dist/chat/composer/use-draft-target.js +15 -3
- package/dist/chat/headless/block-runs.js +26 -1
- package/dist/chat/headless/chip-views.js +1 -1
- package/dist/chat/headless/draft-target.d.ts +28 -1
- package/dist/chat/headless/draft-target.js +22 -1
- package/dist/chat/headless/host.d.ts +43 -7
- package/dist/chat/headless/hosts.d.ts +4 -0
- package/dist/chat/headless/index.d.ts +27 -26
- package/dist/chat/headless/index.js +15 -14
- package/dist/chat/headless/labels.d.ts +17 -0
- package/dist/chat/headless/labels.js +17 -0
- package/dist/chat/headless/markdown-chunks.d.ts +2 -1
- package/dist/chat/headless/markdown-chunks.js +12 -20
- package/dist/chat/headless/markdown-scan.d.ts +64 -0
- package/dist/chat/headless/markdown-scan.js +119 -0
- package/dist/chat/headless/markdown-stream.d.ts +64 -0
- package/dist/chat/headless/markdown-stream.js +143 -0
- package/dist/chat/headless/output-pager.d.ts +68 -0
- package/dist/chat/headless/output-pager.js +113 -0
- package/dist/chat/headless/prompt-origin.d.ts +2 -0
- package/dist/chat/headless/prompt-origin.js +6 -2
- package/dist/chat/headless/session-list.d.ts +10 -0
- package/dist/chat/headless/sidebar/activity.d.ts +14 -0
- package/dist/chat/headless/sidebar/activity.js +32 -0
- package/dist/chat/headless/sidebar/directory.d.ts +19 -2
- package/dist/chat/headless/sidebar/directory.js +19 -51
- package/dist/chat/headless/sidebar/environment.d.ts +15 -4
- package/dist/chat/headless/sidebar/environment.js +27 -9
- package/dist/chat/headless/sidebar/index.d.ts +2 -2
- package/dist/chat/headless/sidebar/index.js +2 -2
- package/dist/chat/headless/sidebar/labels.d.ts +19 -2
- package/dist/chat/headless/sidebar/labels.js +8 -1
- package/dist/chat/headless/sidebar/prewarm.d.ts +68 -0
- package/dist/chat/headless/sidebar/prewarm.js +114 -0
- package/dist/chat/headless/streams/actions.d.ts +4 -2
- package/dist/chat/headless/streams/actions.js +2 -1
- package/dist/chat/headless/streams/event-bytes.d.ts +17 -0
- package/dist/chat/headless/streams/event-bytes.js +46 -0
- package/dist/chat/headless/streams/live-events.d.ts +25 -1
- package/dist/chat/headless/streams/live-events.js +53 -2
- package/dist/chat/headless/streams/selectors.d.ts +3 -0
- package/dist/chat/headless/streams/selectors.js +8 -1
- package/dist/chat/headless/streams/session-streams.d.ts +15 -3
- package/dist/chat/headless/streams/session-streams.js +31 -3
- package/dist/chat/headless/streams/store.d.ts +45 -6
- package/dist/chat/headless/streams/store.js +85 -31
- package/dist/chat/headless/streams/transcript-map.d.ts +57 -0
- package/dist/chat/headless/streams/transcript-map.js +85 -0
- package/dist/chat/headless/streams/transcript.d.ts +4 -2
- package/dist/chat/headless/streams/transcript.js +19 -7
- package/dist/chat/headless/streams/types.d.ts +2 -1
- package/dist/chat/headless/transcript/batch.js +5 -1
- package/dist/chat/headless/transcript/blob-media.d.ts +15 -0
- package/dist/chat/headless/transcript/blob-media.js +23 -0
- package/dist/chat/headless/transcript/collapse.d.ts +10 -0
- package/dist/chat/headless/transcript/collapse.js +35 -6
- package/dist/chat/headless/transcript/derive.d.ts +98 -0
- package/dist/chat/headless/transcript/derive.js +89 -0
- package/dist/chat/headless/transcript/exchange-media.d.ts +3 -1
- package/dist/chat/headless/transcript/exchange-media.js +8 -5
- package/dist/chat/headless/transcript/fold-attachments.d.ts +2 -0
- package/dist/chat/headless/transcript/fold-attachments.js +3 -2
- package/dist/chat/headless/transcript/fold.d.ts +2 -1
- package/dist/chat/headless/transcript/fold.js +16 -6
- package/dist/chat/headless/transcript/incremental.d.ts +53 -0
- package/dist/chat/headless/transcript/incremental.js +181 -0
- package/dist/chat/headless/transcript/index.d.ts +2 -2
- package/dist/chat/headless/transcript/index.js +2 -2
- package/dist/chat/headless/transcript/nesting.js +2 -1
- package/dist/chat/headless/transcript/rail.d.ts +50 -1
- package/dist/chat/headless/transcript/rail.js +165 -23
- package/dist/chat/headless/transcript/rows.d.ts +5 -1
- package/dist/chat/headless/transcript/run-failures.js +2 -1
- package/dist/chat/headless/transcript/seams.d.ts +78 -0
- package/dist/chat/headless/transcript/seams.js +116 -0
- package/dist/chat/headless/transcript/tool-media.d.ts +6 -7
- package/dist/chat/headless/transcript/tool-media.js +27 -9
- package/dist/chat/index.d.ts +9 -8
- package/dist/chat/index.js +18 -17
- package/dist/chat/sidebar/ProjectIcon.js +1 -1
- package/dist/chat/sidebar/RowChips.js +2 -2
- package/dist/chat/sidebar/SessionSidebar.d.ts +6 -0
- package/dist/chat/sidebar/SessionSidebar.js +23 -16
- package/dist/chat/sidebar/SidebarFilterMenu.js +0 -1
- package/dist/chat/sidebar/SidebarFold.js +17 -16
- package/dist/chat/sidebar/SidebarFooter.d.ts +8 -5
- package/dist/chat/sidebar/SidebarFooter.js +6 -6
- package/dist/chat/sidebar/SidebarSessionRow.d.ts +7 -1
- package/dist/chat/sidebar/SidebarSessionRow.js +11 -8
- package/dist/chat/sidebar/session-menu.d.ts +4 -0
- package/dist/chat/sidebar/session-menu.js +14 -2
- package/dist/chat/sidebar/sidebar-live.js +28 -4
- package/dist/chat/sidebar/useInboxRows.js +6 -6
- package/dist/chat/sidebar/useInboxTriage.js +50 -47
- package/dist/chat/sidebar/useSessionSearch.js +19 -18
- package/dist/chat/testing/contract.d.ts +5 -3
- package/dist/chat/testing/contract.js +66 -1
- package/dist/chat/transcript/DiffLines.d.ts +6 -1
- package/dist/chat/transcript/DiffLines.js +35 -20
- package/dist/chat/transcript/EditDiffBlock.d.ts +5 -1
- package/dist/chat/transcript/EditDiffBlock.js +89 -30
- package/dist/chat/transcript/FileChip.js +28 -0
- package/dist/chat/transcript/LazyRow.d.ts +40 -40
- package/dist/chat/transcript/LazyRow.js +100 -149
- package/dist/chat/transcript/MermaidDiagram.js +2 -1
- package/dist/chat/transcript/PromptEcho.js +3 -11
- package/dist/chat/transcript/SessionChip.d.ts +11 -0
- package/dist/chat/transcript/SessionChip.js +34 -0
- package/dist/chat/transcript/SubagentBlock.js +3 -2
- package/dist/chat/transcript/TranscriptRail.d.ts +25 -2
- package/dist/chat/transcript/TranscriptRail.js +175 -17
- package/dist/chat/transcript/TranscriptRow.d.ts +4 -7
- package/dist/chat/transcript/TranscriptRow.js +4 -3
- package/dist/chat/transcript/actions.d.ts +37 -1
- package/dist/chat/transcript/actions.js +27 -1
- package/dist/chat/transcript/chip-details.d.ts +11 -0
- package/dist/chat/transcript/chip-details.js +17 -1
- package/dist/chat/transcript/clipped-output.d.ts +58 -0
- package/dist/chat/transcript/clipped-output.js +131 -0
- package/dist/chat/transcript/fold-attachments.js +10 -5
- package/dist/chat/transcript/fold-worker.js +5 -3
- package/dist/chat/transcript/fold.js +13 -4
- package/dist/chat/transcript/index.d.ts +11 -10
- package/dist/chat/transcript/index.js +10 -9
- package/dist/chat/transcript/markdown-cache.d.ts +17 -2
- package/dist/chat/transcript/markdown-cache.js +48 -4
- package/dist/chat/transcript/markdown.js +110 -55
- package/dist/chat/transcript/media-gallery.d.ts +3 -2
- package/dist/chat/transcript/media-gallery.js +19 -19
- package/dist/chat/transcript/messages.js +5 -4
- package/dist/chat/transcript/notices.js +2 -1
- package/dist/chat/transcript/prompt.d.ts +1 -1
- package/dist/chat/transcript/prompt.js +6 -4
- package/dist/chat/transcript/prose.js +2 -1
- package/dist/chat/transcript/root-items.d.ts +96 -0
- package/dist/chat/transcript/root-items.js +180 -0
- package/dist/chat/transcript/row-mount.d.ts +184 -0
- package/dist/chat/transcript/row-mount.js +532 -0
- package/dist/chat/transcript/row-parking.d.ts +152 -0
- package/dist/chat/transcript/row-parking.js +171 -0
- package/dist/chat/transcript/row-ui-state.d.ts +37 -0
- package/dist/chat/transcript/row-ui-state.js +53 -0
- package/dist/chat/transcript/run-rows.js +3 -2
- package/dist/chat/transcript/script-input.d.ts +1 -1
- package/dist/chat/transcript/tasks.js +3 -2
- package/dist/chat/transcript/tool-media.d.ts +4 -2
- package/dist/chat/transcript/tool-media.js +15 -7
- package/dist/chat/transcript/tool-parts.d.ts +27 -4
- package/dist/chat/transcript/tool-parts.js +31 -6
- package/dist/chat/transcript/tool-payload.js +26 -11
- package/dist/chat/transcript/tool-row.d.ts +2 -1
- package/dist/chat/transcript/tool-row.js +38 -19
- package/dist/chat/transcript/use-transcript-rows.d.ts +25 -8
- package/dist/chat/transcript/use-transcript-rows.js +28 -46
- package/dist/chat/transcript/useHistoryBackfill.d.ts +42 -0
- package/dist/chat/transcript/useHistoryBackfill.js +170 -0
- package/dist/chat/transcript/useStickToBottom.js +2 -3
- package/dist/chat/transcript/useTranscriptFind.js +2 -4
- package/dist/chat/transcript/useTranscriptScroll.d.ts +7 -4
- package/dist/chat/transcript/useTranscriptScroll.js +12 -1
- package/dist/chat/transcript/useTranscriptSearch.d.ts +2 -2
- package/dist/chat/transcript/useTranscriptSearch.js +35 -19
- package/dist/chat/transcript/useTranscriptSelectionCopy.d.ts +5 -5
- package/dist/chat/transcript/useTranscriptSelectionCopy.js +28 -7
- package/dist/chat/transcript/view-scope.d.ts +26 -6
- package/dist/chat/transcript/view-scope.js +106 -20
- package/dist/code/editor/FileTree.d.ts +2 -0
- package/dist/code/editor/FileTree.js +1 -1
- package/dist/code/editor/FileView.js +16 -25
- package/dist/code/editor/find/useFind.js +17 -17
- package/dist/code/editor/useCodeDocument.js +22 -19
- package/dist/code/editor/useDetachCleanup.js +4 -3
- package/dist/code/use-highlighted-html.js +12 -13
- package/dist/components/IconButton.d.ts +3 -1
- package/dist/components/IconButton.js +7 -2
- package/dist/components/IconButtonTip.d.ts +3 -1
- package/dist/components/IconButtonTip.js +2 -1
- package/dist/components/RowActionsMenu.js +7 -14
- package/dist/components/Tooltip.d.ts +4 -1
- package/dist/components/Tooltip.js +8 -6
- package/dist/components/assign-ref.d.ts +8 -0
- package/dist/components/assign-ref.js +12 -0
- package/dist/components/floating/FloatingSurface.js +2 -2
- package/dist/components/floating/HoverCard.js +32 -14
- package/dist/components/floating/Popover.js +4 -7
- package/dist/components/floating/useAnchoredPosition.d.ts +5 -3
- package/dist/components/floating/useAnchoredPosition.js +7 -7
- package/dist/components/object-key.d.ts +7 -0
- package/dist/components/object-key.js +18 -0
- package/dist/components/palette/PaletteList.js +2 -7
- package/dist/components/tooltip-arming.d.ts +3 -0
- package/dist/components/tooltip-arming.js +8 -1
- package/dist/core.css +3 -3
- package/dist/dist/{index-E1Z0aPmi.d.ts → index-BheVJOLc.d.ts} +3 -1
- package/dist/dist/index.d.ts +2 -2
- package/dist/files/FilesTab.js +0 -1
- package/dist/files/TreeColumn.d.ts +2 -4
- package/dist/files/TreeColumn.js +0 -5
- package/dist/files/headless/host.d.ts +3 -7
- package/dist/files/headless/labels.d.ts +0 -1
- package/dist/files/headless/labels.js +0 -1
- package/dist/files/headless/workspace-diff.js +1 -1
- package/dist/files/useCodeReview.js +1 -3
- package/dist/files/useFilesDiagnostics.d.ts +1 -1
- package/dist/files/useFilesDiagnostics.js +4 -11
- package/dist/files/useOpenFiles.js +9 -12
- package/dist/files/useWorkspace.d.ts +5 -7
- package/dist/files/useWorkspace.js +4 -15
- package/dist/git/GitBar.js +5 -3
- package/dist/git/MoveSessionDialog.d.ts +18 -8
- package/dist/git/MoveSessionDialog.js +32 -53
- package/dist/git/MoveToDialog.d.ts +61 -0
- package/dist/git/MoveToDialog.js +240 -0
- package/dist/git/SandboxManager.js +9 -4
- package/dist/git/SyncChip.js +11 -4
- package/dist/git/TeleportSessionDialog.d.ts +69 -0
- package/dist/git/TeleportSessionDialog.js +440 -0
- package/dist/git/headless/host.d.ts +14 -0
- package/dist/git/headless/index.d.ts +2 -1
- package/dist/git/headless/index.js +2 -1
- package/dist/git/headless/labels.d.ts +44 -1
- package/dist/git/headless/labels.js +50 -0
- package/dist/git/headless/sandboxes.d.ts +1 -1
- package/dist/git/headless/sandboxes.js +4 -3
- package/dist/git/headless/teleport.d.ts +76 -0
- package/dist/git/headless/teleport.js +19 -0
- package/dist/git/index.d.ts +4 -2
- package/dist/git/index.js +4 -2
- package/dist/git/useEnvironmentChoices.d.ts +5 -2
- package/dist/git/useEnvironmentChoices.js +12 -4
- package/dist/hooks/useLatest.d.ts +8 -0
- package/dist/hooks/useLatest.js +17 -0
- package/dist/hooks/useMinuteTick.d.ts +6 -2
- package/dist/hooks/useMinuteTick.js +12 -6
- package/dist/hooks/useNearViewport.js +11 -8
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/keybindings/KeybindingsProvider.js +3 -4
- package/dist/keybindings/headless/catalog.d.ts +1 -1
- package/dist/keybindings/headless/catalog.js +18 -0
- package/dist/machines/AddServerForm.js +55 -3
- package/dist/machines/Banners.d.ts +2 -2
- package/dist/machines/Banners.js +3 -3
- package/dist/machines/DaemonMenu.js +1 -3
- package/dist/machines/HostsSection.js +5 -1
- package/dist/machines/OrganizationPanel.d.ts +25 -0
- package/dist/machines/OrganizationPanel.js +266 -0
- package/dist/machines/PersonalLayerPanel.d.ts +32 -0
- package/dist/machines/PersonalLayerPanel.js +360 -0
- package/dist/machines/headless/fixture-host.d.ts +10 -0
- package/dist/machines/headless/fixture-host.js +44 -0
- package/dist/machines/headless/host.d.ts +21 -1
- package/dist/machines/headless/index.d.ts +3 -1
- package/dist/machines/headless/index.js +3 -1
- package/dist/machines/headless/labels.d.ts +55 -0
- package/dist/machines/headless/labels.js +58 -1
- package/dist/machines/headless/layer.d.ts +64 -0
- package/dist/machines/headless/layer.js +56 -0
- package/dist/machines/headless/organization.d.ts +38 -0
- package/dist/machines/headless/organization.js +44 -0
- package/dist/machines/index.d.ts +3 -1
- package/dist/machines/index.js +3 -1
- package/dist/machines/testing/contract.d.ts +25 -1
- package/dist/machines/testing/contract.js +97 -1
- package/dist/motion/grow.js +12 -13
- package/dist/motion/swap.js +2 -5
- package/dist/motion/use-flip-list.d.ts +14 -0
- package/dist/motion/use-flip-list.js +17 -12
- package/dist/palette/headless/app-sources.js +37 -0
- package/dist/palette/headless/labels.js +3 -0
- package/dist/server/sse-handler.js +25 -2
- package/dist/session/DiffFileTree.js +1 -4
- package/dist/session/OpenSessionsDialog.d.ts +46 -0
- package/dist/session/OpenSessionsDialog.js +170 -0
- package/dist/session/PlanTracker.js +1 -2
- package/dist/session/ProjectHome.js +10 -9
- package/dist/session/RemindersPanel.js +10 -12
- package/dist/session/SecretsPanel.js +2 -1
- package/dist/session/SessionHeader.js +1 -0
- package/dist/session/SessionPeopleStack.d.ts +23 -0
- package/dist/session/SessionPeopleStack.js +65 -0
- package/dist/session/SessionPlaceMenu.js +5 -4
- package/dist/session/ShareSessionDialog.d.ts +32 -0
- package/dist/session/ShareSessionDialog.js +342 -0
- package/dist/session/TypingLine.d.ts +22 -0
- package/dist/session/TypingLine.js +31 -0
- package/dist/session/headless/host.d.ts +40 -1
- package/dist/session/headless/index.d.ts +4 -2
- package/dist/session/headless/index.js +3 -1
- package/dist/session/headless/labels.d.ts +49 -0
- package/dist/session/headless/labels.js +56 -0
- package/dist/session/headless/people.d.ts +29 -0
- package/dist/session/headless/people.js +53 -0
- package/dist/session/headless/place.d.ts +5 -0
- package/dist/session/headless/place.js +5 -1
- package/dist/session/headless/typing.d.ts +37 -0
- package/dist/session/headless/typing.js +60 -0
- package/dist/session/index.d.ts +5 -1
- package/dist/session/index.js +5 -1
- package/dist/settings/headless/fixture-performance.js +4 -2
- package/dist/settings/headless/performance.d.ts +4 -0
- package/dist/settings/headless/search.d.ts +1 -1
- package/dist/settings/headless/sections-host.d.ts +7 -2
- package/dist/settings/section.d.ts +15 -3
- package/dist/settings/section.js +15 -3
- package/dist/settings/sections/environments/EnvironmentsSection.js +30 -6
- package/dist/settings/sections/keybindings/labels.d.ts +3 -0
- package/dist/settings/sections/keybindings/labels.js +3 -0
- package/dist/settings/sections/keybindings/rows.js +12 -0
- package/dist/settings/sections/logs/LogsSection.js +5 -8
- package/dist/settings/sections/performance/PerformanceSection.js +8 -1
- package/dist/settings/sections/performance/labels.d.ts +2 -0
- package/dist/settings/sections/performance/labels.js +2 -0
- package/dist/styles.css +65 -9
- package/dist/terminal/HostTerminalSurface.js +28 -30
- package/dist/terminal/TerminalPanel.js +4 -12
- package/dist/terminal/TerminalProvider.d.ts +10 -2
- package/dist/terminal/TerminalProvider.js +10 -2
- package/dist/terminal/headless/labels.d.ts +0 -1
- package/dist/terminal/headless/labels.js +1 -2
- package/dist/terminal/headless/store.js +5 -1
- package/dist/views/headless/answers.d.ts +8 -2
- package/dist/views/headless/answers.js +58 -1
- package/dist/views/headless/placement.d.ts +78 -0
- package/dist/views/headless/placement.js +154 -44
- package/dist/workspace/LayoutBudget.js +1 -7
- package/package.json +2 -2
- package/src/styles/chat.css +3 -1
- package/src/styles/palette.css +3 -3
- package/src/styles/transcript.css +50 -5
- /package/dist/dist/{index-De9AbmxS.d.ts → index-ttmMvjgM.d.ts} +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/chat/headless/transcript/blob-media.ts
|
|
2
|
+
/**
|
|
3
|
+
* Media the session store holds by content hash (its blob table): a turn
|
|
4
|
+
* names such a block `attachment://<hash>`, on a prompt's attachment
|
|
5
|
+
* (`ChatAttachment.ref`) and in a tool result's stand-in line
|
|
6
|
+
* (`[image: image/png, ref attachment://<hash>]`). An app that serves blobs
|
|
7
|
+
* (`TranscriptActions.blobMediaUrl`) loads them by hash: the same bytes for
|
|
8
|
+
* good, so the page caches them for good. Blocks still inline keep the
|
|
9
|
+
* app's older addresses (by call and position, by turn).
|
|
10
|
+
*/
|
|
11
|
+
const HANDLE = "attachment://";
|
|
12
|
+
const HASH = /^[0-9a-f]{32}$/;
|
|
13
|
+
/**
|
|
14
|
+
* The blob hash an `attachment://<hash>` handle names, or `undefined` for anything else.
|
|
15
|
+
*
|
|
16
|
+
* @param ref - A block's ref.
|
|
17
|
+
*/
|
|
18
|
+
function blobHashOf(ref) {
|
|
19
|
+
if (!ref?.startsWith(HANDLE)) return void 0;
|
|
20
|
+
const hash = ref.slice(13).trim();
|
|
21
|
+
return HASH.test(hash) ? hash : void 0;
|
|
22
|
+
}
|
|
23
|
+
export { blobHashOf };
|
|
@@ -30,6 +30,16 @@ export declare function toolFailed(tool: Pick<Extract<Row, {
|
|
|
30
30
|
export declare function refusedSpawn(tool: Pick<Extract<Row, {
|
|
31
31
|
kind: 'tool';
|
|
32
32
|
}>, 'name' | 'result'>): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* The row the full pass puts in front of `events` when they follow other
|
|
35
|
+
* rows: a pass over `events` alone drops a leading separator and adds no
|
|
36
|
+
* turn boundary before a leading prompt, because nothing is above them.
|
|
37
|
+
* With it, rows derived per exchange join into the rows of the whole.
|
|
38
|
+
*
|
|
39
|
+
* @param events - The events of a part, as `collapseEvents` gets them.
|
|
40
|
+
* @param before - The last row the collapse made for everything above them, if any.
|
|
41
|
+
*/
|
|
42
|
+
export declare function collapseSeamRow(events: readonly ChatEvent[], before: Row | undefined): Row | null;
|
|
33
43
|
/**
|
|
34
44
|
* Turns transcript events into rows: pairs tool calls with their results, merges streamed text, reconciles edits and spawns. Rows are cached per source event, so appending an event keeps every earlier row identical.
|
|
35
45
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { promptOriginOf } from "../prompt-origin.js";
|
|
2
2
|
import { pairToolEvents } from "./pairing.js";
|
|
3
3
|
import { parseBashExitMeta } from "./rows.js";
|
|
4
|
-
import { displayNameFor, formatToolCall, isUserBashEvent, mcpJobsByCall, placeEnvironmentSetups, readEnvironmentSetup, scriptProgressByCall, scriptProgressKey } from "zidane/chat/pure";
|
|
4
|
+
import { displayNameFor, formatToolCall, isUserBashEvent, mcpJobsByCall, noteTranscriptPass, placeEnvironmentSetups, readEnvironmentSetup, scriptProgressByCall, scriptProgressKey } from "zidane/chat/pure";
|
|
5
5
|
// src/chat/headless/transcript/collapse.ts
|
|
6
6
|
/**
|
|
7
7
|
* When the paired result is an `error`, flip every `applied` outcome
|
|
@@ -135,6 +135,9 @@ function markdownRow(event, mid) {
|
|
|
135
135
|
/**
|
|
136
136
|
* The one row of the thinking run `events[start..end)`, whose first event has text.
|
|
137
137
|
*
|
|
138
|
+
* @param events - The events the run is in.
|
|
139
|
+
* @param start - The index of the run's first event.
|
|
140
|
+
* @param end - The index after the run's last event.
|
|
138
141
|
* @param kid - The run's row id, its per-(turn, owner) ordinal.
|
|
139
142
|
*/
|
|
140
143
|
function thinkingRow(events, start, end, kid) {
|
|
@@ -168,6 +171,7 @@ const lastPasses = /* @__PURE__ */ new WeakMap();
|
|
|
168
171
|
function collapseTail(events, showEditDiffs, isStreaming) {
|
|
169
172
|
const last = events.length > 0 ? lastPasses.get(events[0]) : void 0;
|
|
170
173
|
if (!last || last.events.length !== events.length || last.showEditDiffs !== showEditDiffs || last.isStreaming !== isStreaming) return null;
|
|
174
|
+
noteTranscriptPass("collapse:tail", events.length);
|
|
171
175
|
const prev = last.events;
|
|
172
176
|
const { rowOf, headOf } = last;
|
|
173
177
|
const changed = [];
|
|
@@ -263,6 +267,28 @@ function refusedSpawn(tool) {
|
|
|
263
267
|
return tool.name === "spawn" && typeof tool.result === "string" && /^(?:Tool error: )?Cannot spawn/.test(tool.result);
|
|
264
268
|
}
|
|
265
269
|
/**
|
|
270
|
+
* The row the full pass puts in front of `events` when they follow other
|
|
271
|
+
* rows: a pass over `events` alone drops a leading separator and adds no
|
|
272
|
+
* turn boundary before a leading prompt, because nothing is above them.
|
|
273
|
+
* With it, rows derived per exchange join into the rows of the whole.
|
|
274
|
+
*
|
|
275
|
+
* @param events - The events of a part, as `collapseEvents` gets them.
|
|
276
|
+
* @param before - The last row the collapse made for everything above them, if any.
|
|
277
|
+
*/
|
|
278
|
+
function collapseSeamRow(events, before) {
|
|
279
|
+
const first = events[0];
|
|
280
|
+
if (!first || !before || before.kind === "separator") return null;
|
|
281
|
+
if (first.kind === "separator") {
|
|
282
|
+
const sid = rowIdFor(first);
|
|
283
|
+
return cachedRow(first, `s-${sid}`, () => ({
|
|
284
|
+
kind: "separator",
|
|
285
|
+
id: `s-${sid}`
|
|
286
|
+
}));
|
|
287
|
+
}
|
|
288
|
+
if (first.kind === "user-prompt" && !first.childId) return autoSeparatorFor(first, rowIdFor(first));
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
266
292
|
* Turns transcript events into rows: pairs tool calls with their results, merges streamed text, reconciles edits and spawns. Rows are cached per source event, so appending an event keeps every earlier row identical.
|
|
267
293
|
*
|
|
268
294
|
* @param events - The transcript events, oldest first.
|
|
@@ -281,6 +307,7 @@ function collapseEvents(events, showEditDiffs, isStreaming) {
|
|
|
281
307
|
* @param isStreaming - A run is in flight.
|
|
282
308
|
*/
|
|
283
309
|
function collapseAll(events, showEditDiffs, isStreaming) {
|
|
310
|
+
noteTranscriptPass("collapse", events.length);
|
|
284
311
|
const rows = [];
|
|
285
312
|
const rowOf = new Int32Array(events.length).fill(-1);
|
|
286
313
|
const headOf = new Int32Array(events.length);
|
|
@@ -395,7 +422,7 @@ function collapseAll(events, showEditDiffs, isStreaming) {
|
|
|
395
422
|
const paired = pair ? events[pair.resultIndex] : void 0;
|
|
396
423
|
const running = !paired || pair?.resultKind === "tool-result" && paired.streaming === true;
|
|
397
424
|
const errored = pair?.resultKind === "error";
|
|
398
|
-
const key = `ub-${sid}|${running}|${errored}|${paired ? rowIdFor(paired) : -1}|${paired?.text.length ?? -1}|${paired?.clipped
|
|
425
|
+
const key = `ub-${sid}|${running}|${errored}|${paired ? rowIdFor(paired) : -1}|${paired?.text.length ?? -1}|${paired?.clipped?.result !== void 0}`;
|
|
399
426
|
rows.push(cachedRow(event, key, () => {
|
|
400
427
|
const command = typeof event.input?.command === "string" ? event.input.command : event.text;
|
|
401
428
|
const result = paired ? paired.text : null;
|
|
@@ -409,7 +436,7 @@ function collapseAll(events, showEditDiffs, isStreaming) {
|
|
|
409
436
|
exit: !running && !errored && result !== null ? parseBashExitMeta(result) : null,
|
|
410
437
|
...errored ? { errored: true } : {},
|
|
411
438
|
...event.callId ? { callId: event.callId } : {},
|
|
412
|
-
...paired?.clipped ? { resultClipped: true } : {}
|
|
439
|
+
...paired?.clipped?.result ? { resultClipped: true } : {}
|
|
413
440
|
};
|
|
414
441
|
}));
|
|
415
442
|
break;
|
|
@@ -426,7 +453,7 @@ function collapseAll(events, showEditDiffs, isStreaming) {
|
|
|
426
453
|
const resuming = !paired && event.resuming === true;
|
|
427
454
|
const scriptProgress = event.callId ? progressOf.get(scriptProgressKey(event.callId, event.childId)) : void 0;
|
|
428
455
|
const mcpJob = event.callId ? jobOf.get(scriptProgressKey(event.callId, event.childId)) : void 0;
|
|
429
|
-
const key = `t-${sid}|${showEditDiffs}|${okCoerced}|${paired ? rowIdFor(paired) : -1}|${paired?.text.length ?? -1}|${paired?.clipped
|
|
456
|
+
const key = `t-${sid}|${showEditDiffs}|${okCoerced}|${paired ? rowIdFor(paired) : -1}|${paired?.text.length ?? -1}|${paired?.clipped?.result !== void 0}|${waitingFor ? "w" : ""}|${since ?? ""}|${doneMs ?? ""}|${resuming ? "r" : ""}|${scriptProgress ? progressId(scriptProgress) : ""}|${mcpJob ? progressId(mcpJob) : ""}`;
|
|
430
457
|
rows.push(cachedRow(event, key, () => {
|
|
431
458
|
const toolName = event.tool ?? "?";
|
|
432
459
|
const rawInput = event.input;
|
|
@@ -447,7 +474,9 @@ function collapseAll(events, showEditDiffs, isStreaming) {
|
|
|
447
474
|
result,
|
|
448
475
|
ok,
|
|
449
476
|
...event.callId ? { callId: event.callId } : {},
|
|
450
|
-
...paired?.clipped ? { resultClipped: true } : {},
|
|
477
|
+
...paired?.clipped?.result ? { resultClipped: true } : {},
|
|
478
|
+
...paired?.mediaRefs ? { mediaRefs: paired.mediaRefs } : {},
|
|
479
|
+
...event.clipped?.input ? { inputClipped: true } : {},
|
|
451
480
|
...waitingFor ? { waitingFor } : {},
|
|
452
481
|
...resuming ? { resuming: true } : {},
|
|
453
482
|
...scriptProgress ? { scriptProgress } : {},
|
|
@@ -564,4 +593,4 @@ function collapseAll(events, showEditDiffs, isStreaming) {
|
|
|
564
593
|
});
|
|
565
594
|
return rows;
|
|
566
595
|
}
|
|
567
|
-
export { collapseAll, collapseEvents, inheritRowIdentity, refusedSpawn, toolFailed };
|
|
596
|
+
export { collapseAll, collapseEvents, collapseSeamRow, inheritRowIdentity, refusedSpawn, toolFailed };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The transcript's row pipeline, events to the rows a transcript paints:
|
|
3
|
+
*
|
|
4
|
+
* filter cache notices and a codemode script's calls, per the settings
|
|
5
|
+
* gatherCommandNotes a `/` command's notes close its exchange as one line
|
|
6
|
+
* collapseEvents events → rows (pairs tool calls, merges text, edits, spawns)
|
|
7
|
+
* nestToolCalls nested calls under their calling row
|
|
8
|
+
* batch* tool runs, thinking chains, task bursts
|
|
9
|
+
* markRunFailures a run that ended early → one row that can continue or retry
|
|
10
|
+
* dockRunReceipts run receipts onto their reply
|
|
11
|
+
* foldExchanges compact density: each exchange's work behind one row
|
|
12
|
+
* clusterByOwner subagent rows → blocks per spawn
|
|
13
|
+
*
|
|
14
|
+
* {@link deriveRowsPart} runs it over one part of a transcript (a run of
|
|
15
|
+
* whole exchanges) so the incremental deriver (`incremental.ts`) can join
|
|
16
|
+
* parts; {@link deriveTranscriptRows} runs it over a whole transcript.
|
|
17
|
+
*/
|
|
18
|
+
import { ChatEvent } from "../host.js";
|
|
19
|
+
import { Cluster, Row } from "./rows.js";
|
|
20
|
+
import { RunReceipt } from "zidane/chat/pure";
|
|
21
|
+
/** The display options that shape the rows. */
|
|
22
|
+
export interface TranscriptRowOptions {
|
|
23
|
+
/** Show cache notices (cache expired / break, dropped reasoning). */
|
|
24
|
+
showCacheNotices: boolean;
|
|
25
|
+
/** Show the calls a codemode script makes (those running a subagent always show). */
|
|
26
|
+
codemodeShowCalls: boolean;
|
|
27
|
+
/** Show edit diffs on edit tool rows. */
|
|
28
|
+
showEditDiffs: boolean;
|
|
29
|
+
/** Batch tool rows across the whole exchange, not only adjacent ones. */
|
|
30
|
+
groupToolCalls: boolean;
|
|
31
|
+
/** Dock run receipts under their reply; off hides them. */
|
|
32
|
+
showRunReceipt: boolean;
|
|
33
|
+
/** Compact density: fold each exchange's work behind one row. */
|
|
34
|
+
compact: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** The rows of one part of a transcript. */
|
|
37
|
+
export interface DerivedRowsPart {
|
|
38
|
+
/** The rows after every pass, in paint order. */
|
|
39
|
+
rows: readonly Row[];
|
|
40
|
+
/** Run receipts docked under their reply, by the reply row's id. */
|
|
41
|
+
receipts: ReadonlyMap<string, RunReceipt>;
|
|
42
|
+
/** `rows` grouped into subagent blocks. */
|
|
43
|
+
clusters: readonly Cluster[];
|
|
44
|
+
/** The last row the collapse made up to the end of this part (the seam for the next part). */
|
|
45
|
+
lastCollapsed: Row | undefined;
|
|
46
|
+
/** The reply still streaming in this part, if any. */
|
|
47
|
+
lastStreaming: Row | null;
|
|
48
|
+
}
|
|
49
|
+
/** The rows a transcript paints and what it derives from them. */
|
|
50
|
+
export interface DerivedTranscriptRows {
|
|
51
|
+
/** The rows after every pass, in paint order. */
|
|
52
|
+
visibleRows: readonly Row[];
|
|
53
|
+
/** Run receipts docked under their reply, by the reply row's id. */
|
|
54
|
+
receiptByRowId: ReadonlyMap<string, RunReceipt>;
|
|
55
|
+
/** The failure row that offers to pick the work back up (the transcript's last word, once idle). */
|
|
56
|
+
resumableId: string | null;
|
|
57
|
+
/** `visibleRows` grouped into subagent blocks (`clusterByOwner`). */
|
|
58
|
+
clusters: readonly Cluster[];
|
|
59
|
+
/** The reply still streaming: the only row with a caret. */
|
|
60
|
+
lastStreamingRow: Row | null | undefined;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The events every later pass sees: cache notices and a codemode script's
|
|
64
|
+
* calls filtered per the settings, a `/` command's notes gathered at the end
|
|
65
|
+
* of its exchange.
|
|
66
|
+
*
|
|
67
|
+
* @param events - Transcript events in order.
|
|
68
|
+
* @param options - The display options.
|
|
69
|
+
*/
|
|
70
|
+
export declare function shownEvents(events: readonly ChatEvent[], options: Pick<TranscriptRowOptions, 'showCacheNotices' | 'codemodeShowCalls'>): readonly ChatEvent[];
|
|
71
|
+
/**
|
|
72
|
+
* The pipeline over one part of a transcript: whole exchanges, which no pass
|
|
73
|
+
* looks across (the incremental deriver makes sure of it).
|
|
74
|
+
*
|
|
75
|
+
* @param events - The part's events.
|
|
76
|
+
* @param streaming - A run is in flight.
|
|
77
|
+
* @param options - The display options.
|
|
78
|
+
* @param final - The part ends the transcript (its last exchange may be live).
|
|
79
|
+
* @param before - The last collapsed row of the parts above, if any.
|
|
80
|
+
*/
|
|
81
|
+
export declare function deriveRowsPart(events: readonly ChatEvent[], streaming: boolean, options: TranscriptRowOptions, final: boolean, before: Row | undefined): DerivedRowsPart;
|
|
82
|
+
/**
|
|
83
|
+
* The failure row that offers to pick the work back up: the transcript's last
|
|
84
|
+
* word (past separators and receipts) once idle.
|
|
85
|
+
*
|
|
86
|
+
* @param parts - The rows, in parts, oldest first.
|
|
87
|
+
* @param streaming - A run is in flight.
|
|
88
|
+
*/
|
|
89
|
+
export declare function resumableRowId(parts: ReadonlyArray<readonly Row[]>, streaming: boolean): string | null;
|
|
90
|
+
/**
|
|
91
|
+
* The whole pipeline over a whole transcript, in one go: what the incremental
|
|
92
|
+
* deriver must equal.
|
|
93
|
+
*
|
|
94
|
+
* @param events - Transcript events in order.
|
|
95
|
+
* @param streaming - A run is in flight.
|
|
96
|
+
* @param options - The display options.
|
|
97
|
+
*/
|
|
98
|
+
export declare function deriveTranscriptRows(events: readonly ChatEvent[], streaming: boolean, options: TranscriptRowOptions): DerivedTranscriptRows;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { batchTaskRuns, batchThinkingRuns, batchToolRuns, clusterByOwner } from "./batch.js";
|
|
2
|
+
import { collapseEvents, collapseSeamRow } from "./collapse.js";
|
|
3
|
+
import { dockRunReceipts, findLastStreamingRow, foldExchanges } from "./fold.js";
|
|
4
|
+
import { nestToolCalls, nestedCallVisible } from "./nesting.js";
|
|
5
|
+
import { markRunFailures } from "./run-failures.js";
|
|
6
|
+
import { gatherCommandNotes, isCacheNotice, noteTranscriptPass } from "zidane/chat/pure";
|
|
7
|
+
// src/chat/headless/transcript/derive.ts
|
|
8
|
+
/**
|
|
9
|
+
* The events every later pass sees: cache notices and a codemode script's
|
|
10
|
+
* calls filtered per the settings, a `/` command's notes gathered at the end
|
|
11
|
+
* of its exchange.
|
|
12
|
+
*
|
|
13
|
+
* @param events - Transcript events in order.
|
|
14
|
+
* @param options - The display options.
|
|
15
|
+
*/
|
|
16
|
+
function shownEvents(events, options) {
|
|
17
|
+
const { showCacheNotices, codemodeShowCalls } = options;
|
|
18
|
+
let shown = events;
|
|
19
|
+
if (!showCacheNotices || !codemodeShowCalls) {
|
|
20
|
+
noteTranscriptPass("filter", events.length);
|
|
21
|
+
shown = events.filter((event) => (showCacheNotices || !isCacheNotice(event.notice)) && nestedCallVisible(event, codemodeShowCalls));
|
|
22
|
+
}
|
|
23
|
+
return gatherCommandNotes(shown);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The pipeline over one part of a transcript: whole exchanges, which no pass
|
|
27
|
+
* looks across (the incremental deriver makes sure of it).
|
|
28
|
+
*
|
|
29
|
+
* @param events - The part's events.
|
|
30
|
+
* @param streaming - A run is in flight.
|
|
31
|
+
* @param options - The display options.
|
|
32
|
+
* @param final - The part ends the transcript (its last exchange may be live).
|
|
33
|
+
* @param before - The last collapsed row of the parts above, if any.
|
|
34
|
+
*/
|
|
35
|
+
function deriveRowsPart(events, streaming, options, final, before) {
|
|
36
|
+
const shown = shownEvents(events, options);
|
|
37
|
+
const collapsed = collapseEvents(shown, options.showEditDiffs, streaming);
|
|
38
|
+
const seam = collapseSeamRow(shown, before);
|
|
39
|
+
const nested = nestToolCalls(seam ? [seam, ...collapsed] : collapsed);
|
|
40
|
+
const batched = batchTaskRuns(batchThinkingRuns(batchToolRuns(nested, options.groupToolCalls)));
|
|
41
|
+
const failed = markRunFailures(batched);
|
|
42
|
+
const { visibleRows, receiptByRowId } = dockRunReceipts(failed, options.showRunReceipt);
|
|
43
|
+
const rows = options.compact ? foldExchanges(visibleRows, streaming, final) : visibleRows;
|
|
44
|
+
return {
|
|
45
|
+
rows,
|
|
46
|
+
receipts: receiptByRowId,
|
|
47
|
+
clusters: clusterByOwner(rows),
|
|
48
|
+
lastCollapsed: collapsed.at(-1) ?? seam ?? before,
|
|
49
|
+
lastStreaming: findLastStreamingRow(rows)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The failure row that offers to pick the work back up: the transcript's last
|
|
54
|
+
* word (past separators and receipts) once idle.
|
|
55
|
+
*
|
|
56
|
+
* @param parts - The rows, in parts, oldest first.
|
|
57
|
+
* @param streaming - A run is in flight.
|
|
58
|
+
*/
|
|
59
|
+
function resumableRowId(parts, streaming) {
|
|
60
|
+
if (streaming) return null;
|
|
61
|
+
for (let p = parts.length - 1; p >= 0; p--) {
|
|
62
|
+
const rows = parts[p];
|
|
63
|
+
for (let i = rows.length - 1; i >= 0; i--) {
|
|
64
|
+
const row = rows[i];
|
|
65
|
+
if (row.kind === "separator" || row.kind === "run-summary") continue;
|
|
66
|
+
return row.kind === "error" && row.failure ? row.id : null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The whole pipeline over a whole transcript, in one go: what the incremental
|
|
73
|
+
* deriver must equal.
|
|
74
|
+
*
|
|
75
|
+
* @param events - Transcript events in order.
|
|
76
|
+
* @param streaming - A run is in flight.
|
|
77
|
+
* @param options - The display options.
|
|
78
|
+
*/
|
|
79
|
+
function deriveTranscriptRows(events, streaming, options) {
|
|
80
|
+
const part = deriveRowsPart(events, streaming, options, true, void 0);
|
|
81
|
+
return {
|
|
82
|
+
visibleRows: part.rows,
|
|
83
|
+
receiptByRowId: part.receipts,
|
|
84
|
+
resumableId: resumableRowId([part.rows], streaming),
|
|
85
|
+
clusters: part.clusters,
|
|
86
|
+
lastStreamingRow: part.lastStreaming
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export { deriveRowsPart, deriveTranscriptRows, resumableRowId, shownEvents };
|
|
@@ -38,6 +38,7 @@ export type ExchangeMedium = {
|
|
|
38
38
|
name: string;
|
|
39
39
|
callId: string;
|
|
40
40
|
index: number;
|
|
41
|
+
hash?: string;
|
|
41
42
|
};
|
|
42
43
|
/** Keys a component names its medium by. */
|
|
43
44
|
export declare const mediumKey: {
|
|
@@ -64,5 +65,6 @@ export declare function mediaRefsOf(text: string): MediaRef[];
|
|
|
64
65
|
* the first prompt, index n what the n-th top-level prompt started.
|
|
65
66
|
*
|
|
66
67
|
* @param events - The transcript's events, oldest first.
|
|
68
|
+
* @param attachmentSrc - Where a prompt's attachment loads from (default: its `dataUrl`); one with none is left out.
|
|
67
69
|
*/
|
|
68
|
-
export declare function exchangesMedia(events: readonly ChatEvent[]): ExchangeMedium[][];
|
|
70
|
+
export declare function exchangesMedia(events: readonly ChatEvent[], attachmentSrc?: (att: NonNullable<ChatEvent['attachments']>[number]) => string | undefined): ExchangeMedium[][];
|
|
@@ -45,8 +45,9 @@ function isText(mediaType) {
|
|
|
45
45
|
* the first prompt, index n what the n-th top-level prompt started.
|
|
46
46
|
*
|
|
47
47
|
* @param events - The transcript's events, oldest first.
|
|
48
|
+
* @param attachmentSrc - Where a prompt's attachment loads from (default: its `dataUrl`); one with none is left out.
|
|
48
49
|
*/
|
|
49
|
-
function exchangesMedia(events) {
|
|
50
|
+
function exchangesMedia(events, attachmentSrc = (att) => att.dataUrl) {
|
|
50
51
|
const exchanges = [[]];
|
|
51
52
|
let current = exchanges[0];
|
|
52
53
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -75,7 +76,8 @@ function exchangesMedia(events) {
|
|
|
75
76
|
exchanges.push(current);
|
|
76
77
|
seen.clear();
|
|
77
78
|
(event.attachments ?? []).forEach((att, index) => {
|
|
78
|
-
|
|
79
|
+
const dataUrl = attachmentSrc(att);
|
|
80
|
+
if (!dataUrl) return;
|
|
79
81
|
const kind = att.mediaType.startsWith("image/") ? "image" : isPdf(att.mediaType) ? "pdf" : isText(att.mediaType) ? "text" : null;
|
|
80
82
|
if (kind) add({
|
|
81
83
|
key: mediumKey.attachment(index),
|
|
@@ -84,7 +86,7 @@ function exchangesMedia(events) {
|
|
|
84
86
|
name: att.name,
|
|
85
87
|
mediaType: att.mediaType,
|
|
86
88
|
size: att.size,
|
|
87
|
-
dataUrl
|
|
89
|
+
dataUrl
|
|
88
90
|
});
|
|
89
91
|
});
|
|
90
92
|
addRefs(event.text);
|
|
@@ -96,13 +98,14 @@ function exchangesMedia(events) {
|
|
|
96
98
|
}
|
|
97
99
|
if (event.kind === "tool-result" && event.callId && event.text.includes("[")) {
|
|
98
100
|
const callId = event.callId;
|
|
99
|
-
for (const item of parseToolMedia(event.text).media) add({
|
|
101
|
+
for (const item of parseToolMedia(event.text, void 0, event.mediaRefs).media) add({
|
|
100
102
|
key: mediumKey.tool(callId, item.index),
|
|
101
103
|
from: "tool",
|
|
102
104
|
kind: item.kind,
|
|
103
105
|
name: event.tool ?? item.mediaType,
|
|
104
106
|
callId,
|
|
105
|
-
index: item.index
|
|
107
|
+
index: item.index,
|
|
108
|
+
...item.hash ? { hash: item.hash } : {}
|
|
106
109
|
});
|
|
107
110
|
}
|
|
108
111
|
}
|
|
@@ -14,6 +14,8 @@ export interface FoldAttachment {
|
|
|
14
14
|
index: number;
|
|
15
15
|
/** The call's overview line ("Screenshot localhost:5173"): the image's name in the lightbox. */
|
|
16
16
|
label: string;
|
|
17
|
+
/** The blob hash the store holds it by, when it does (`TranscriptActions.blobMediaUrl`). */
|
|
18
|
+
hash?: string;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* Whether two lists show the same images under the same names, in the same
|
|
@@ -12,11 +12,12 @@ function callImages(tool) {
|
|
|
12
12
|
let images = NONE;
|
|
13
13
|
if (callId && typeof result === "string" && result.includes("[image:")) {
|
|
14
14
|
const label = toolAction(tool).label;
|
|
15
|
-
images = parseToolMedia(result).media.filter((m) => m.kind === "image").map((m) => ({
|
|
15
|
+
images = parseToolMedia(result, void 0, tool.mediaRefs).media.filter((m) => m.kind === "image").map((m) => ({
|
|
16
16
|
key: `${callId}:${m.index}`,
|
|
17
17
|
callId,
|
|
18
18
|
index: m.index,
|
|
19
|
-
label
|
|
19
|
+
label,
|
|
20
|
+
...m.hash ? { hash: m.hash } : {}
|
|
20
21
|
}));
|
|
21
22
|
}
|
|
22
23
|
CACHE.set(tool, images);
|
|
@@ -57,8 +57,9 @@ export declare function dockRunReceipts(rows: readonly Row[], show: boolean): {
|
|
|
57
57
|
*
|
|
58
58
|
* @param rows - The transcript rows after batching and receipt docking, oldest first.
|
|
59
59
|
* @param isStreaming - A run is in flight, so the last exchange is live.
|
|
60
|
+
* @param final - `rows` end the transcript. False for a part that more rows (opening with a boundary) follow: its last exchange is then settled.
|
|
60
61
|
*/
|
|
61
|
-
export declare function foldExchanges(rows: readonly Row[], isStreaming: boolean): Row[];
|
|
62
|
+
export declare function foldExchanges(rows: readonly Row[], isStreaming: boolean, final?: boolean): Row[];
|
|
62
63
|
/**
|
|
63
64
|
* A worker's (subagent's) own rows folded like an exchange of the main
|
|
64
65
|
* transcript: its tool calls, thoughts and the workers it started behind one
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FOLD_CACHE, IdHold, TOOL_GROUP_BOUNDARIES, sameMembers } from "./batch.js";
|
|
2
2
|
import { toolFailed } from "./collapse.js";
|
|
3
3
|
import { foldUnits } from "./fold-actions.js";
|
|
4
|
-
import { countTaskOutcomes, foldSummary, foldsInCompactShape, planFold, taskOutcome } from "zidane/chat/pure";
|
|
4
|
+
import { countTaskOutcomes, foldSummary, foldsInCompactShape, noteTranscriptPass, planFold, taskOutcome } from "zidane/chat/pure";
|
|
5
5
|
// src/chat/headless/transcript/fold.ts
|
|
6
6
|
/**
|
|
7
7
|
* Fold `run-summary` rows into the assistant row that closed the run: the
|
|
@@ -31,6 +31,7 @@ import { countTaskOutcomes, foldSummary, foldsInCompactShape, planFold, taskOutc
|
|
|
31
31
|
* @param show - Whether to show run receipts. When false they are dropped.
|
|
32
32
|
*/
|
|
33
33
|
function dockRunReceipts(rows, show) {
|
|
34
|
+
noteTranscriptPass("dock-receipts", rows.length);
|
|
34
35
|
const receiptByRowId = /* @__PURE__ */ new Map();
|
|
35
36
|
const visibleRows = [];
|
|
36
37
|
let lastAssistantRowId = null;
|
|
@@ -118,8 +119,10 @@ function rowStats(stats) {
|
|
|
118
119
|
*
|
|
119
120
|
* @param rows - The transcript rows after batching and receipt docking, oldest first.
|
|
120
121
|
* @param isStreaming - A run is in flight, so the last exchange is live.
|
|
122
|
+
* @param final - `rows` end the transcript. False for a part that more rows (opening with a boundary) follow: its last exchange is then settled.
|
|
121
123
|
*/
|
|
122
|
-
function foldExchanges(rows, isStreaming) {
|
|
124
|
+
function foldExchanges(rows, isStreaming, final = true) {
|
|
125
|
+
noteTranscriptPass("fold-exchanges", rows.length);
|
|
123
126
|
const out = [];
|
|
124
127
|
const used = /* @__PURE__ */ new Set();
|
|
125
128
|
let boundary = null;
|
|
@@ -162,7 +165,7 @@ function foldExchanges(rows, isStreaming) {
|
|
|
162
165
|
};
|
|
163
166
|
for (let i = 0; i < rows.length; i++) {
|
|
164
167
|
const row = rows[i];
|
|
165
|
-
if (row.kind === "compact-summary" && boundary?.kind === "user-prompt" && compactionInRun(rows, i, isStreaming)) {
|
|
168
|
+
if (row.kind === "compact-summary" && boundary?.kind === "user-prompt" && compactionInRun(rows, i, isStreaming && final)) {
|
|
166
169
|
folded.push(row);
|
|
167
170
|
continue;
|
|
168
171
|
}
|
|
@@ -175,7 +178,7 @@ function foldExchanges(rows, isStreaming) {
|
|
|
175
178
|
if (foldsInCompact(row)) folded.push(row);
|
|
176
179
|
else visible.push(row);
|
|
177
180
|
}
|
|
178
|
-
flush(
|
|
181
|
+
flush(final);
|
|
179
182
|
return out;
|
|
180
183
|
}
|
|
181
184
|
/**
|
|
@@ -276,9 +279,16 @@ function groupMessages(visible, boundary, live, used) {
|
|
|
276
279
|
function findLastStreamingRow(rows) {
|
|
277
280
|
for (let i = rows.length - 1; i >= 0; i -= 1) {
|
|
278
281
|
const row = rows[i];
|
|
279
|
-
if (row.kind === "markdown" && row.streaming)
|
|
280
|
-
|
|
282
|
+
if (row.kind === "markdown" && row.streaming) {
|
|
283
|
+
noteTranscriptPass("last-streaming", rows.length - i);
|
|
284
|
+
return row;
|
|
285
|
+
}
|
|
286
|
+
if (row.kind === "message-group" && row.current.kind === "markdown" && row.current.streaming) {
|
|
287
|
+
noteTranscriptPass("last-streaming", rows.length - i);
|
|
288
|
+
return row.current;
|
|
289
|
+
}
|
|
281
290
|
}
|
|
291
|
+
noteTranscriptPass("last-streaming", rows.length);
|
|
282
292
|
return null;
|
|
283
293
|
}
|
|
284
294
|
/** A background task's dot, by how it ended. */
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The row pipeline (`derive.ts`), incremental: a transcript store's settled
|
|
3
|
+
* exchanges (`TranscriptEvents.chunks`) derive once, in blocks that no pass
|
|
4
|
+
* looks across (`seams.ts`), and each frame derives only the open exchange
|
|
5
|
+
* (the tail) and joins. The settled rows and clusters keep their identity
|
|
6
|
+
* across frames, and so does the settled part's array while only the open
|
|
7
|
+
* exchange changes (`parts.settled`). An exchange tied to the open one
|
|
8
|
+
* (a subagent writing across a prompt, a setup, a repaired environment)
|
|
9
|
+
* derives with it, so the result always equals the whole pipeline's.
|
|
10
|
+
*
|
|
11
|
+
* Handed a plain array, the deriver splits it into exchanges first (one walk,
|
|
12
|
+
* reusing the exchanges it saw last time); an array a transcript store made
|
|
13
|
+
* (`transcriptArray`) maps back to its store for free.
|
|
14
|
+
*/
|
|
15
|
+
import { ChatEvent } from "../host.js";
|
|
16
|
+
import { DerivedTranscriptRows, TranscriptRowOptions } from "./derive.js";
|
|
17
|
+
import { Cluster, Row } from "./rows.js";
|
|
18
|
+
import { RunReceipt, TranscriptEvents } from "zidane/chat/pure";
|
|
19
|
+
/** Rows and their clusters, for one side of the settled / open split. */
|
|
20
|
+
export interface TranscriptRowsSlice {
|
|
21
|
+
/** The rows, in paint order. */
|
|
22
|
+
rows: readonly Row[];
|
|
23
|
+
/** The rows grouped into subagent blocks. */
|
|
24
|
+
clusters: readonly Cluster[];
|
|
25
|
+
/** The run receipts docked on these rows, by row id. */
|
|
26
|
+
receipts?: ReadonlyMap<string, RunReceipt>;
|
|
27
|
+
}
|
|
28
|
+
/** The derived rows, whole and in their two parts. */
|
|
29
|
+
export interface IncrementalTranscriptRows extends DerivedTranscriptRows {
|
|
30
|
+
/**
|
|
31
|
+
* `visibleRows` and `clusters` in two parts: the settled exchanges (the same
|
|
32
|
+
* arrays while only the open exchange changes) and the open one. A renderer
|
|
33
|
+
* can read these instead of the joined arrays: those are joined on first
|
|
34
|
+
* read (a copy of every row), these are not.
|
|
35
|
+
*/
|
|
36
|
+
parts: {
|
|
37
|
+
settled: TranscriptRowsSlice;
|
|
38
|
+
open: TranscriptRowsSlice;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Derives a transcript's rows, keeping what it derived for the settled exchanges. One per transcript view. */
|
|
42
|
+
export interface TranscriptRowsDeriver {
|
|
43
|
+
/**
|
|
44
|
+
* The rows of `source`: a transcript store, or an array (mapped back to its store when one made it).
|
|
45
|
+
*
|
|
46
|
+
* @param source - The transcript.
|
|
47
|
+
* @param streaming - A run is in flight.
|
|
48
|
+
* @param options - The display options.
|
|
49
|
+
*/
|
|
50
|
+
derive: (source: readonly ChatEvent[] | TranscriptEvents<ChatEvent>, streaming: boolean, options: TranscriptRowOptions) => IncrementalTranscriptRows;
|
|
51
|
+
}
|
|
52
|
+
/** A deriver for one transcript view (it keeps the settled exchanges' rows of the transcript it last derived). */
|
|
53
|
+
export declare function createTranscriptRowsDeriver(): TranscriptRowsDeriver;
|