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,181 @@
|
|
|
1
|
+
import { deriveRowsPart, resumableRowId } from "./derive.js";
|
|
2
|
+
import { BlockPlan, tailTies } from "./seams.js";
|
|
3
|
+
import { noteTranscriptPass, transcriptFromArray, transcriptOfArray } from "zidane/chat/pure";
|
|
4
|
+
// src/chat/headless/transcript/incremental.ts
|
|
5
|
+
const seamOf = (row) => !row ? "none" : row.kind === "separator" ? "separator" : "other";
|
|
6
|
+
function optionsKey(o) {
|
|
7
|
+
return `${+o.showCacheNotices}${+o.codemodeShowCalls}${+o.showEditDiffs}${+o.groupToolCalls}${+o.showRunReceipt}${+o.compact}`;
|
|
8
|
+
}
|
|
9
|
+
/** A settled block's rows, per its first chunk. */
|
|
10
|
+
const blocks = /* @__PURE__ */ new WeakMap();
|
|
11
|
+
function sameChunks(a, b) {
|
|
12
|
+
if (a.length !== b.length) return false;
|
|
13
|
+
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
function eventsOf(chunks, tail) {
|
|
17
|
+
if (chunks.length === 0) return tail ?? [];
|
|
18
|
+
if (chunks.length === 1 && !tail) return chunks[0];
|
|
19
|
+
const all = tail ? [...chunks, tail] : chunks;
|
|
20
|
+
noteTranscriptPass("join:events", all.reduce((n, c) => n + c.length, 0));
|
|
21
|
+
return all.flat();
|
|
22
|
+
}
|
|
23
|
+
function settledBlock(chunks, streaming, options, optsKey, before) {
|
|
24
|
+
const key = `${optsKey}|${+streaming}|${seamOf(before)}`;
|
|
25
|
+
const hit = blocks.get(chunks[0]);
|
|
26
|
+
if (hit && hit.key === key && sameChunks(hit.chunks, chunks)) return hit.part;
|
|
27
|
+
const part = deriveRowsPart(eventsOf(chunks), streaming, options, false, before);
|
|
28
|
+
blocks.set(chunks[0], {
|
|
29
|
+
chunks,
|
|
30
|
+
key,
|
|
31
|
+
part
|
|
32
|
+
});
|
|
33
|
+
return part;
|
|
34
|
+
}
|
|
35
|
+
const EMPTY_RECEIPTS = /* @__PURE__ */ new Map();
|
|
36
|
+
/** Two receipt maps read as one (the settled part's, merged once, and the open part's). */
|
|
37
|
+
var JoinedMap = class {
|
|
38
|
+
a;
|
|
39
|
+
b;
|
|
40
|
+
constructor(a, b) {
|
|
41
|
+
this.a = a;
|
|
42
|
+
this.b = b;
|
|
43
|
+
}
|
|
44
|
+
get size() {
|
|
45
|
+
return this.a.size + this.b.size;
|
|
46
|
+
}
|
|
47
|
+
get(key) {
|
|
48
|
+
return this.b.get(key) ?? this.a.get(key);
|
|
49
|
+
}
|
|
50
|
+
has(key) {
|
|
51
|
+
return this.b.has(key) || this.a.has(key);
|
|
52
|
+
}
|
|
53
|
+
forEach(callback) {
|
|
54
|
+
for (const [key, value] of this) callback(value, key, this);
|
|
55
|
+
}
|
|
56
|
+
*entries() {
|
|
57
|
+
yield* this.a.entries();
|
|
58
|
+
yield* this.b.entries();
|
|
59
|
+
}
|
|
60
|
+
*keys() {
|
|
61
|
+
for (const [key] of this.entries()) yield key;
|
|
62
|
+
}
|
|
63
|
+
*values() {
|
|
64
|
+
for (const [, value] of this.entries()) yield value;
|
|
65
|
+
}
|
|
66
|
+
[Symbol.iterator]() {
|
|
67
|
+
return this.entries();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const NO_SETTLED = {
|
|
71
|
+
chunks: [],
|
|
72
|
+
count: 0,
|
|
73
|
+
key: "",
|
|
74
|
+
slice: {
|
|
75
|
+
rows: [],
|
|
76
|
+
clusters: []
|
|
77
|
+
},
|
|
78
|
+
receipts: EMPTY_RECEIPTS,
|
|
79
|
+
lastCollapsed: void 0,
|
|
80
|
+
lastStreaming: null
|
|
81
|
+
};
|
|
82
|
+
function joinSettled(parts, base) {
|
|
83
|
+
const rows = parts.flatMap((p) => p.rows);
|
|
84
|
+
noteTranscriptPass("join:settled", rows.length);
|
|
85
|
+
const receipts = /* @__PURE__ */ new Map();
|
|
86
|
+
let lastStreaming = null;
|
|
87
|
+
for (const part of parts) {
|
|
88
|
+
part.receipts.forEach((receipt, id) => receipts.set(id, receipt));
|
|
89
|
+
lastStreaming = part.lastStreaming ?? lastStreaming;
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
...base,
|
|
93
|
+
slice: {
|
|
94
|
+
rows,
|
|
95
|
+
clusters: parts.flatMap((p) => p.clusters),
|
|
96
|
+
receipts
|
|
97
|
+
},
|
|
98
|
+
receipts,
|
|
99
|
+
lastCollapsed: parts.at(-1)?.lastCollapsed,
|
|
100
|
+
lastStreaming
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/** A deriver for one transcript view (it keeps the settled exchanges' rows of the transcript it last derived). */
|
|
104
|
+
function createTranscriptRowsDeriver() {
|
|
105
|
+
const plan = new BlockPlan();
|
|
106
|
+
let settled = NO_SETTLED;
|
|
107
|
+
let last = null;
|
|
108
|
+
const settle = (transcript, count, streaming, options, optsKey) => {
|
|
109
|
+
const key = `${optsKey}|${+streaming}`;
|
|
110
|
+
if (settled.count === count && settled.key === key && sameChunks(settled.chunks, transcript.chunks)) return settled;
|
|
111
|
+
if (count === 0) return {
|
|
112
|
+
...NO_SETTLED,
|
|
113
|
+
chunks: transcript.chunks,
|
|
114
|
+
key
|
|
115
|
+
};
|
|
116
|
+
const parts = [];
|
|
117
|
+
let before;
|
|
118
|
+
for (let b = 0; b < count; b++) {
|
|
119
|
+
const block = plan.blocks[b];
|
|
120
|
+
const part = settledBlock(transcript.chunks.slice(block.start, block.end), streaming, options, optsKey, before);
|
|
121
|
+
parts.push(part);
|
|
122
|
+
before = part.lastCollapsed;
|
|
123
|
+
}
|
|
124
|
+
return joinSettled(parts, {
|
|
125
|
+
chunks: transcript.chunks,
|
|
126
|
+
count,
|
|
127
|
+
key
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
const derive = (source, streaming, options) => {
|
|
131
|
+
const transcript = Array.isArray(source) ? transcriptOfArray(source) ?? transcriptFromArray(source, last?.transcript) : source;
|
|
132
|
+
const optsKey = optionsKey(options);
|
|
133
|
+
if (last && last.transcript === transcript && last.streaming === streaming && last.key === optsKey) return last.result;
|
|
134
|
+
plan.update(transcript.chunks);
|
|
135
|
+
const count = plan.joinFrom(tailTies(transcript.tail));
|
|
136
|
+
settled = settle(transcript, count, streaming, options, optsKey);
|
|
137
|
+
const from = count < plan.blocks.length ? plan.blocks[count].start : transcript.chunks.length;
|
|
138
|
+
const events = eventsOf(transcript.chunks.slice(from), transcript.tail);
|
|
139
|
+
const open = deriveRowsPart(events, streaming, options, true, settled.lastCollapsed);
|
|
140
|
+
const prior = settled.slice;
|
|
141
|
+
const receiptByRowId = settled.receipts.size === 0 ? open.receipts : open.receipts.size === 0 ? settled.receipts : new JoinedMap(settled.receipts, open.receipts);
|
|
142
|
+
let visibleRows;
|
|
143
|
+
let clusters;
|
|
144
|
+
const result = {
|
|
145
|
+
get visibleRows() {
|
|
146
|
+
if (!visibleRows) {
|
|
147
|
+
if (prior.rows.length > 0) noteTranscriptPass("join:rows", prior.rows.length + open.rows.length);
|
|
148
|
+
visibleRows = prior.rows.length > 0 ? prior.rows.concat(open.rows) : open.rows;
|
|
149
|
+
}
|
|
150
|
+
return visibleRows;
|
|
151
|
+
},
|
|
152
|
+
receiptByRowId,
|
|
153
|
+
resumableId: resumableRowId([prior.rows, open.rows], streaming),
|
|
154
|
+
get clusters() {
|
|
155
|
+
if (!clusters) {
|
|
156
|
+
if (prior.clusters.length > 0) noteTranscriptPass("join:clusters", prior.clusters.length + open.clusters.length);
|
|
157
|
+
clusters = prior.clusters.length > 0 ? prior.clusters.concat(open.clusters) : open.clusters;
|
|
158
|
+
}
|
|
159
|
+
return clusters;
|
|
160
|
+
},
|
|
161
|
+
lastStreamingRow: open.lastStreaming ?? settled.lastStreaming,
|
|
162
|
+
parts: {
|
|
163
|
+
settled: prior,
|
|
164
|
+
open: {
|
|
165
|
+
rows: open.rows,
|
|
166
|
+
clusters: open.clusters,
|
|
167
|
+
receipts: open.receipts
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
last = {
|
|
172
|
+
transcript,
|
|
173
|
+
streaming,
|
|
174
|
+
key: optsKey,
|
|
175
|
+
result
|
|
176
|
+
};
|
|
177
|
+
return result;
|
|
178
|
+
};
|
|
179
|
+
return { derive };
|
|
180
|
+
}
|
|
181
|
+
export { createTranscriptRowsDeriver };
|
|
@@ -6,8 +6,8 @@ import { dockRunReceipts, dotVariantFor, findLastStreamingRow, foldExchanges, fo
|
|
|
6
6
|
import { FoldActionItem, FoldActionState, foldActionItems, toolAction } from "./fold-actions.js";
|
|
7
7
|
import { nestToolCalls, nestedCallVisible } from "./nesting.js";
|
|
8
8
|
import { PairingResult, ToolPairing, pairToolEvents } from "./pairing.js";
|
|
9
|
-
import { EMPTY_RAIL, RailExchange, RailModel, TranscriptRailState, TranscriptRailStore, computeRailModel, createTranscriptRailStore, dataRowSelector, plainPreview, sameRail } from "./rail.js";
|
|
9
|
+
import { EMPTY_RAIL, RailExchange, RailModel, TranscriptRailState, TranscriptRailStore, computeRailModel, computeRailModelParts, createTranscriptRailStore, dataRowSelector, plainPreview, railWithOutline, sameRail } from "./rail.js";
|
|
10
10
|
import { BashExitMeta, Cluster, DotVariant, ExchangeFoldStats, GroupCluster, Owned, Row, SpawnMeta, TaskInfo, ToolRowModel, firstRowId, parseBashExitMeta } from "./rows.js";
|
|
11
11
|
import { RunFailure, failureTooltip, markRunFailures } from "./run-failures.js";
|
|
12
12
|
import { SelectStops, computeSelectStops, rowTurnIds, stopForRow } from "./select-stops.js";
|
|
13
|
-
export { type AuthCardPlan, type AuthFixes, type AuthSettingsTarget, type BashExitMeta, type Cluster, type DotVariant, EMPTY_RAIL, type ExchangeFoldStats, type ExchangeMedium, type FoldActionItem, type FoldActionState, type GroupCluster, type MediaRef, type Owned, type PairingResult, type RailExchange, type RailModel, type Row, type RunFailure, type SelectStops, type SpawnMeta, type TaskInfo, type ToolPairing, type ToolRowModel, type TranscriptRailState, type TranscriptRailStore, authFailureDetails, batchTaskRuns, batchThinkingRuns, batchToolRuns, clusterByOwner, collapseEvents, computeRailModel, computeSelectStops, createAuthFixes, createTranscriptRailStore, dataRowSelector, dockRunReceipts, dotVariantFor, exchangesMedia, failureTooltip, findLastStreamingRow, firstRowId, foldActionItems, foldExchanges, foldWorkerRows, inheritRowIdentity, isAuthFixed, markRunFailures, mediaRefsOf, mediumKey, nestToolCalls, nestedCallVisible, pairToolEvents, parseBashExitMeta, plainPreview, planAuthCard, refusedSpawn, rowTurnIds, sameRail, stopForRow, toolAction, toolFailed };
|
|
13
|
+
export { type AuthCardPlan, type AuthFixes, type AuthSettingsTarget, type BashExitMeta, type Cluster, type DotVariant, EMPTY_RAIL, type ExchangeFoldStats, type ExchangeMedium, type FoldActionItem, type FoldActionState, type GroupCluster, type MediaRef, type Owned, type PairingResult, type RailExchange, type RailModel, type Row, type RunFailure, type SelectStops, type SpawnMeta, type TaskInfo, type ToolPairing, type ToolRowModel, type TranscriptRailState, type TranscriptRailStore, authFailureDetails, batchTaskRuns, batchThinkingRuns, batchToolRuns, clusterByOwner, collapseEvents, computeRailModel, computeRailModelParts, computeSelectStops, createAuthFixes, createTranscriptRailStore, dataRowSelector, dockRunReceipts, dotVariantFor, exchangesMedia, failureTooltip, findLastStreamingRow, firstRowId, foldActionItems, foldExchanges, foldWorkerRows, inheritRowIdentity, isAuthFixed, markRunFailures, mediaRefsOf, mediumKey, nestToolCalls, nestedCallVisible, pairToolEvents, parseBashExitMeta, plainPreview, planAuthCard, railWithOutline, refusedSpawn, rowTurnIds, sameRail, stopForRow, toolAction, toolFailed };
|
|
@@ -6,8 +6,8 @@ import { dockRunReceipts, dotVariantFor, findLastStreamingRow, foldExchanges, fo
|
|
|
6
6
|
import { foldActionItems, toolAction } from "./fold-actions.js";
|
|
7
7
|
import { nestToolCalls, nestedCallVisible } from "./nesting.js";
|
|
8
8
|
import { pairToolEvents } from "./pairing.js";
|
|
9
|
-
import { EMPTY_RAIL, computeRailModel, createTranscriptRailStore, dataRowSelector, plainPreview, sameRail } from "./rail.js";
|
|
9
|
+
import { EMPTY_RAIL, computeRailModel, computeRailModelParts, createTranscriptRailStore, dataRowSelector, plainPreview, railWithOutline, sameRail } from "./rail.js";
|
|
10
10
|
import { firstRowId, parseBashExitMeta } from "./rows.js";
|
|
11
11
|
import { failureTooltip, markRunFailures } from "./run-failures.js";
|
|
12
12
|
import { computeSelectStops, rowTurnIds, stopForRow } from "./select-stops.js";
|
|
13
|
-
export { EMPTY_RAIL, authFailureDetails, batchTaskRuns, batchThinkingRuns, batchToolRuns, clusterByOwner, collapseEvents, computeRailModel, computeSelectStops, createAuthFixes, createTranscriptRailStore, dataRowSelector, dockRunReceipts, dotVariantFor, exchangesMedia, failureTooltip, findLastStreamingRow, firstRowId, foldActionItems, foldExchanges, foldWorkerRows, inheritRowIdentity, isAuthFixed, markRunFailures, mediaRefsOf, mediumKey, nestToolCalls, nestedCallVisible, pairToolEvents, parseBashExitMeta, plainPreview, planAuthCard, refusedSpawn, rowTurnIds, sameRail, stopForRow, toolAction, toolFailed };
|
|
13
|
+
export { EMPTY_RAIL, authFailureDetails, batchTaskRuns, batchThinkingRuns, batchToolRuns, clusterByOwner, collapseEvents, computeRailModel, computeRailModelParts, computeSelectStops, createAuthFixes, createTranscriptRailStore, dataRowSelector, dockRunReceipts, dotVariantFor, exchangesMedia, failureTooltip, findLastStreamingRow, firstRowId, foldActionItems, foldExchanges, foldWorkerRows, inheritRowIdentity, isAuthFixed, markRunFailures, mediaRefsOf, mediumKey, nestToolCalls, nestedCallVisible, pairToolEvents, parseBashExitMeta, plainPreview, planAuthCard, railWithOutline, refusedSpawn, rowTurnIds, sameRail, stopForRow, toolAction, toolFailed };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sameMembers } from "./batch.js";
|
|
2
|
-
import { nestedCallShown } from "zidane/chat/pure";
|
|
2
|
+
import { nestedCallShown, noteTranscriptPass } from "zidane/chat/pure";
|
|
3
3
|
// src/chat/headless/transcript/nesting.ts
|
|
4
4
|
/**
|
|
5
5
|
* Whether a nested call's events show: core's `nestedCallShown` (a subagent,
|
|
@@ -23,6 +23,7 @@ const callKey = (owner, callId) => `${owner ?? ""}\u0000${callId}`;
|
|
|
23
23
|
* @param rows - Rows from {@link collapseEvents}, oldest first.
|
|
24
24
|
*/
|
|
25
25
|
function nestToolCalls(rows) {
|
|
26
|
+
noteTranscriptPass("nest", rows.length);
|
|
26
27
|
const calls = /* @__PURE__ */ new Map();
|
|
27
28
|
for (const row of rows) if (row.kind === "tool" && row.callId) calls.set(callKey(row.childId, row.callId), row);
|
|
28
29
|
const childrenOf = /* @__PURE__ */ new Map();
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { Readable } from "../store.js";
|
|
15
15
|
import { Cluster, Row } from "./rows.js";
|
|
16
|
-
import { RunReceipt } from "zidane/chat/pure";
|
|
16
|
+
import { PromptOutlineEntry, RunReceipt } from "zidane/chat/pure";
|
|
17
17
|
/** One exchange on the rail: a typed prompt and the run that answered it. */
|
|
18
18
|
export interface RailExchange {
|
|
19
19
|
/** The prompt row's id: the exchange's id and the row a jump lands on. */
|
|
@@ -28,6 +28,14 @@ export interface RailExchange {
|
|
|
28
28
|
lastRowId: string;
|
|
29
29
|
/** The receipt of the run that answered (model, duration), when it docked one. */
|
|
30
30
|
receipt?: RunReceipt;
|
|
31
|
+
/**
|
|
32
|
+
* A prompt of the session's outline whose history is not loaded yet: no rows (`firstRowId` and `lastRowId` are
|
|
33
|
+
* empty), its turn and where it sits. A jump loads up to `index` first.
|
|
34
|
+
*/
|
|
35
|
+
unloaded?: {
|
|
36
|
+
turnId: string;
|
|
37
|
+
index: number;
|
|
38
|
+
};
|
|
31
39
|
}
|
|
32
40
|
/** The rail's exchanges and how any turn maps to the exchange that holds it. */
|
|
33
41
|
export interface RailModel {
|
|
@@ -62,6 +70,41 @@ export declare function computeRailModel(clusters: readonly Cluster[], { isHidde
|
|
|
62
70
|
isHidden?: (row: Row) => boolean;
|
|
63
71
|
receipts?: ReadonlyMap<string, RunReceipt>;
|
|
64
72
|
}): RailModel;
|
|
73
|
+
/**
|
|
74
|
+
* {@link computeRailModel} over the two parts an incremental transcript paints: the settled
|
|
75
|
+
* clusters fold once (per clusters array), each stream tick folds the open ones. The settled
|
|
76
|
+
* exchanges' rail entries keep their objects, and the turn map reads through to theirs.
|
|
77
|
+
*
|
|
78
|
+
* @param parts - The settled and the open root clusters.
|
|
79
|
+
* @param parts.settled - The settled exchanges' clusters and receipts.
|
|
80
|
+
* @param parts.settled.clusters - The settled root clusters (one fold per array).
|
|
81
|
+
* @param parts.settled.receipts - The receipts docked on them.
|
|
82
|
+
* @param parts.open - The open exchange's clusters.
|
|
83
|
+
* @param parts.open.clusters - The open root clusters.
|
|
84
|
+
* @param options - As {@link computeRailModel}'s; `receipts` holds both parts'.
|
|
85
|
+
* @param options.isHidden - Whether a row paints nothing.
|
|
86
|
+
* @param options.receipts - The run receipts, by the id of the reply row they dock on.
|
|
87
|
+
*/
|
|
88
|
+
export declare function computeRailModelParts(parts: {
|
|
89
|
+
settled: {
|
|
90
|
+
clusters: readonly Cluster[];
|
|
91
|
+
receipts?: ReadonlyMap<string, RunReceipt>;
|
|
92
|
+
};
|
|
93
|
+
open: {
|
|
94
|
+
clusters: readonly Cluster[];
|
|
95
|
+
};
|
|
96
|
+
}, { isHidden, receipts }?: {
|
|
97
|
+
isHidden?: (row: Row) => boolean;
|
|
98
|
+
receipts?: ReadonlyMap<string, RunReceipt>;
|
|
99
|
+
}): RailModel;
|
|
100
|
+
/**
|
|
101
|
+
* The rail with the session's whole outline: the outline's prompts before the first loaded one (their history is
|
|
102
|
+
* not loaded yet) as unloaded exchanges, then the loaded exchanges. The same array when there are none to add.
|
|
103
|
+
*
|
|
104
|
+
* @param model - The loaded exchanges.
|
|
105
|
+
* @param outline - The session's prompts, oldest first, or `null` when there is none (all loaded, or the host can't say).
|
|
106
|
+
*/
|
|
107
|
+
export declare function railWithOutline(model: RailModel, outline: readonly PromptOutlineEntry[] | null): readonly RailExchange[];
|
|
65
108
|
/**
|
|
66
109
|
* Whether two exchange lists show the same rail: same exchanges, same text, same span and receipt.
|
|
67
110
|
*
|
|
@@ -75,6 +118,10 @@ export interface TranscriptRailState extends RailModel {
|
|
|
75
118
|
hovered: string | null;
|
|
76
119
|
/** The exchange holding select-turn mode's cursor, or `null` outside the mode. */
|
|
77
120
|
selected: string | null;
|
|
121
|
+
/** The session's whole prompt outline while part of its history is not loaded; `null` otherwise. */
|
|
122
|
+
outline: readonly PromptOutlineEntry[] | null;
|
|
123
|
+
/** Loads the history up to a turn position (`Transcript.loadThrough`); `null`: unloaded prompts can't be reached. */
|
|
124
|
+
loadThrough: ((index: number) => Promise<boolean>) | null;
|
|
78
125
|
}
|
|
79
126
|
/**
|
|
80
127
|
* The bridge between a transcript and its rail: the transcript publishes its
|
|
@@ -88,6 +135,8 @@ export interface TranscriptRailStore extends Readable<TranscriptRailState> {
|
|
|
88
135
|
hover: (id: string | null) => void;
|
|
89
136
|
/** The exchange holding select-turn mode's cursor, or `null`. */
|
|
90
137
|
select: (id: string | null) => void;
|
|
138
|
+
/** The session's outline (`null`: none, all is loaded) and how to load up to one of its prompts. */
|
|
139
|
+
publishOutline: (outline: readonly PromptOutlineEntry[] | null, loadThrough: ((index: number) => Promise<boolean>) | null) => void;
|
|
91
140
|
}
|
|
92
141
|
/** A rail store with no exchange: one per transcript view (the provider makes it). */
|
|
93
142
|
export declare function createTranscriptRailStore(): TranscriptRailStore;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { writable } from "../store.js";
|
|
2
2
|
import { rowTurnIds } from "./select-stops.js";
|
|
3
|
+
import { noteTranscriptPass } from "zidane/chat/pure";
|
|
3
4
|
// src/chat/headless/transcript/rail.ts
|
|
4
5
|
/** The longest text an exchange keeps for its preview: the card clamps its lines, this bounds the work. */
|
|
5
6
|
const PREVIEW_CHARS = 320;
|
|
@@ -59,28 +60,95 @@ function* rowsWithin(row) {
|
|
|
59
60
|
* @param options.receipts - The run receipts, by the id of the reply row they dock on.
|
|
60
61
|
*/
|
|
61
62
|
function computeRailModel(clusters, { isHidden = () => false, receipts } = {}) {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
63
|
+
const fold = railFold();
|
|
64
|
+
foldRail(fold, clusters, isHidden, receipts);
|
|
65
|
+
closeRail(fold, receipts);
|
|
66
|
+
return {
|
|
67
|
+
exchanges: fold.exchanges,
|
|
68
|
+
exchangeOfTurn: fold.exchangeOfTurn
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/** Two turn maps read as one: the settled exchanges' and the open part's (which wins). */
|
|
72
|
+
var LayeredTurns = class {
|
|
73
|
+
base;
|
|
74
|
+
top = /* @__PURE__ */ new Map();
|
|
75
|
+
constructor(base) {
|
|
76
|
+
this.base = base;
|
|
77
|
+
}
|
|
78
|
+
get size() {
|
|
79
|
+
let n = this.base.size;
|
|
80
|
+
for (const key of this.top.keys()) n += this.base.has(key) ? 0 : 1;
|
|
81
|
+
return n;
|
|
82
|
+
}
|
|
83
|
+
get(key) {
|
|
84
|
+
return this.top.has(key) ? this.top.get(key) : this.base.get(key);
|
|
85
|
+
}
|
|
86
|
+
has(key) {
|
|
87
|
+
return this.top.has(key) || this.base.has(key);
|
|
88
|
+
}
|
|
89
|
+
set(key, value) {
|
|
90
|
+
this.top.set(key, value);
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
forEach(callback) {
|
|
94
|
+
for (const [key, value] of this) callback(value, key, this);
|
|
95
|
+
}
|
|
96
|
+
*entries() {
|
|
97
|
+
for (const [key, value] of this.base) if (!this.top.has(key)) yield [key, value];
|
|
98
|
+
yield* this.top.entries();
|
|
99
|
+
}
|
|
100
|
+
*keys() {
|
|
101
|
+
for (const [key] of this.entries()) yield key;
|
|
102
|
+
}
|
|
103
|
+
*values() {
|
|
104
|
+
for (const [, value] of this.entries()) yield value;
|
|
105
|
+
}
|
|
106
|
+
[Symbol.iterator]() {
|
|
107
|
+
return this.entries();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
function railFold(base) {
|
|
111
|
+
if (!base) return {
|
|
112
|
+
exchanges: [],
|
|
113
|
+
shared: false,
|
|
114
|
+
exchangeOfTurn: /* @__PURE__ */ new Map(),
|
|
115
|
+
current: null,
|
|
116
|
+
lastReply: null
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
exchanges: base.exchanges,
|
|
120
|
+
shared: true,
|
|
121
|
+
exchangeOfTurn: new LayeredTurns(base.exchangeOfTurn),
|
|
122
|
+
current: base.current ? { ...base.current } : null,
|
|
123
|
+
lastReply: base.lastReply
|
|
76
124
|
};
|
|
125
|
+
}
|
|
126
|
+
function closeRail(fold, receipts) {
|
|
127
|
+
const current = fold.current;
|
|
128
|
+
if (!current) return;
|
|
129
|
+
const lastReply = fold.lastReply;
|
|
130
|
+
if (lastReply && lastReply.kind === "markdown") {
|
|
131
|
+
current.answer = previewOf(lastReply) || null;
|
|
132
|
+
const receipt = receipts?.get(lastReply.id);
|
|
133
|
+
if (receipt) current.receipt = receipt;
|
|
134
|
+
}
|
|
135
|
+
if (fold.shared) {
|
|
136
|
+
fold.exchanges = [...fold.exchanges];
|
|
137
|
+
fold.shared = false;
|
|
138
|
+
}
|
|
139
|
+
fold.exchanges.push(current);
|
|
140
|
+
fold.current = null;
|
|
141
|
+
fold.lastReply = null;
|
|
142
|
+
}
|
|
143
|
+
function foldRail(fold, clusters, isHidden, receipts) {
|
|
144
|
+
noteTranscriptPass("rail", clusters.length);
|
|
77
145
|
for (const cluster of clusters) {
|
|
78
146
|
if (cluster.kind !== "single") continue;
|
|
79
147
|
const row = cluster.row;
|
|
80
148
|
if (isHidden(row)) continue;
|
|
81
149
|
if (row.kind === "user-prompt" && !row.synthetic && row.childId === void 0) {
|
|
82
|
-
|
|
83
|
-
current = {
|
|
150
|
+
closeRail(fold, receipts);
|
|
151
|
+
fold.current = {
|
|
84
152
|
id: row.id,
|
|
85
153
|
prompt: previewOf(row),
|
|
86
154
|
answer: null,
|
|
@@ -88,18 +156,80 @@ function computeRailModel(clusters, { isHidden = () => false, receipts } = {}) {
|
|
|
88
156
|
lastRowId: row.id
|
|
89
157
|
};
|
|
90
158
|
}
|
|
159
|
+
const current = fold.current;
|
|
91
160
|
if (!current) continue;
|
|
92
161
|
current.lastRowId = row.id;
|
|
93
|
-
for (const id of rowTurnIds(row)) if (!exchangeOfTurn.has(id)) exchangeOfTurn.set(id, current.id);
|
|
94
|
-
for (const inner of rowsWithin(row)) if (inner.kind === "markdown" && inner.text.trim() !== "") lastReply = inner;
|
|
162
|
+
for (const id of rowTurnIds(row)) if (!fold.exchangeOfTurn.has(id)) fold.exchangeOfTurn.set(id, current.id);
|
|
163
|
+
for (const inner of rowsWithin(row)) if (inner.kind === "markdown" && inner.text.trim() !== "") fold.lastReply = inner;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/** The settled clusters' fold, per clusters array (its rows keep their identity while only the open exchange changes). */
|
|
167
|
+
const settledRails = /* @__PURE__ */ new WeakMap();
|
|
168
|
+
/**
|
|
169
|
+
* {@link computeRailModel} over the two parts an incremental transcript paints: the settled
|
|
170
|
+
* clusters fold once (per clusters array), each stream tick folds the open ones. The settled
|
|
171
|
+
* exchanges' rail entries keep their objects, and the turn map reads through to theirs.
|
|
172
|
+
*
|
|
173
|
+
* @param parts - The settled and the open root clusters.
|
|
174
|
+
* @param parts.settled - The settled exchanges' clusters and receipts.
|
|
175
|
+
* @param parts.settled.clusters - The settled root clusters (one fold per array).
|
|
176
|
+
* @param parts.settled.receipts - The receipts docked on them.
|
|
177
|
+
* @param parts.open - The open exchange's clusters.
|
|
178
|
+
* @param parts.open.clusters - The open root clusters.
|
|
179
|
+
* @param options - As {@link computeRailModel}'s; `receipts` holds both parts'.
|
|
180
|
+
* @param options.isHidden - Whether a row paints nothing.
|
|
181
|
+
* @param options.receipts - The run receipts, by the id of the reply row they dock on.
|
|
182
|
+
*/
|
|
183
|
+
function computeRailModelParts(parts, { isHidden = () => false, receipts } = {}) {
|
|
184
|
+
const { settled, open } = parts;
|
|
185
|
+
let hit = settledRails.get(settled.clusters);
|
|
186
|
+
const settledReceipts = settled.receipts ?? receipts;
|
|
187
|
+
if (!hit || hit.isHidden !== isHidden || hit.receipts !== settledReceipts) {
|
|
188
|
+
const fold = railFold();
|
|
189
|
+
foldRail(fold, settled.clusters, isHidden, settledReceipts);
|
|
190
|
+
hit = {
|
|
191
|
+
isHidden,
|
|
192
|
+
receipts: settledReceipts,
|
|
193
|
+
fold
|
|
194
|
+
};
|
|
195
|
+
settledRails.set(settled.clusters, hit);
|
|
95
196
|
}
|
|
96
|
-
|
|
197
|
+
const fold = railFold(hit.fold);
|
|
198
|
+
foldRail(fold, open.clusters, isHidden, receipts);
|
|
199
|
+
closeRail(fold, receipts);
|
|
97
200
|
return {
|
|
98
|
-
exchanges,
|
|
99
|
-
exchangeOfTurn
|
|
201
|
+
exchanges: fold.exchanges,
|
|
202
|
+
exchangeOfTurn: fold.exchangeOfTurn
|
|
100
203
|
};
|
|
101
204
|
}
|
|
102
205
|
/**
|
|
206
|
+
* The rail with the session's whole outline: the outline's prompts before the first loaded one (their history is
|
|
207
|
+
* not loaded yet) as unloaded exchanges, then the loaded exchanges. The same array when there are none to add.
|
|
208
|
+
*
|
|
209
|
+
* @param model - The loaded exchanges.
|
|
210
|
+
* @param outline - The session's prompts, oldest first, or `null` when there is none (all loaded, or the host can't say).
|
|
211
|
+
*/
|
|
212
|
+
function railWithOutline(model, outline) {
|
|
213
|
+
if (!outline || outline.length === 0) return model.exchanges;
|
|
214
|
+
const unloaded = [];
|
|
215
|
+
for (const prompt of outline) {
|
|
216
|
+
if (model.exchangeOfTurn.has(prompt.turnId)) break;
|
|
217
|
+
unloaded.push({
|
|
218
|
+
id: `outline:${prompt.turnId}`,
|
|
219
|
+
prompt: prompt.text,
|
|
220
|
+
answer: null,
|
|
221
|
+
firstRowId: "",
|
|
222
|
+
lastRowId: "",
|
|
223
|
+
unloaded: {
|
|
224
|
+
turnId: prompt.turnId,
|
|
225
|
+
index: prompt.index
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
if (unloaded.length === outline.length && model.exchanges.length > 0) return model.exchanges;
|
|
230
|
+
return unloaded.length > 0 ? [...unloaded, ...model.exchanges] : model.exchanges;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
103
233
|
* Whether two exchange lists show the same rail: same exchanges, same text, same span and receipt.
|
|
104
234
|
*
|
|
105
235
|
* @param a - One list.
|
|
@@ -116,6 +246,11 @@ function sameRail(a, b) {
|
|
|
116
246
|
/** Whether two turn maps send every turn to the same exchange. */
|
|
117
247
|
function sameTurns(a, b) {
|
|
118
248
|
if (a === b) return true;
|
|
249
|
+
if (a instanceof LayeredTurns && b instanceof LayeredTurns && a.base === b.base) {
|
|
250
|
+
if (a.top.size !== b.top.size) return false;
|
|
251
|
+
for (const [turn, exchange] of a.top) if (b.top.get(turn) !== exchange) return false;
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
119
254
|
if (a.size !== b.size) return false;
|
|
120
255
|
for (const [turn, exchange] of a) if (b.get(turn) !== exchange) return false;
|
|
121
256
|
return true;
|
|
@@ -125,7 +260,9 @@ function createTranscriptRailStore() {
|
|
|
125
260
|
const state = writable({
|
|
126
261
|
...EMPTY_RAIL,
|
|
127
262
|
hovered: null,
|
|
128
|
-
selected: null
|
|
263
|
+
selected: null,
|
|
264
|
+
outline: null,
|
|
265
|
+
loadThrough: null
|
|
129
266
|
});
|
|
130
267
|
return {
|
|
131
268
|
get: state.get,
|
|
@@ -142,7 +279,12 @@ function createTranscriptRailStore() {
|
|
|
142
279
|
select: (id) => state.set((prev) => prev.selected === id ? prev : {
|
|
143
280
|
...prev,
|
|
144
281
|
selected: id
|
|
282
|
+
}),
|
|
283
|
+
publishOutline: (outline, loadThrough) => state.set((prev) => prev.outline === outline && prev.loadThrough === loadThrough ? prev : {
|
|
284
|
+
...prev,
|
|
285
|
+
outline,
|
|
286
|
+
loadThrough
|
|
145
287
|
})
|
|
146
288
|
};
|
|
147
289
|
}
|
|
148
|
-
export { EMPTY_RAIL, computeRailModel, createTranscriptRailStore, dataRowSelector, plainPreview, sameRail };
|
|
290
|
+
export { EMPTY_RAIL, computeRailModel, computeRailModelParts, createTranscriptRailStore, dataRowSelector, plainPreview, railWithOutline, sameRail };
|
|
@@ -231,8 +231,12 @@ export type Row = (Owned & {
|
|
|
231
231
|
ok: boolean | null;
|
|
232
232
|
/** Wire id of the call — the key for the lazy full-result fetch. */
|
|
233
233
|
callId?: string;
|
|
234
|
-
/** True when `result`
|
|
234
|
+
/** True when the host clipped `result` for the wire (`clipped.result`; expand offers a full fetch). */
|
|
235
235
|
resultClipped?: boolean;
|
|
236
|
+
/** Per media block of the result, the blob it is held as (`StreamEvent.mediaRefs`): its address by hash. */
|
|
237
|
+
mediaRefs?: readonly (string | null)[];
|
|
238
|
+
/** True when the host clipped `rawInput` for the wire (`clipped.input`; expand offers the whole input). */
|
|
239
|
+
inputClipped?: boolean;
|
|
236
240
|
/**
|
|
237
241
|
* Timing, from the host: `startedAt` while the call is unpaired (its
|
|
238
242
|
* `tool` event's), `durationMs` once its result landed (its
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRunStopMarker } from "zidane/chat/pure";
|
|
1
|
+
import { createRunStopMarker, noteTranscriptPass } from "zidane/chat/pure";
|
|
2
2
|
// src/chat/headless/transcript/run-failures.ts
|
|
3
3
|
/** A reset time: the clock time today, with the date on any other day. */
|
|
4
4
|
function formatResetTime(resetsAt) {
|
|
@@ -57,6 +57,7 @@ const markRows = createRunStopMarker({
|
|
|
57
57
|
* @param rows - The transcript rows, oldest first.
|
|
58
58
|
*/
|
|
59
59
|
function markRunFailures(rows) {
|
|
60
|
+
noteTranscriptPass("run-failures", rows.length);
|
|
60
61
|
return markRepaired(markRows(rows));
|
|
61
62
|
}
|
|
62
63
|
/** Each repaired error's copy, per row: a row that did not change keeps its identity (memoised rows stay put). */
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a transcript can be cut so that its parts derive rows on their own.
|
|
3
|
+
*
|
|
4
|
+
* Every pass of the row pipeline (`derive.ts`) stops at an exchange start (a
|
|
5
|
+
* top-level prompt and the separators before it), except where data ties two
|
|
6
|
+
* exchanges together:
|
|
7
|
+
*
|
|
8
|
+
* - ids: a result, a nested call, a script's progress or a queued spawn names
|
|
9
|
+
* a call of an earlier exchange (`callId`, `parentToolCallId`); a subagent
|
|
10
|
+
* or a turn spans exchanges (`childId`, `spawn.parentChildId`, `turnId`:
|
|
11
|
+
* clustering, ordinals); a call without an id pairs by turn and tool name.
|
|
12
|
+
* - environment setups: the last attempt is marked as such (all setups tie),
|
|
13
|
+
* and a running one at an exchange's end moves into the next exchange.
|
|
14
|
+
* - a broken-environment error is marked repaired by the next reply, which
|
|
15
|
+
* may be in a later exchange.
|
|
16
|
+
*
|
|
17
|
+
* Exchanges tied this way form one block, derived together. Ties are rare
|
|
18
|
+
* (a background subagent writing across a prompt, a setup), so a block is
|
|
19
|
+
* almost always one exchange.
|
|
20
|
+
*/
|
|
21
|
+
import { ChatEvent } from "../host.js";
|
|
22
|
+
/** What one exchange's events tie to. */
|
|
23
|
+
export interface ExchangeTies {
|
|
24
|
+
/** Ids it shares with any exchange holding the same id. */
|
|
25
|
+
keys: readonly string[];
|
|
26
|
+
/** It ends on a running (or waited-for) setup, which moves into the next exchange. */
|
|
27
|
+
heldEnd: boolean;
|
|
28
|
+
/** It holds a broken-environment error a later reply may mark repaired. */
|
|
29
|
+
envError: boolean;
|
|
30
|
+
/** It holds what shows the environment works (a reply, a custom row, a setup). */
|
|
31
|
+
works: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The ties of a settled exchange (computed once per chunk).
|
|
35
|
+
*
|
|
36
|
+
* @param chunk - The exchange's events, never changed.
|
|
37
|
+
*/
|
|
38
|
+
export declare function chunkTies(chunk: readonly ChatEvent[]): ExchangeTies;
|
|
39
|
+
/**
|
|
40
|
+
* The ties of the open exchange (computed each time: it changes every frame).
|
|
41
|
+
*
|
|
42
|
+
* @param tail - The open exchange's events.
|
|
43
|
+
*/
|
|
44
|
+
export declare function tailTies(tail: readonly ChatEvent[]): ExchangeTies;
|
|
45
|
+
/** A run of chunks derived together: `[start, end)`. */
|
|
46
|
+
export interface Block {
|
|
47
|
+
start: number;
|
|
48
|
+
end: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The blocks of a list of exchanges, grown one exchange at a time. Reused
|
|
52
|
+
* while the list only grows (a commit appends one exchange); any other change
|
|
53
|
+
* plans again from the start.
|
|
54
|
+
*/
|
|
55
|
+
export declare class BlockPlan {
|
|
56
|
+
/** The exchanges planned so far. */
|
|
57
|
+
chunks: ReadonlyArray<readonly ChatEvent[]>;
|
|
58
|
+
/** The blocks, oldest first, covering every planned exchange. */
|
|
59
|
+
blocks: Block[];
|
|
60
|
+
private firstSeen;
|
|
61
|
+
private openRepair;
|
|
62
|
+
private lastHeld;
|
|
63
|
+
/**
|
|
64
|
+
* Brings the plan to `chunks`.
|
|
65
|
+
*
|
|
66
|
+
* @param chunks - The settled exchanges, oldest first.
|
|
67
|
+
*/
|
|
68
|
+
update(chunks: ReadonlyArray<readonly ChatEvent[]>): void;
|
|
69
|
+
/**
|
|
70
|
+
* The index of the first block an exchange with `ties`, appended after the planned ones, must join (`blocks.length` for none).
|
|
71
|
+
*
|
|
72
|
+
* @param ties - The appended exchange's ties.
|
|
73
|
+
*/
|
|
74
|
+
joinFrom(ties: ExchangeTies): number;
|
|
75
|
+
private add;
|
|
76
|
+
/** The earliest exchange the one at `index` ties to (`index` for none); `record` files its ids. */
|
|
77
|
+
private reach;
|
|
78
|
+
}
|