zidane-ui 9.2.2 → 9.3.1
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/browser-keybindings-host.js +3 -1
- package/dist/adapters/live.d.ts +6 -0
- package/dist/adapters/live.js +16 -8
- package/dist/adapters/server-composer-host.js +22 -9
- package/dist/adapters/server-host.js +143 -18
- package/dist/adapters/server-media.d.ts +9 -1
- package/dist/adapters/server-media.js +14 -1
- package/dist/adapters/server-settings-host.js +30 -3
- package/dist/adapters/server-settings-sections.js +23 -1
- package/dist/adapters/server-sidebar-host.d.ts +3 -1
- package/dist/adapters/server-sidebar-host.js +10 -1
- package/dist/app/ModalProvider.js +1 -1
- package/dist/approvals/ApprovalShell.js +1 -1
- package/dist/chat/DaemonOrb.d.ts +29 -1
- package/dist/chat/DaemonOrb.js +25 -12
- package/dist/chat/HostTranscript.d.ts +0 -12
- package/dist/chat/HostTranscript.js +6 -1
- package/dist/chat/SessionStreamsProvider.d.ts +8 -0
- package/dist/chat/SessionStreamsProvider.js +11 -2
- package/dist/chat/StatusDot.js +8 -2
- package/dist/chat/Transcript.d.ts +20 -11
- package/dist/chat/Transcript.js +335 -162
- package/dist/chat/composer/ComposerEditor.js +1 -1
- package/dist/chat/headless/host.d.ts +43 -7
- package/dist/chat/headless/index.d.ts +8 -6
- package/dist/chat/headless/index.js +11 -9
- package/dist/chat/headless/labels.d.ts +30 -0
- package/dist/chat/headless/labels.js +29 -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 +66 -0
- package/dist/chat/headless/markdown-scan.js +124 -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/session-list.d.ts +20 -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 +17 -2
- package/dist/chat/headless/sidebar/directory.js +50 -54
- package/dist/chat/headless/sidebar/environment.d.ts +5 -2
- package/dist/chat/headless/sidebar/environment.js +11 -2
- package/dist/chat/headless/sidebar/host.d.ts +15 -0
- package/dist/chat/headless/sidebar/inbox.d.ts +12 -3
- package/dist/chat/headless/sidebar/inbox.js +18 -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 +38 -2
- package/dist/chat/headless/sidebar/labels.js +16 -0
- 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 +2 -0
- package/dist/chat/headless/streams/actions.js +1 -0
- package/dist/chat/headless/streams/event-bytes.d.ts +6 -0
- package/dist/chat/headless/streams/event-bytes.js +34 -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 +24 -1
- package/dist/chat/headless/streams/store.js +51 -26
- package/dist/chat/headless/streams/transcript-map.d.ts +57 -0
- package/dist/chat/headless/streams/transcript-map.js +88 -0
- package/dist/chat/headless/streams/transcript.d.ts +4 -2
- package/dist/chat/headless/streams/transcript.js +19 -7
- 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 +32 -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-actions.d.ts +8 -3
- package/dist/chat/headless/transcript/fold-actions.js +16 -0
- 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 +4 -2
- package/dist/chat/headless/transcript/fold.js +37 -7
- 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 -1
- package/dist/chat/headless/transcript/index.js +2 -1
- package/dist/chat/headless/transcript/nesting.js +2 -1
- package/dist/chat/headless/transcript/rail.d.ts +142 -0
- package/dist/chat/headless/transcript/rail.js +290 -0
- package/dist/chat/headless/transcript/rows.d.ts +11 -1
- package/dist/chat/headless/transcript/run-failures.d.ts +4 -0
- package/dist/chat/headless/transcript/run-failures.js +31 -2
- 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/headless/transcript-labels.d.ts +1 -0
- package/dist/chat/headless/turn-labels.d.ts +1 -0
- package/dist/chat/headless/turn-labels.js +2 -1
- package/dist/chat/index.d.ts +10 -8
- package/dist/chat/index.js +9 -7
- package/dist/chat/interactions/ElicitationCard.js +1 -1
- package/dist/chat/interactions/InteractionCard.js +1 -1
- package/dist/chat/interactions/PlanCard.js +3 -3
- package/dist/chat/interactions/QuestionField.js +4 -4
- package/dist/chat/interactions/QuestionForm.js +3 -3
- package/dist/chat/interactions/SecretInput.js +1 -1
- package/dist/chat/sidebar/ProjectIcon.d.ts +1 -1
- package/dist/chat/sidebar/ProjectIcon.js +1 -1
- package/dist/chat/sidebar/RowChips.d.ts +3 -2
- package/dist/chat/sidebar/RowChips.js +6 -3
- package/dist/chat/sidebar/SessionSidebar.js +13 -14
- package/dist/chat/sidebar/SidebarFooter.d.ts +8 -5
- package/dist/chat/sidebar/SidebarFooter.js +6 -6
- package/dist/chat/sidebar/SidebarFrame.d.ts +2 -0
- package/dist/chat/sidebar/SidebarFrame.js +5 -2
- package/dist/chat/sidebar/SidebarSessionRow.d.ts +3 -1
- package/dist/chat/sidebar/SidebarSessionRow.js +3 -1
- package/dist/chat/sidebar/SpacesSection.d.ts +20 -1
- package/dist/chat/sidebar/SpacesSection.js +34 -13
- package/dist/chat/sidebar/index.d.ts +2 -2
- package/dist/chat/sidebar/session-menu.d.ts +11 -2
- package/dist/chat/sidebar/session-menu.js +50 -5
- package/dist/chat/sidebar/sidebar-live.js +1 -1
- package/dist/chat/sidebar/useInboxRows.js +43 -2
- package/dist/chat/sidebar/useInboxTriage.js +19 -14
- package/dist/chat/testing/contract.d.ts +5 -3
- package/dist/chat/testing/contract.js +66 -1
- package/dist/chat/testing/fixture-sidebar-host.d.ts +7 -1
- package/dist/chat/testing/fixture-sidebar-host.js +12 -0
- package/dist/chat/testing/sidebar.contract.d.ts +6 -0
- package/dist/chat/testing/sidebar.contract.js +24 -0
- 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/InteractionToolBody.js +1 -1
- package/dist/chat/transcript/LazyRow.d.ts +40 -40
- package/dist/chat/transcript/LazyRow.js +101 -149
- package/dist/chat/transcript/MermaidDiagram.js +2 -1
- package/dist/chat/transcript/SelectCursor.d.ts +11 -1
- package/dist/chat/transcript/SelectCursor.js +10 -5
- package/dist/chat/transcript/SubagentBlock.js +3 -2
- package/dist/chat/transcript/TranscriptRail.d.ts +109 -0
- package/dist/chat/transcript/TranscriptRail.js +579 -0
- package/dist/chat/transcript/TranscriptRow.d.ts +4 -7
- package/dist/chat/transcript/TranscriptRow.js +9 -5
- package/dist/chat/transcript/actions.d.ts +43 -3
- package/dist/chat/transcript/actions.js +27 -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 +3 -2
- package/dist/chat/transcript/fold.js +21 -2
- package/dist/chat/transcript/index.d.ts +11 -9
- package/dist/chat/transcript/index.js +10 -8
- package/dist/chat/transcript/markdown-cache.d.ts +7 -1
- package/dist/chat/transcript/markdown-cache.js +12 -1
- package/dist/chat/transcript/markdown.js +116 -54
- package/dist/chat/transcript/media-gallery.d.ts +3 -2
- package/dist/chat/transcript/media-gallery.js +10 -7
- package/dist/chat/transcript/notices.d.ts +23 -1
- package/dist/chat/transcript/notices.js +110 -28
- package/dist/chat/transcript/prompt.js +6 -4
- package/dist/chat/transcript/prose.js +3 -1
- package/dist/chat/transcript/receipt-parts.d.ts +22 -0
- package/dist/chat/transcript/receipt-parts.js +87 -0
- 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 +165 -0
- package/dist/chat/transcript/row-mount.js +498 -0
- package/dist/chat/transcript/row-parking.d.ts +125 -0
- package/dist/chat/transcript/row-parking.js +135 -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 +6 -78
- package/dist/chat/transcript/script-input.d.ts +1 -1
- package/dist/chat/transcript/scroll-clamp.js +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 -5
- 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 +24 -7
- package/dist/chat/transcript/use-transcript-rows.js +28 -46
- package/dist/chat/transcript/useSettledReveal.js +15 -3
- package/dist/chat/transcript/useStickToBottom.js +4 -4
- package/dist/chat/transcript/useTranscriptSearch.js +30 -14
- package/dist/chat/transcript/view-scope.d.ts +26 -6
- package/dist/chat/transcript/view-scope.js +106 -20
- package/dist/components/ChoiceCards.js +1 -1
- package/dist/components/ConfirmDialog.js +1 -1
- package/dist/components/CopyValue.d.ts +33 -0
- package/dist/components/CopyValue.js +54 -0
- package/dist/components/Form.js +1 -1
- package/dist/components/HowItWorks.js +1 -1
- package/dist/components/Menu.js +1 -1
- package/dist/components/StepFrame.js +2 -2
- package/dist/components/SwatchPicker.js +1 -1
- package/dist/components/ToggleCard.js +1 -1
- package/dist/components/floating/HoverCard.js +2 -3
- package/dist/components/floating/hover-delay.d.ts +4 -0
- package/dist/components/floating/hover-delay.js +6 -0
- package/dist/core.css +14 -12
- package/dist/dist/{index-Betz0OWq.d.ts → index-C6-t1SS9.d.ts} +21 -2
- package/dist/dist/index-De9AbmxS.d.ts +1 -0
- package/dist/dist/index.d.ts +5 -5
- package/dist/dist/sandbox-CSUihARm.d.ts +2 -0
- package/dist/dist/{timeout-CyU7HLyz.d.ts → timeout-CmTx6V9y.d.ts} +1 -0
- package/dist/extensions/ExtensionDialogHost.js +1 -1
- package/dist/files/TreeColumn.js +3 -1
- package/dist/files/headless/host.d.ts +2 -2
- package/dist/git/ImportRepoDialog.js +1 -1
- package/dist/git/MoveSessionDialog.js +2 -2
- package/dist/git/SandboxManager.d.ts +42 -0
- package/dist/git/SandboxManager.js +297 -0
- package/dist/git/SyncChip.js +1 -1
- package/dist/git/headless/index.d.ts +2 -1
- package/dist/git/headless/index.js +2 -1
- package/dist/git/headless/labels.d.ts +29 -0
- package/dist/git/headless/labels.js +34 -1
- package/dist/git/headless/sandboxes.d.ts +43 -0
- package/dist/git/headless/sandboxes.js +52 -0
- package/dist/git/index.d.ts +2 -1
- package/dist/git/index.js +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/keybindings/headless/catalog.d.ts +1 -1
- package/dist/keybindings/headless/catalog.js +12 -0
- package/dist/machines/HostsSection.d.ts +1 -1
- package/dist/machines/headless/labels.js +2 -2
- package/dist/motion/flip-list.js +3 -10
- package/dist/motion/presence.d.ts +10 -0
- package/dist/motion/presence.js +20 -1
- package/dist/motion/swap.d.ts +8 -2
- package/dist/motion/swap.js +5 -2
- package/dist/onboarding/conversation.js +27 -15
- package/dist/onboarding/demos/how-it-works.js +1 -1
- package/dist/onboarding/skills/parts.js +4 -4
- package/dist/onboarding/sources/SourceBrowser.js +1 -1
- package/dist/onboarding/steps/ReadyStep.js +1 -1
- package/dist/onboarding/steps/connect/KeyForm.js +1 -1
- package/dist/palette/headless/app-sources.js +20 -0
- package/dist/palette/headless/labels.js +2 -0
- package/dist/session/PlanTracker.js +3 -3
- package/dist/session/SecretsPanel.js +1 -1
- package/dist/session/SessionHeader.d.ts +18 -6
- package/dist/session/SessionHeader.js +68 -12
- package/dist/session/SessionPlaceMenu.d.ts +35 -0
- package/dist/session/SessionPlaceMenu.js +299 -0
- package/dist/session/SessionShell.js +1 -1
- package/dist/session/TurnDetailsDialog.js +1 -1
- package/dist/session/headless/index.d.ts +2 -1
- package/dist/session/headless/index.js +2 -1
- package/dist/session/headless/labels.d.ts +73 -0
- package/dist/session/headless/labels.js +73 -0
- package/dist/session/headless/place.d.ts +49 -0
- package/dist/session/headless/place.js +57 -0
- package/dist/session/index.d.ts +2 -1
- package/dist/session/index.js +2 -1
- package/dist/settings/ConversationPresetsCard.js +1 -1
- package/dist/settings/SettingCard.js +2 -2
- package/dist/settings/SettingsRowsPage.js +1 -1
- package/dist/settings/headless/fixture-performance.js +4 -2
- package/dist/settings/headless/fixture-sections.js +7 -0
- package/dist/settings/headless/labels.d.ts +1 -1
- package/dist/settings/headless/labels.js +1 -1
- package/dist/settings/headless/layout.d.ts +4 -4
- package/dist/settings/headless/layout.js +1 -1
- package/dist/settings/headless/performance.d.ts +4 -0
- package/dist/settings/headless/search.d.ts +2 -2
- package/dist/settings/headless/sections-host.d.ts +20 -2
- package/dist/settings/sections/claude-import/ClaudeImportDialog.js +1 -1
- package/dist/settings/sections/enabled-list/EnabledListSection.js +2 -2
- package/dist/settings/sections/environments/EnvironmentsSection.d.ts +9 -3
- package/dist/settings/sections/environments/EnvironmentsSection.js +292 -52
- package/dist/settings/sections/environments/labels.d.ts +15 -0
- package/dist/settings/sections/environments/labels.js +18 -3
- package/dist/settings/sections/extensions/ChangeOriginDialog.js +1 -1
- package/dist/settings/sections/extensions/ExtensionSourceBrowser.js +1 -1
- package/dist/settings/sections/extensions/ExtensionsSection.d.ts +3 -2
- package/dist/settings/sections/extensions/ExtensionsSection.js +9 -3
- package/dist/settings/sections/host-catalog/HostCatalogSection.js +15 -5
- package/dist/settings/sections/keybindings/labels.d.ts +2 -0
- package/dist/settings/sections/keybindings/labels.js +2 -0
- package/dist/settings/sections/keybindings/rows.js +8 -0
- package/dist/settings/sections/models/SpacesDefaultsSection.d.ts +7 -3
- package/dist/settings/sections/models/SpacesDefaultsSection.js +11 -5
- 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/settings/sections/skills/SkillGroups.js +1 -1
- package/dist/settings/server-app.d.ts +4 -2
- package/dist/settings/server-app.js +7 -3
- package/dist/settings/testing/sections.contract.d.ts +7 -1
- package/dist/settings/testing/sections.contract.js +37 -0
- package/dist/styles.css +243 -19
- package/dist/terminal/TerminalDrawer.js +3 -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/SidePanel.js +3 -1
- package/package.json +2 -2
- package/src/styles/base.css +13 -0
- package/src/styles/chat.css +30 -0
- package/src/styles/components.css +0 -10
- package/src/styles/files.css +5 -0
- package/src/styles/sidebar.css +29 -7
- package/src/styles/terminal.css +6 -0
- package/src/styles/tokens.css +5 -0
- package/src/styles/transcript.css +138 -0
- package/src/styles/workspace.css +6 -0
- package/dist/dist/index-QcFzZlao.d.ts +0 -1
- package/dist/dist/sandbox-D0zsW8I1.d.ts +0 -2
- /package/dist/dist/{types-_Dtoq_No.d.ts → execution-failure-SREfl-EZ.d.ts} +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { inheritRowIdentity } from "../transcript/collapse.js";
|
|
2
|
-
import {
|
|
2
|
+
import { applyLiveEventToTranscript, endTurnInTranscript, finishLiveTranscript } from "./live-events.js";
|
|
3
3
|
import { mergeLiveTail } from "./merge.js";
|
|
4
4
|
import { mergePromptPreviews, missingPreviewData } from "./prompt-previews.js";
|
|
5
5
|
import { defaultFrameScheduler } from "./scheduler.js";
|
|
6
|
-
import {
|
|
6
|
+
import { TranscriptMap } from "./transcript-map.js";
|
|
7
|
+
import { appendTranscriptEvent, applyHistoryOp, applyHistorySince, dedupeEnvironmentSetups, readFreshness, reconcileEvents, transcriptDiscardThinking } from "zidane/chat/pure";
|
|
7
8
|
// src/chat/headless/streams/store.ts
|
|
8
9
|
const PARENT_OWNER = "parent";
|
|
9
10
|
/** Numberings a window remembers leaving (`_retiredHistoryIds`). */
|
|
@@ -72,7 +73,8 @@ const NOTIFY_FALLBACK_MS = 50;
|
|
|
72
73
|
* @typeParam K - The session key type (the desktop app's branded `SessionKey`). Default: `string`.
|
|
73
74
|
*/
|
|
74
75
|
var SessionStreamStore = class {
|
|
75
|
-
|
|
76
|
+
/** Each session's events as a transcript store: a streamed delta copies only the open exchange (`TranscriptMap`). */
|
|
77
|
+
_events = new TranscriptMap();
|
|
76
78
|
_running = /* @__PURE__ */ new Map();
|
|
77
79
|
_scheduler;
|
|
78
80
|
_markdown;
|
|
@@ -187,6 +189,16 @@ var SessionStreamStore = class {
|
|
|
187
189
|
return this._events.get(sessionId) ?? EMPTY_EVENTS;
|
|
188
190
|
}
|
|
189
191
|
/**
|
|
192
|
+
* A session's events as a transcript store (settled exchanges and the open
|
|
193
|
+
* one), for a consumer that derives per exchange. `getEventsSnapshot` is
|
|
194
|
+
* its array (`transcriptOfArray` maps one to the other).
|
|
195
|
+
*
|
|
196
|
+
* @param sessionId - The session.
|
|
197
|
+
*/
|
|
198
|
+
getTranscriptSnapshot(sessionId) {
|
|
199
|
+
return this._events.transcript(sessionId);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
190
202
|
* Whether a run is in flight for the session.
|
|
191
203
|
*
|
|
192
204
|
* @param sessionId - The session, or `null` for none.
|
|
@@ -282,6 +294,14 @@ var SessionStreamStore = class {
|
|
|
282
294
|
return this._events.has(sessionId);
|
|
283
295
|
}
|
|
284
296
|
/**
|
|
297
|
+
* About how many bytes the session's rows hold (`eventsBytes`): what the prewarm window budgets by.
|
|
298
|
+
*
|
|
299
|
+
* @param sessionId - The session.
|
|
300
|
+
*/
|
|
301
|
+
eventBytes(sessionId) {
|
|
302
|
+
return this._events.bytes(sessionId);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
285
305
|
* Whether the session's window was hydrated from DISK (`setEventsPage`),
|
|
286
306
|
* as opposed to merely having a record. `markRunning` and every live
|
|
287
307
|
* signal seed `_events` for a session this window never loaded — a run
|
|
@@ -297,6 +317,14 @@ var SessionStreamStore = class {
|
|
|
297
317
|
return this._pages.has(sessionId);
|
|
298
318
|
}
|
|
299
319
|
/**
|
|
320
|
+
* The sessions whose window was hydrated from disk (see `isHydrated`). An
|
|
321
|
+
* app keeps their live signals coming (`sessions.subscribe`): a window
|
|
322
|
+
* that stops getting them goes stale. `subscribeHas` fires when this changes.
|
|
323
|
+
*/
|
|
324
|
+
hydratedSessions() {
|
|
325
|
+
return [...this._pages.keys()];
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
300
328
|
* The session's scrollback bookkeeping (a shared empty state when it was never hydrated). Stable identity until a page write.
|
|
301
329
|
*
|
|
302
330
|
* @param sessionId - The session, or `null` for none.
|
|
@@ -737,7 +765,6 @@ var SessionStreamStore = class {
|
|
|
737
765
|
*/
|
|
738
766
|
appendUserPrompt(sessionId, text, refs, rawAttachments, clientMessageId) {
|
|
739
767
|
const had = this._events.has(sessionId);
|
|
740
|
-
const events = this._events.get(sessionId)?.slice() ?? [];
|
|
741
768
|
const attachments = rawAttachments === void 0 || missingPreviewData(rawAttachments) ? mergePromptPreviews(rawAttachments, this.takePromptPreviews(sessionId, text)) : rawAttachments;
|
|
742
769
|
const event = {
|
|
743
770
|
kind: "user-prompt",
|
|
@@ -745,7 +772,6 @@ var SessionStreamStore = class {
|
|
|
745
772
|
...refs && refs.length > 0 ? { refs: [...refs] } : {},
|
|
746
773
|
...attachments && attachments.length > 0 ? { attachments: [...attachments] } : {}
|
|
747
774
|
};
|
|
748
|
-
events.push(event);
|
|
749
775
|
const pending = this._pendingEcho.get(sessionId) ?? [];
|
|
750
776
|
pending.push({
|
|
751
777
|
text,
|
|
@@ -753,7 +779,7 @@ var SessionStreamStore = class {
|
|
|
753
779
|
event
|
|
754
780
|
});
|
|
755
781
|
this._pendingEcho.set(sessionId, pending);
|
|
756
|
-
this._events.
|
|
782
|
+
this._events.setTranscript(sessionId, appendTranscriptEvent(this._events.transcriptOrEmpty(sessionId), event));
|
|
757
783
|
this._notifySession(sessionId);
|
|
758
784
|
if (!had) this._notifyHas();
|
|
759
785
|
}
|
|
@@ -797,7 +823,8 @@ var SessionStreamStore = class {
|
|
|
797
823
|
write(sessionId, patch) {
|
|
798
824
|
const had = this._events.has(sessionId);
|
|
799
825
|
const wasHydrated = this._pages.has(sessionId);
|
|
800
|
-
if (patch.
|
|
826
|
+
if (patch.transcript !== void 0) this._events.setTranscript(sessionId, patch.transcript);
|
|
827
|
+
else if (patch.events !== void 0) this._events.set(sessionId, patch.events);
|
|
801
828
|
else if (!had) this._events.set(sessionId, []);
|
|
802
829
|
if (patch.running !== void 0) this._running.set(sessionId, patch.running);
|
|
803
830
|
if (patch.page === null) this._pages.delete(sessionId);
|
|
@@ -813,12 +840,10 @@ var SessionStreamStore = class {
|
|
|
813
840
|
*/
|
|
814
841
|
appendErrorEvent(sessionId, text) {
|
|
815
842
|
const had = this._events.has(sessionId);
|
|
816
|
-
|
|
817
|
-
events.push({
|
|
843
|
+
this._events.setTranscript(sessionId, appendTranscriptEvent(this._events.transcriptOrEmpty(sessionId), {
|
|
818
844
|
kind: "error",
|
|
819
845
|
text
|
|
820
|
-
});
|
|
821
|
-
this._events.set(sessionId, events);
|
|
846
|
+
}));
|
|
822
847
|
this._notifySession(sessionId);
|
|
823
848
|
if (!had) this._notifyHas();
|
|
824
849
|
}
|
|
@@ -845,16 +870,16 @@ var SessionStreamStore = class {
|
|
|
845
870
|
return;
|
|
846
871
|
case "run:end": {
|
|
847
872
|
this.runStateVersion++;
|
|
848
|
-
const prior = this._events.
|
|
849
|
-
let next =
|
|
850
|
-
if (!signal.ok && signal.error) next =
|
|
873
|
+
const prior = this._events.transcriptOrEmpty(signal.sessionId);
|
|
874
|
+
let next = finishLiveTranscript(prior);
|
|
875
|
+
if (!signal.ok && signal.error) next = appendTranscriptEvent(next, {
|
|
851
876
|
kind: "error",
|
|
852
877
|
text: signal.error,
|
|
853
878
|
...signal.detail ? { detail: signal.detail } : {}
|
|
854
|
-
}
|
|
879
|
+
});
|
|
855
880
|
const had = this._events.has(signal.sessionId);
|
|
856
881
|
const wasRunning = this._running.get(signal.sessionId) === true;
|
|
857
|
-
this._events.
|
|
882
|
+
this._events.setTranscript(signal.sessionId, next);
|
|
858
883
|
this._running.set(signal.sessionId, false);
|
|
859
884
|
const sawStart = this._runStarted.delete(signal.sessionId);
|
|
860
885
|
const streamed = this._runActivity.delete(signal.sessionId);
|
|
@@ -866,10 +891,10 @@ var SessionStreamStore = class {
|
|
|
866
891
|
return;
|
|
867
892
|
}
|
|
868
893
|
case "turn:end": {
|
|
869
|
-
const prior = this._events.
|
|
894
|
+
const prior = this._events.transcriptOrEmpty(signal.sessionId);
|
|
870
895
|
const owner = signal.childId ?? PARENT_OWNER;
|
|
871
896
|
const had = this._events.has(signal.sessionId);
|
|
872
|
-
this._events.
|
|
897
|
+
this._events.setTranscript(signal.sessionId, endTurnInTranscript(prior, owner));
|
|
873
898
|
this._notifySession(signal.sessionId);
|
|
874
899
|
if (!had) this._notifyHas();
|
|
875
900
|
return;
|
|
@@ -898,8 +923,8 @@ var SessionStreamStore = class {
|
|
|
898
923
|
};
|
|
899
924
|
}
|
|
900
925
|
const had = this._events.has(signal.sessionId);
|
|
901
|
-
const prior = this._events.
|
|
902
|
-
this._events.
|
|
926
|
+
const prior = this._events.transcriptOrEmpty(signal.sessionId);
|
|
927
|
+
this._events.setTranscript(signal.sessionId, this._append(prior, event));
|
|
903
928
|
this._runActivity.add(signal.sessionId);
|
|
904
929
|
if (this._batch) this._notifySoon(signal.sessionId);
|
|
905
930
|
else this._notifySession(signal.sessionId);
|
|
@@ -942,7 +967,7 @@ var SessionStreamStore = class {
|
|
|
942
967
|
if (plan.length === 0) return;
|
|
943
968
|
const touched = /* @__PURE__ */ new Set();
|
|
944
969
|
for (const entry of plan) {
|
|
945
|
-
const prior = this._events.
|
|
970
|
+
const prior = this._events.transcriptOrEmpty(entry.sessionId);
|
|
946
971
|
const synthetic = {
|
|
947
972
|
kind: "markdown",
|
|
948
973
|
text: entry.text,
|
|
@@ -951,7 +976,7 @@ var SessionStreamStore = class {
|
|
|
951
976
|
...entry.depth != null ? { depth: entry.depth } : {},
|
|
952
977
|
...entry.turnId ? { turnId: entry.turnId } : {}
|
|
953
978
|
};
|
|
954
|
-
this._events.
|
|
979
|
+
this._events.setTranscript(entry.sessionId, this._append(prior, synthetic));
|
|
955
980
|
touched.add(entry.sessionId);
|
|
956
981
|
}
|
|
957
982
|
for (const sessionId of touched) this._notifySession(sessionId);
|
|
@@ -1065,10 +1090,10 @@ var SessionStreamStore = class {
|
|
|
1065
1090
|
}
|
|
1066
1091
|
/** Drop a stalled attempt's reasoning lane: the retry (or next model) streams its own, and the saved turn never holds it. */
|
|
1067
1092
|
_discardThinking(sessionId, source, turnId) {
|
|
1068
|
-
const events = this._events.
|
|
1093
|
+
const events = this._events.transcript(sessionId);
|
|
1069
1094
|
if (!events) return;
|
|
1070
|
-
const next =
|
|
1071
|
-
if (next !== events) this._events.
|
|
1095
|
+
const next = transcriptDiscardThinking(events, source, turnId);
|
|
1096
|
+
if (next !== events) this._events.setTranscript(sessionId, next);
|
|
1072
1097
|
}
|
|
1073
1098
|
/**
|
|
1074
1099
|
* Append a fresh event with the kit's live rule (`applyLiveEvent`, the
|
|
@@ -1080,7 +1105,7 @@ var SessionStreamStore = class {
|
|
|
1080
1105
|
* timing of its own).
|
|
1081
1106
|
*/
|
|
1082
1107
|
_append(events, event) {
|
|
1083
|
-
return
|
|
1108
|
+
return applyLiveEventToTranscript(events, event, Date.now(), this._markdown);
|
|
1084
1109
|
}
|
|
1085
1110
|
_notifySession(sessionId) {
|
|
1086
1111
|
this._pendingNotify.delete(sessionId);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ChatEvent } from "../host.js";
|
|
2
|
+
import { TranscriptEvents } from "zidane/chat/pure";
|
|
3
|
+
/**
|
|
4
|
+
* The session stream store's events: one transcript store per session
|
|
5
|
+
* (`TranscriptEvents`, settled exchanges and the open one). Reads as a map of
|
|
6
|
+
* arrays (`get`, `set`) for the store's rare whole-window writes, and as
|
|
7
|
+
* transcripts (`transcript`, `setTranscript`) for the streaming hot path,
|
|
8
|
+
* where a delta copies only the open exchange. An array read is made once per
|
|
9
|
+
* write, and `set` of an array keeps it as given (`get` returns it).
|
|
10
|
+
*/
|
|
11
|
+
export declare class TranscriptMap<K> {
|
|
12
|
+
private readonly map;
|
|
13
|
+
/** Sessions held. */
|
|
14
|
+
get size(): number;
|
|
15
|
+
/**
|
|
16
|
+
* The session's events as one array (the same array until the next write).
|
|
17
|
+
*
|
|
18
|
+
* @param sessionId - The session.
|
|
19
|
+
*/
|
|
20
|
+
get(sessionId: K): ChatEvent[] | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Sets the session's events; the exchanges they keep unchanged keep their chunks.
|
|
23
|
+
*
|
|
24
|
+
* @param sessionId - The session.
|
|
25
|
+
* @param events - The events. Never changed afterwards.
|
|
26
|
+
*/
|
|
27
|
+
set(sessionId: K, events: readonly ChatEvent[]): this;
|
|
28
|
+
/**
|
|
29
|
+
* The session's transcript store, if held.
|
|
30
|
+
*
|
|
31
|
+
* @param sessionId - The session.
|
|
32
|
+
*/
|
|
33
|
+
transcript(sessionId: K): TranscriptEvents<ChatEvent> | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* The session's transcript store, or an empty one.
|
|
36
|
+
*
|
|
37
|
+
* @param sessionId - The session.
|
|
38
|
+
*/
|
|
39
|
+
transcriptOrEmpty(sessionId: K): TranscriptEvents<ChatEvent>;
|
|
40
|
+
/**
|
|
41
|
+
* Sets the session's transcript store.
|
|
42
|
+
*
|
|
43
|
+
* @param sessionId - The session.
|
|
44
|
+
* @param transcript - The transcript.
|
|
45
|
+
*/
|
|
46
|
+
setTranscript(sessionId: K, transcript: TranscriptEvents<ChatEvent>): this;
|
|
47
|
+
/**
|
|
48
|
+
* About how many bytes the session's rows hold: each settled exchange is measured once.
|
|
49
|
+
*
|
|
50
|
+
* @param sessionId - The session.
|
|
51
|
+
*/
|
|
52
|
+
bytes(sessionId: K): number;
|
|
53
|
+
has(sessionId: K): boolean;
|
|
54
|
+
delete(sessionId: K): boolean;
|
|
55
|
+
clear(): void;
|
|
56
|
+
keys(): IterableIterator<K>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { eventsBytes } from "./event-bytes.js";
|
|
2
|
+
import { emptyTranscript, transcriptArray, transcriptFromArray } from "zidane/chat/pure";
|
|
3
|
+
// src/chat/headless/streams/transcript-map.ts
|
|
4
|
+
/**
|
|
5
|
+
* The session stream store's events: one transcript store per session
|
|
6
|
+
* (`TranscriptEvents`, settled exchanges and the open one). Reads as a map of
|
|
7
|
+
* arrays (`get`, `set`) for the store's rare whole-window writes, and as
|
|
8
|
+
* transcripts (`transcript`, `setTranscript`) for the streaming hot path,
|
|
9
|
+
* where a delta copies only the open exchange. An array read is made once per
|
|
10
|
+
* write, and `set` of an array keeps it as given (`get` returns it).
|
|
11
|
+
*/
|
|
12
|
+
var TranscriptMap = class {
|
|
13
|
+
map = /* @__PURE__ */ new Map();
|
|
14
|
+
/** Sessions held. */
|
|
15
|
+
get size() {
|
|
16
|
+
return this.map.size;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The session's events as one array (the same array until the next write).
|
|
20
|
+
*
|
|
21
|
+
* @param sessionId - The session.
|
|
22
|
+
*/
|
|
23
|
+
get(sessionId) {
|
|
24
|
+
const transcript = this.map.get(sessionId);
|
|
25
|
+
return transcript ? transcriptArray(transcript) : void 0;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Sets the session's events; the exchanges they keep unchanged keep their chunks.
|
|
29
|
+
*
|
|
30
|
+
* @param sessionId - The session.
|
|
31
|
+
* @param events - The events. Never changed afterwards.
|
|
32
|
+
*/
|
|
33
|
+
set(sessionId, events) {
|
|
34
|
+
this.map.set(sessionId, transcriptFromArray(events, this.map.get(sessionId)));
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The session's transcript store, if held.
|
|
39
|
+
*
|
|
40
|
+
* @param sessionId - The session.
|
|
41
|
+
*/
|
|
42
|
+
transcript(sessionId) {
|
|
43
|
+
return this.map.get(sessionId);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The session's transcript store, or an empty one.
|
|
47
|
+
*
|
|
48
|
+
* @param sessionId - The session.
|
|
49
|
+
*/
|
|
50
|
+
transcriptOrEmpty(sessionId) {
|
|
51
|
+
return this.map.get(sessionId) ?? emptyTranscript();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Sets the session's transcript store.
|
|
55
|
+
*
|
|
56
|
+
* @param sessionId - The session.
|
|
57
|
+
* @param transcript - The transcript.
|
|
58
|
+
*/
|
|
59
|
+
setTranscript(sessionId, transcript) {
|
|
60
|
+
this.map.set(sessionId, transcript);
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* About how many bytes the session's rows hold: each settled exchange is measured once.
|
|
65
|
+
*
|
|
66
|
+
* @param sessionId - The session.
|
|
67
|
+
*/
|
|
68
|
+
bytes(sessionId) {
|
|
69
|
+
const transcript = this.map.get(sessionId);
|
|
70
|
+
if (!transcript) return 0;
|
|
71
|
+
let bytes = eventsBytes(transcript.tail);
|
|
72
|
+
for (const chunk of transcript.chunks) bytes += eventsBytes(chunk);
|
|
73
|
+
return bytes;
|
|
74
|
+
}
|
|
75
|
+
has(sessionId) {
|
|
76
|
+
return this.map.has(sessionId);
|
|
77
|
+
}
|
|
78
|
+
delete(sessionId) {
|
|
79
|
+
return this.map.delete(sessionId);
|
|
80
|
+
}
|
|
81
|
+
clear() {
|
|
82
|
+
this.map.clear();
|
|
83
|
+
}
|
|
84
|
+
keys() {
|
|
85
|
+
return this.map.keys();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
export { TranscriptMap };
|
|
@@ -2,8 +2,10 @@ import { Transcript, TranscriptState } from "../host.js";
|
|
|
2
2
|
import { SessionStreamStore } from "./store.js";
|
|
3
3
|
/**
|
|
4
4
|
* A session's {@link TranscriptState} read off the store, reusing `prev` while
|
|
5
|
-
* none of its parts changed (snapshots compare by identity).
|
|
5
|
+
* none of its parts changed (snapshots compare by identity). It carries the
|
|
6
|
+
* store's transcript (`transcript`); `events`, one array of it, is made on
|
|
7
|
+
* first read, so a reader of `transcript` never pays for a copy per delta.
|
|
6
8
|
*/
|
|
7
9
|
export declare function transcriptSnapshot<K extends string>(store: SessionStreamStore<K>, sessionId: K, prev: TranscriptState | undefined): TranscriptState;
|
|
8
10
|
/** A session's transcript as the components read it: a store over the session's slice, subscribed to that session only. */
|
|
9
|
-
export declare function storeTranscript<K extends string>(store: SessionStreamStore<K>, sessionId: K, loadEarlier?: () => void): Transcript;
|
|
11
|
+
export declare function storeTranscript<K extends string>(store: SessionStreamStore<K>, sessionId: K, loadEarlier?: () => void, more?: Pick<Transcript, 'loadThrough' | 'outline'>): Transcript;
|
|
@@ -1,29 +1,41 @@
|
|
|
1
|
+
import { emptyTranscript, transcriptArray } from "zidane/chat/pure";
|
|
1
2
|
// src/chat/headless/streams/transcript.ts
|
|
3
|
+
/** The transcript of a session the store holds nothing for: one object, so a reader's memo holds. */
|
|
4
|
+
const NO_TRANSCRIPT = emptyTranscript();
|
|
2
5
|
/**
|
|
3
6
|
* A session's {@link TranscriptState} read off the store, reusing `prev` while
|
|
4
|
-
* none of its parts changed (snapshots compare by identity).
|
|
7
|
+
* none of its parts changed (snapshots compare by identity). It carries the
|
|
8
|
+
* store's transcript (`transcript`); `events`, one array of it, is made on
|
|
9
|
+
* first read, so a reader of `transcript` never pays for a copy per delta.
|
|
5
10
|
*/
|
|
6
11
|
function transcriptSnapshot(store, sessionId, prev) {
|
|
7
|
-
const
|
|
12
|
+
const transcript = store.getTranscriptSnapshot(sessionId) ?? NO_TRANSCRIPT;
|
|
8
13
|
const running = store.getRunningSnapshot(sessionId);
|
|
9
14
|
const hydrated = store.isHydrated(sessionId);
|
|
10
15
|
const page = store.getPageSnapshot(sessionId);
|
|
11
|
-
if (prev && prev.
|
|
12
|
-
|
|
13
|
-
events
|
|
16
|
+
if (prev && prev.transcript === transcript && prev.running === running && prev.hydrated === hydrated && prev.hasEarlier === page.hasMore && prev.loadingEarlier === page.loadingEarlier) return prev;
|
|
17
|
+
const state = {
|
|
18
|
+
get events() {
|
|
19
|
+
return transcriptArray(transcript);
|
|
20
|
+
},
|
|
14
21
|
running,
|
|
15
22
|
hydrated,
|
|
16
23
|
hasEarlier: page.hasMore,
|
|
17
24
|
loadingEarlier: page.loadingEarlier
|
|
18
25
|
};
|
|
26
|
+
return Object.defineProperty(state, "transcript", {
|
|
27
|
+
value: transcript,
|
|
28
|
+
enumerable: false
|
|
29
|
+
});
|
|
19
30
|
}
|
|
20
31
|
/** A session's transcript as the components read it: a store over the session's slice, subscribed to that session only. */
|
|
21
|
-
function storeTranscript(store, sessionId, loadEarlier) {
|
|
32
|
+
function storeTranscript(store, sessionId, loadEarlier, more = {}) {
|
|
22
33
|
let last;
|
|
23
34
|
return {
|
|
24
35
|
get: () => last = transcriptSnapshot(store, sessionId, last),
|
|
25
36
|
subscribe: (onChange) => store.subscribeSession(sessionId, onChange),
|
|
26
|
-
...loadEarlier ? { loadEarlier } : {}
|
|
37
|
+
...loadEarlier ? { loadEarlier } : {},
|
|
38
|
+
...more
|
|
27
39
|
};
|
|
28
40
|
}
|
|
29
41
|
export { storeTranscript, transcriptSnapshot };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { spawnParents, summarizeTools } from "zidane/chat/pure";
|
|
1
|
+
import { noteTranscriptPass, spawnParents, summarizeTools } from "zidane/chat/pure";
|
|
2
2
|
// src/chat/headless/transcript/batch.ts
|
|
3
3
|
/**
|
|
4
4
|
* Group contiguous rows with the same `childId` so the renderer can
|
|
@@ -14,6 +14,7 @@ import { spawnParents, summarizeTools } from "zidane/chat/pure";
|
|
|
14
14
|
* @param rows - The transcript rows, oldest first.
|
|
15
15
|
*/
|
|
16
16
|
function clusterByOwner(rows) {
|
|
17
|
+
noteTranscriptPass("cluster", rows.length);
|
|
17
18
|
const out = [];
|
|
18
19
|
const parents = spawnParents(rows);
|
|
19
20
|
const present = /* @__PURE__ */ new Set();
|
|
@@ -243,6 +244,7 @@ function liftExchangeToolGroups(rows) {
|
|
|
243
244
|
* @param groupToolCalls - Lifts parent-owned tool calls into one group per exchange before batching adjacent runs. Defaults to `false`.
|
|
244
245
|
*/
|
|
245
246
|
function batchToolRuns(rows, groupToolCalls = false) {
|
|
247
|
+
noteTranscriptPass("batch:tools", rows.length);
|
|
246
248
|
const pre = groupToolCalls ? liftExchangeToolGroups(rows) : rows;
|
|
247
249
|
const out = [];
|
|
248
250
|
const used = /* @__PURE__ */ new Set();
|
|
@@ -311,6 +313,7 @@ const THINKING_CHAIN_TRANSPARENT = /* @__PURE__ */ new Set(["tool", "tool-batch"
|
|
|
311
313
|
* @param rows - The transcript rows after {@link batchToolRuns}, oldest first.
|
|
312
314
|
*/
|
|
313
315
|
function batchThinkingRuns(rows) {
|
|
316
|
+
noteTranscriptPass("batch:thinking", rows.length);
|
|
314
317
|
const out = [];
|
|
315
318
|
const used = /* @__PURE__ */ new Set();
|
|
316
319
|
let chain = [];
|
|
@@ -366,6 +369,7 @@ const TASK_BATCH_IDS = new IdHold();
|
|
|
366
369
|
* @param rows - The transcript rows, oldest first.
|
|
367
370
|
*/
|
|
368
371
|
function batchTaskRuns(rows) {
|
|
372
|
+
noteTranscriptPass("batch:tasks", rows.length);
|
|
369
373
|
const out = [];
|
|
370
374
|
const used = /* @__PURE__ */ new Set();
|
|
371
375
|
let burst = [];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media the session store holds by content hash (its blob table): a turn
|
|
3
|
+
* names such a block `attachment://<hash>`, on a prompt's attachment
|
|
4
|
+
* (`ChatAttachment.ref`) and in a tool result's stand-in line
|
|
5
|
+
* (`[image: image/png, ref attachment://<hash>]`). An app that serves blobs
|
|
6
|
+
* (`TranscriptActions.blobMediaUrl`) loads them by hash: the same bytes for
|
|
7
|
+
* good, so the page caches them for good. Blocks still inline keep the
|
|
8
|
+
* app's older addresses (by call and position, by turn).
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The blob hash an `attachment://<hash>` handle names, or `undefined` for anything else.
|
|
12
|
+
*
|
|
13
|
+
* @param ref - A block's ref.
|
|
14
|
+
*/
|
|
15
|
+
export declare function blobHashOf(ref: string | undefined): string | undefined;
|
|
@@ -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
|
|
@@ -168,6 +168,7 @@ const lastPasses = /* @__PURE__ */ new WeakMap();
|
|
|
168
168
|
function collapseTail(events, showEditDiffs, isStreaming) {
|
|
169
169
|
const last = events.length > 0 ? lastPasses.get(events[0]) : void 0;
|
|
170
170
|
if (!last || last.events.length !== events.length || last.showEditDiffs !== showEditDiffs || last.isStreaming !== isStreaming) return null;
|
|
171
|
+
noteTranscriptPass("collapse:tail", events.length);
|
|
171
172
|
const prev = last.events;
|
|
172
173
|
const { rowOf, headOf } = last;
|
|
173
174
|
const changed = [];
|
|
@@ -263,6 +264,28 @@ function refusedSpawn(tool) {
|
|
|
263
264
|
return tool.name === "spawn" && typeof tool.result === "string" && /^(?:Tool error: )?Cannot spawn/.test(tool.result);
|
|
264
265
|
}
|
|
265
266
|
/**
|
|
267
|
+
* The row the full pass puts in front of `events` when they follow other
|
|
268
|
+
* rows: a pass over `events` alone drops a leading separator and adds no
|
|
269
|
+
* turn boundary before a leading prompt, because nothing is above them.
|
|
270
|
+
* With it, rows derived per exchange join into the rows of the whole.
|
|
271
|
+
*
|
|
272
|
+
* @param events - The events of a part, as `collapseEvents` gets them.
|
|
273
|
+
* @param before - The last row the collapse made for everything above them, if any.
|
|
274
|
+
*/
|
|
275
|
+
function collapseSeamRow(events, before) {
|
|
276
|
+
const first = events[0];
|
|
277
|
+
if (!first || !before || before.kind === "separator") return null;
|
|
278
|
+
if (first.kind === "separator") {
|
|
279
|
+
const sid = rowIdFor(first);
|
|
280
|
+
return cachedRow(first, `s-${sid}`, () => ({
|
|
281
|
+
kind: "separator",
|
|
282
|
+
id: `s-${sid}`
|
|
283
|
+
}));
|
|
284
|
+
}
|
|
285
|
+
if (first.kind === "user-prompt" && !first.childId) return autoSeparatorFor(first, rowIdFor(first));
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
266
289
|
* 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
290
|
*
|
|
268
291
|
* @param events - The transcript events, oldest first.
|
|
@@ -281,6 +304,7 @@ function collapseEvents(events, showEditDiffs, isStreaming) {
|
|
|
281
304
|
* @param isStreaming - A run is in flight.
|
|
282
305
|
*/
|
|
283
306
|
function collapseAll(events, showEditDiffs, isStreaming) {
|
|
307
|
+
noteTranscriptPass("collapse", events.length);
|
|
284
308
|
const rows = [];
|
|
285
309
|
const rowOf = new Int32Array(events.length).fill(-1);
|
|
286
310
|
const headOf = new Int32Array(events.length);
|
|
@@ -395,7 +419,7 @@ function collapseAll(events, showEditDiffs, isStreaming) {
|
|
|
395
419
|
const paired = pair ? events[pair.resultIndex] : void 0;
|
|
396
420
|
const running = !paired || pair?.resultKind === "tool-result" && paired.streaming === true;
|
|
397
421
|
const errored = pair?.resultKind === "error";
|
|
398
|
-
const key = `ub-${sid}|${running}|${errored}|${paired ? rowIdFor(paired) : -1}|${paired?.text.length ?? -1}|${paired?.clipped
|
|
422
|
+
const key = `ub-${sid}|${running}|${errored}|${paired ? rowIdFor(paired) : -1}|${paired?.text.length ?? -1}|${paired?.clipped?.result !== void 0}`;
|
|
399
423
|
rows.push(cachedRow(event, key, () => {
|
|
400
424
|
const command = typeof event.input?.command === "string" ? event.input.command : event.text;
|
|
401
425
|
const result = paired ? paired.text : null;
|
|
@@ -409,7 +433,7 @@ function collapseAll(events, showEditDiffs, isStreaming) {
|
|
|
409
433
|
exit: !running && !errored && result !== null ? parseBashExitMeta(result) : null,
|
|
410
434
|
...errored ? { errored: true } : {},
|
|
411
435
|
...event.callId ? { callId: event.callId } : {},
|
|
412
|
-
...paired?.clipped ? { resultClipped: true } : {}
|
|
436
|
+
...paired?.clipped?.result ? { resultClipped: true } : {}
|
|
413
437
|
};
|
|
414
438
|
}));
|
|
415
439
|
break;
|
|
@@ -426,7 +450,7 @@ function collapseAll(events, showEditDiffs, isStreaming) {
|
|
|
426
450
|
const resuming = !paired && event.resuming === true;
|
|
427
451
|
const scriptProgress = event.callId ? progressOf.get(scriptProgressKey(event.callId, event.childId)) : void 0;
|
|
428
452
|
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
|
|
453
|
+
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
454
|
rows.push(cachedRow(event, key, () => {
|
|
431
455
|
const toolName = event.tool ?? "?";
|
|
432
456
|
const rawInput = event.input;
|
|
@@ -447,7 +471,9 @@ function collapseAll(events, showEditDiffs, isStreaming) {
|
|
|
447
471
|
result,
|
|
448
472
|
ok,
|
|
449
473
|
...event.callId ? { callId: event.callId } : {},
|
|
450
|
-
...paired?.clipped ? { resultClipped: true } : {},
|
|
474
|
+
...paired?.clipped?.result ? { resultClipped: true } : {},
|
|
475
|
+
...paired?.mediaRefs ? { mediaRefs: paired.mediaRefs } : {},
|
|
476
|
+
...event.clipped?.input ? { inputClipped: true } : {},
|
|
451
477
|
...waitingFor ? { waitingFor } : {},
|
|
452
478
|
...resuming ? { resuming: true } : {},
|
|
453
479
|
...scriptProgress ? { scriptProgress } : {},
|
|
@@ -564,4 +590,4 @@ function collapseAll(events, showEditDiffs, isStreaming) {
|
|
|
564
590
|
});
|
|
565
591
|
return rows;
|
|
566
592
|
}
|
|
567
|
-
export { collapseAll, collapseEvents, inheritRowIdentity, refusedSpawn, toolFailed };
|
|
593
|
+
export { collapseAll, collapseEvents, collapseSeamRow, inheritRowIdentity, refusedSpawn, toolFailed };
|