@prettier-ai/dsh-client-ui-chat 0.1.2-alpha.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.
Files changed (76) hide show
  1. package/LICENSE +21 -0
  2. package/README.i18n.yaml +6 -0
  3. package/README.md +69 -0
  4. package/README.zh.md +69 -0
  5. package/lib/client.js +7588 -0
  6. package/lib/index.js +25 -0
  7. package/lib/invariant.js +16 -0
  8. package/lib/types/chat-settings.d.ts +20 -0
  9. package/lib/types/client/apply.d.ts +10 -0
  10. package/lib/types/client/chat/ApprovalCommand.d.ts +20 -0
  11. package/lib/types/client/chat/AssistantMarkdown.d.ts +22 -0
  12. package/lib/types/client/chat/AssistantNodeView.d.ts +4 -0
  13. package/lib/types/client/chat/ChatNodeSeat.d.ts +15 -0
  14. package/lib/types/client/chat/ChatView.d.ts +7 -0
  15. package/lib/types/client/chat/CommandNodeView.d.ts +9 -0
  16. package/lib/types/client/chat/CompactionCommandCard.d.ts +8 -0
  17. package/lib/types/client/chat/CompactionItem.d.ts +19 -0
  18. package/lib/types/client/chat/ContextBody.d.ts +131 -0
  19. package/lib/types/client/chat/ContextInjectionRow.d.ts +26 -0
  20. package/lib/types/client/chat/GenericCommandCard.d.ts +9 -0
  21. package/lib/types/client/chat/MessageIconActions.d.ts +36 -0
  22. package/lib/types/client/chat/MessageItem.d.ts +42 -0
  23. package/lib/types/client/chat/ReasoningRow.d.ts +14 -0
  24. package/lib/types/client/chat/StatsLine.d.ts +64 -0
  25. package/lib/types/client/chat/SystemPromptRow.d.ts +19 -0
  26. package/lib/types/client/chat/TurnNavigator.d.ts +21 -0
  27. package/lib/types/client/chat/TurnProcessNodeView.d.ts +4 -0
  28. package/lib/types/client/chat/TurnTailNodeView.d.ts +7 -0
  29. package/lib/types/client/chat/TurnUsageDisclosure.d.ts +9 -0
  30. package/lib/types/client/chat/message-chrome.d.ts +49 -0
  31. package/lib/types/client/chat/register-node-renderers.d.ts +7 -0
  32. package/lib/types/client/chat/searchable-hidden.d.ts +9 -0
  33. package/lib/types/client/chat/token-format.d.ts +25 -0
  34. package/lib/types/client/chat/turn-assistant.d.ts +8 -0
  35. package/lib/types/client/chat/use-calendar-day.d.ts +6 -0
  36. package/lib/types/client/chat/use-throttled-visual-update.d.ts +8 -0
  37. package/lib/types/client/contract/assistant-content.d.ts +9 -0
  38. package/lib/types/client/contract/chat-nodes.d.ts +110 -0
  39. package/lib/types/client/contract/slots.d.ts +195 -0
  40. package/lib/types/client/contract/snapshot.d.ts +65 -0
  41. package/lib/types/client/contract/store.d.ts +22 -0
  42. package/lib/types/client/contract/turn-metrics.d.ts +38 -0
  43. package/lib/types/client/contract/turn-process.d.ts +48 -0
  44. package/lib/types/client/conversation-nodes/assistant.d.ts +37 -0
  45. package/lib/types/client/conversation-nodes/chat-snapshot-builder.d.ts +42 -0
  46. package/lib/types/client/conversation-nodes/command.d.ts +54 -0
  47. package/lib/types/client/conversation-nodes/common.d.ts +41 -0
  48. package/lib/types/client/conversation-nodes/compaction.d.ts +22 -0
  49. package/lib/types/client/conversation-nodes/event-projection.d.ts +57 -0
  50. package/lib/types/client/conversation-nodes/fallback.d.ts +17 -0
  51. package/lib/types/client/conversation-nodes/inbox.d.ts +21 -0
  52. package/lib/types/client/conversation-nodes/message.d.ts +31 -0
  53. package/lib/types/client/conversation-nodes/partial.d.ts +34 -0
  54. package/lib/types/client/conversation-nodes/register.d.ts +7 -0
  55. package/lib/types/client/conversation-nodes/request-prompt.d.ts +30 -0
  56. package/lib/types/client/conversation-nodes/retry.d.ts +23 -0
  57. package/lib/types/client/conversation-nodes/tool.d.ts +23 -0
  58. package/lib/types/client/conversation-nodes/turn-error.d.ts +31 -0
  59. package/lib/types/client/conversation-nodes/turn-max-tokens.d.ts +23 -0
  60. package/lib/types/client/conversation-nodes/turn-navigation.d.ts +17 -0
  61. package/lib/types/client/conversation-nodes/turn-process.d.ts +32 -0
  62. package/lib/types/client/conversation-nodes/turn-tail.d.ts +28 -0
  63. package/lib/types/client/details/DetailsPanel.d.ts +4 -0
  64. package/lib/types/client/details/tool-node-reader.d.ts +9 -0
  65. package/lib/types/client/index.d.ts +36 -0
  66. package/lib/types/client/locale.d.ts +224 -0
  67. package/lib/types/client/markdown-labels.d.ts +10 -0
  68. package/lib/types/client/model/conversation-context.d.ts +22 -0
  69. package/lib/types/client/model/steering-history.d.ts +23 -0
  70. package/lib/types/client/model/tool-call-tree.d.ts +45 -0
  71. package/lib/types/client/settings/TranscriptViewRow.d.ts +22 -0
  72. package/lib/types/client/stores.d.ts +22 -0
  73. package/lib/types/client/transcript-view.d.ts +22 -0
  74. package/lib/types/index.d.ts +6 -0
  75. package/lib/types/invariant.d.ts +13 -0
  76. package/package.json +121 -0
@@ -0,0 +1,49 @@
1
+ import type { Translate } from '@prettier-ai/dsh-client-ui-slots';
2
+ /** The date-template share of the conversation dictionary the clock consumes. */
3
+ export type ClockTranslate = Translate<'clock.md' | 'clock.ymd'>;
4
+ /** The elapsed-duration share of the conversation dictionary. */
5
+ export type RunDurationTranslate = Translate<'duration.seconds' | 'duration.minutes'>;
6
+ /**
7
+ * Local calendar-day epoch (ms at local midnight) for an instant.
8
+ * @param ms - Unix epoch ms.
9
+ * @returns Midnight of that local calendar day.
10
+ */
11
+ export declare function startOfLocalDay(ms: number): number;
12
+ /**
13
+ * Delay until the next local midnight after `ms` (at least 1ms).
14
+ * @param ms - Unix epoch ms.
15
+ * @returns Milliseconds until the following local midnight.
16
+ */
17
+ export declare function msUntilNextLocalMidnight(ms: number): number;
18
+ /**
19
+ * Localized elapsed-time label shared by running and settled turn chrome.
20
+ * @param ms - Elapsed duration in milliseconds (negatives clamp to zero).
21
+ * @param t - Translate seat supplying the duration templates.
22
+ * @returns Display string in whole seconds.
23
+ */
24
+ export declare function formatRunDuration(ms: number, t: RunDurationTranslate): string;
25
+ /**
26
+ * Sub-turn latency figure: one decimal under ten seconds, whole seconds
27
+ * beyond. Unit-less so the locale template owns the second suffix.
28
+ * @param ms - Latency in milliseconds (negatives clamp to zero).
29
+ * @returns Display number in seconds without unit.
30
+ */
31
+ export declare function formatLatencySeconds(ms: number): string;
32
+ /**
33
+ * Decode-throughput figure: whole tokens from ten up, one decimal below.
34
+ * @param tps - Tokens per second.
35
+ * @returns Display number without unit.
36
+ */
37
+ export declare function formatTokensPerSecond(tps: number): string;
38
+ /**
39
+ * Compact local timestamp for message IconActions. Same calendar day →
40
+ * `HH:mm`; earlier this year → the `clock.md` date template + clock; other
41
+ * years → the `clock.ymd` template + clock. Pure: the date templates arrive
42
+ * through the caller's locale seat.
43
+ * @param time - Unix epoch ms from the source session event.
44
+ * @param t - translate seat supplying the `clock.md` / `clock.ymd` templates.
45
+ * @param now - Reference instant for the day/year cut (defaults to wall clock).
46
+ * @returns Date-aware clock string (24-hour, zero-padded time).
47
+ */
48
+ export declare function formatMessageClock(time: number, t: ClockTranslate, now?: number): string;
49
+ //# sourceMappingURL=message-chrome.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { Context } from '@prettier-ai/cordis';
2
+ /**
3
+ * Register this package's business renderers behind the keyed Chat Node seat.
4
+ * @param ctx - owning UI Conversation context.
5
+ */
6
+ export declare function registerChatNodeRenderers(ctx: Context): void;
7
+ //# sourceMappingURL=register-node-renderers.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { type RefObject } from 'react';
2
+ /**
3
+ * Apply searchable hidden state without unmounting a stable subtree.
4
+ * @param hidden - whether the subtree is currently hidden.
5
+ * @param reveal - callback for browser find's `beforematch` reveal.
6
+ * @returns ref for the stable subtree root.
7
+ */
8
+ export declare function useSearchableHidden(hidden: boolean, reveal: () => void): RefObject<HTMLDivElement>;
9
+ //# sourceMappingURL=searchable-hidden.d.ts.map
@@ -0,0 +1,25 @@
1
+ import type { ChatViewSlotProps } from '../contract/slots.ts';
2
+ /**
3
+ * Compact token count: 517 / 12.2K / 517K / 1.2M.
4
+ * @param value - non-negative token count.
5
+ * @param t - Chat locale seat.
6
+ * @returns locale-owned compact display string.
7
+ */
8
+ export declare function formatTokens(value: number, t: ChatViewSlotProps['t']): string;
9
+ /**
10
+ * Exact integer token count with locale-owned digit grouping.
11
+ * @param value - non-negative safe integer token count.
12
+ * @param t - Chat locale seat.
13
+ * @returns an unrounded display string.
14
+ */
15
+ export declare function formatExactTokens(value: number, t: ChatViewSlotProps['t']): string;
16
+ /**
17
+ * Display-ready cache-hit share without rounding a partial hit to 100%.
18
+ * @param cacheReadTokens - exact prompt tokens served from cache.
19
+ * @param promptTokens - exact aggregate prompt tokens.
20
+ * @param decimalPlaces - ordinary-ratio precision; partial hits that would
21
+ * round to 100 automatically use enough additional precision to stay honest.
22
+ * @returns percentage text, or null when there was no prompt input.
23
+ */
24
+ export declare function formatCacheHitPercent(cacheReadTokens: number, promptTokens: number, decimalPlaces?: 0 | 1): string | null;
25
+ //# sourceMappingURL=token-format.d.ts.map
@@ -0,0 +1,8 @@
1
+ import type { AssistantBlock } from '../contract/snapshot.ts';
2
+ /**
3
+ * Collect visible prose from one Assistant lifecycle.
4
+ * @param blocks - Assistant content blocks.
5
+ * @returns concatenated text blocks.
6
+ */
7
+ export declare function assistantText(blocks: readonly AssistantBlock[]): string;
8
+ //# sourceMappingURL=turn-assistant.d.ts.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Local calendar-day epoch that advances at each local midnight.
3
+ * @returns Midnight ms for the current local day; updates after the boundary.
4
+ */
5
+ export declare function useCalendarDay(): number;
6
+ //# sourceMappingURL=use-calendar-day.d.ts.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Return a stable scheduler that coalesces visual updates over a frame interval.
3
+ * @param update - DOM alignment to run after the throttle interval.
4
+ * @param intervalFrames - frames to wait before applying the latest alignment.
5
+ * @returns a stable function that schedules the latest update.
6
+ */
7
+ export declare function useThrottledVisualUpdate(update: () => void, intervalFrames?: number): () => void;
8
+ //# sourceMappingURL=use-throttled-visual-update.d.ts.map
@@ -0,0 +1,9 @@
1
+ import type { AssistantBlock } from './snapshot.ts';
2
+ /**
3
+ * Test whether Assistant blocks contain a user-facing reply rather than only
4
+ * reasoning or Tool-call protocol material.
5
+ * @param blocks - Assistant content blocks.
6
+ * @returns whether the blocks contain visible reply content.
7
+ */
8
+ export declare function hasAssistantReplyContent(blocks: readonly AssistantBlock[]): boolean;
9
+ //# sourceMappingURL=assistant-content.d.ts.map
@@ -0,0 +1,110 @@
1
+ import type { AssistantBlock, AssistantMessageNode, CommandNode, CompactionSummaryNode, ConversationLocation, ConversationViewNode, ModelRetryNode, RunningToolCall, ToolCallBlock } from '@prettier-ai/dsh-client-ui-conversation/client';
2
+ /** Final Chat render unit produced by a Chat business Definition. */
3
+ export interface ChatConversationViewNode extends ConversationViewNode {
4
+ readonly target: 'chat';
5
+ readonly anchorSeq: number;
6
+ readonly location: ConversationLocation;
7
+ readonly visibility: 'visible' | 'hidden';
8
+ }
9
+ /** Merge-extensible payload registry keyed by final Chat renderer kind. */
10
+ export interface ChatNodeDataMap {
11
+ }
12
+ /** Renderer kinds contributed by the currently installed Chat business modules. */
13
+ export type ChatNodeKind = Extract<keyof ChatNodeDataMap, string>;
14
+ /** Final Chat Node narrowed to one registered renderer kind and payload. */
15
+ export type ChatNode<Kind extends ChatNodeKind = ChatNodeKind> = {
16
+ [RegisteredKind in Kind]: ChatConversationViewNode & {
17
+ readonly kind: RegisteredKind;
18
+ readonly data: ChatNodeDataMap[RegisteredKind];
19
+ };
20
+ }[Kind];
21
+ /** Final Assistant row payload shared by streaming and settled states. */
22
+ export interface AssistantChatData {
23
+ readonly status: 'running' | 'settled' | 'interrupted';
24
+ readonly turn: number;
25
+ readonly step: number;
26
+ readonly blocks: readonly AssistantBlock[];
27
+ readonly time: number;
28
+ readonly usage?: unknown;
29
+ readonly finalNode?: AssistantMessageNode;
30
+ }
31
+ /** Settled or interrupted Assistant payload with its durable presentation node. */
32
+ export type FinalAssistantChatData = AssistantChatData & {
33
+ readonly finalNode: AssistantMessageNode;
34
+ };
35
+ /** Root Tool row payload; the root lifecycle owns all recursive subcalls. */
36
+ export interface ToolChatData {
37
+ readonly root: ToolCallBlock;
38
+ }
39
+ /** One manual command and its correlated compaction transaction. */
40
+ export interface ManualCompactionChatData {
41
+ readonly command: CommandNode;
42
+ readonly compaction: CompactionSummaryNode | null;
43
+ }
44
+ /** One durable retry chain rendered as a single row. */
45
+ export interface RetryChatData {
46
+ readonly attempts: readonly ModelRetryNode[];
47
+ readonly current: ModelRetryNode;
48
+ }
49
+ /** One provider/model route that contributed a billed request attempt. */
50
+ export interface TurnTokenUsageRoute {
51
+ readonly provider: string;
52
+ readonly model: string;
53
+ }
54
+ /** Exact provider-reported token accounting for every attempt in one completed Turn. */
55
+ export interface TurnTokenUsage {
56
+ /** Sum of uncached prompt input across all attempts. */
57
+ readonly uncachedInputTokens: number;
58
+ readonly outputTokens: number;
59
+ /** Exact aggregate prompt plus output total across all attempts. */
60
+ readonly totalTokens: number;
61
+ /** Present only when every attempt reported the bucket. */
62
+ readonly cacheReadTokens?: number;
63
+ /** Present only when every attempt reported the bucket. */
64
+ readonly cacheWriteTokens?: number;
65
+ /** Output subset, present only when every attempt reported it. */
66
+ readonly reasoningTokens?: number;
67
+ /** Present only when every billed attempt has provider/model attribution. */
68
+ readonly routes?: readonly TurnTokenUsageRoute[];
69
+ }
70
+ /** Turn-local footer row that owns actions and optional feature contributions. */
71
+ export interface TurnTailChatData {
72
+ readonly turn: number;
73
+ readonly seq: number;
74
+ readonly time: number;
75
+ /** Last finalized content-bearing Assistant in this Turn. */
76
+ readonly closing: FinalAssistantChatData | null;
77
+ /** Whether non-rendered later evidence makes the closing seq non-tail. */
78
+ readonly branchUnavailable: boolean;
79
+ readonly ttftMs?: number;
80
+ readonly tokensPerSecond?: number;
81
+ /** Exact per-Turn accounting; absent when the loaded evidence is incomplete. */
82
+ readonly tokenUsage?: TurnTokenUsage;
83
+ }
84
+ /** Turn-level process disclosure projected before the finalized answer. */
85
+ export interface TurnProcessChatData {
86
+ readonly turn: number;
87
+ readonly controlAnchorSeq: number;
88
+ readonly processStartSeq: number;
89
+ readonly answerAnchorSeq: number | null;
90
+ readonly answerStep: number | null;
91
+ readonly inlineReasoning: boolean;
92
+ readonly messageCount: number;
93
+ readonly toolCallCount: number;
94
+ readonly subagentCount: number;
95
+ }
96
+ /**
97
+ * Test whether a Tool root has settled.
98
+ * @param block - Tool root lifecycle value.
99
+ * @returns whether the root carries its final result.
100
+ */
101
+ export declare function isSettledTool(block: ToolCallBlock): block is Extract<ToolCallBlock, {
102
+ kind: 'tool-result';
103
+ }>;
104
+ /**
105
+ * Test whether a Tool root is still running.
106
+ * @param block - Tool root lifecycle value.
107
+ * @returns whether the root lacks a final result.
108
+ */
109
+ export declare function isRunningTool(block: ToolCallBlock): block is RunningToolCall;
110
+ //# sourceMappingURL=chat-nodes.d.ts.map
@@ -0,0 +1,195 @@
1
+ /** Chat-owned Slot declarations and composed component props. */
2
+ import type { MessageId } from '@prettier-ai/dsh-llm/brand';
3
+ import type { ConversationTurnDataMap, MessageImageLoader, MessageImagesOwnerProps, RenderMessageImages, TurnLocation } from '@prettier-ai/dsh-client-ui-conversation/client';
4
+ import type { InjectFace, PropsLocale, PropsRenderSlots, PropsRuntime, PropsStore, SlotHookFactory, SnapshotSelectorHook } from '@prettier-ai/dsh-client-ui-slots';
5
+ import type { SnapshotStore } from '@prettier-ai/dsh-client-store';
6
+ import type { MarkdownFileMentions } from '@prettier-ai/dsh-client-ui-primitives';
7
+ import type { createChatStore } from '../stores.ts';
8
+ import type { ToolCallId, SelectionTarget } from './store.ts';
9
+ import type { ChatNode, ChatNodeKind } from './chat-nodes.ts';
10
+ import type { ChatSnapshot, CommandNode, CompactionSummaryNode, ToolCallBlock } from './snapshot.ts';
11
+ import type { TurnProcessSpec } from './turn-process.ts';
12
+ import type { TranscriptViewMode } from '../../chat-settings.ts';
13
+ /** Selector hook over the current Conversation binding's Chat target. */
14
+ export type UseChat = SnapshotSelectorHook<ChatSnapshot>;
15
+ /** Owner currency of the completed-Turn extension chain. */
16
+ export interface TurnTailOwnerProps {
17
+ turn: TurnLocation;
18
+ seq: number;
19
+ openFile: (path: string) => void;
20
+ }
21
+ /** Owner currency of finalized-assistant actions. */
22
+ export interface AssistantActionOwnerProps {
23
+ messageId: MessageId;
24
+ }
25
+ /** Optional prose file-mention provider consumed by Chat. */
26
+ export interface ChatFileMentions {
27
+ /**
28
+ * Resolve prose links for one closing Turn.
29
+ * @param owner - closing-Turn identity and file opener.
30
+ * @returns link resolver when available.
31
+ */
32
+ forClosing(owner: TurnTailOwnerProps): MarkdownFileMentions | undefined;
33
+ }
34
+ declare module '@prettier-ai/cordis' {
35
+ interface Context {
36
+ /** Optional prose file-mention provider. */
37
+ chatFileMentions: ChatFileMentions;
38
+ }
39
+ }
40
+ /** Hook constrained to business data published on the current Chat Node's Turn. */
41
+ export type UseChatNodeTurnData = <Key extends Extract<keyof ConversationTurnDataMap, string>>(key: Key) => Readonly<ConversationTurnDataMap[Key]> | undefined;
42
+ /** Slot-level Hook factory for keyed Chat renderers. */
43
+ export interface ChatNodeTurnDataInjected {
44
+ hooks: {
45
+ turnData: SlotHookFactory<'conversation.chat.node', UseChatNodeTurnData>;
46
+ };
47
+ }
48
+ /** Stable owner currency delivered to a keyed Chat renderer. */
49
+ export interface ChatNodeOwnerProps {
50
+ selectedCallId?: ToolCallId | undefined;
51
+ cwd?: string | undefined;
52
+ openFile: (path: string) => void;
53
+ inspectCall: (callId: ToolCallId) => void;
54
+ forkAt: (seq: number) => void;
55
+ renderMessageImages: RenderMessageImages;
56
+ fileMentions: (owner: TurnTailOwnerProps) => MarkdownFileMentions | undefined;
57
+ /** Turn-process state when this Node belongs to a projected Turn. */
58
+ turnProcess?: TurnProcessOwnerProps | undefined;
59
+ }
60
+ /** Shared presentation state for one Turn-process answer generation. */
61
+ export interface TurnProcessOwnerProps {
62
+ readonly spec: TurnProcessSpec;
63
+ readonly foldable: boolean;
64
+ readonly open: boolean;
65
+ setOpen(open: boolean): void;
66
+ }
67
+ /** Full props of one keyed Chat renderer. */
68
+ export type ChatNodeViewProps<Kind extends ChatNodeKind = ChatNodeKind> = PropsRuntime<'conversation.chat.node', Kind> & PropsLocale<'chat'>;
69
+ /** Tool block rendered in the details panel. */
70
+ export interface DetailsToolOwnerProps {
71
+ block: ToolCallBlock;
72
+ cwd?: string | undefined;
73
+ }
74
+ /** Command-row owner share. */
75
+ export interface CommandRowOwnerProps {
76
+ node: CommandNode;
77
+ compaction?: CompactionSummaryNode;
78
+ }
79
+ /** Full props of a registered command row. */
80
+ export type CommandRowProps = PropsRuntime<'conversation.chat.commandview'>;
81
+ /** Shared Chat store handle. */
82
+ export type ChatStore = ReturnType<typeof createChatStore>;
83
+ /** In-memory reader position resilient to transcript reflow. */
84
+ export interface ChatScrollPosition {
85
+ readonly anchorKey: string;
86
+ readonly anchorTop: number;
87
+ readonly scrollTop: number;
88
+ }
89
+ /** Business callbacks injected into the Chat view. */
90
+ export interface ChatViewInjected {
91
+ hooks: {
92
+ /** Persisted completed-Turn transcript presentation. */
93
+ transcriptView: SnapshotStore<TranscriptViewMode>;
94
+ };
95
+ openDetails: (target: SelectionTarget) => void;
96
+ openFile: (path: string) => Promise<void>;
97
+ loadOlder: () => void;
98
+ loadImage: MessageImageLoader;
99
+ chatScroll: {
100
+ save: (position: ChatScrollPosition | null) => void;
101
+ read: () => ChatScrollPosition | null;
102
+ };
103
+ forkAt: (seq: number) => void;
104
+ fileMentions: (owner: TurnTailOwnerProps) => MarkdownFileMentions | undefined;
105
+ }
106
+ /** Full Chat view props. */
107
+ export type ChatViewSlotProps = PropsRuntime<'conversation.view'> & PropsRenderSlots<'conversation.chat.node' | 'conversation.message.images'> & PropsStore<ChatStore> & InjectFace<ChatViewInjected> & PropsLocale<'chat'>;
108
+ /** Full props of the durable-message image renderer. */
109
+ export type MessageImagesProps = PropsRuntime<'conversation.message.images'> & PropsLocale<'conversation'>;
110
+ /** Details-panel callbacks. */
111
+ export interface DetailsInjected {
112
+ closeDetails: () => void;
113
+ }
114
+ /** Full details-panel props. */
115
+ export type DetailsSlotProps = PropsRuntime<'details'> & PropsRenderSlots<'conversation.details.tool'> & PropsStore<ChatStore> & InjectFace<DetailsInjected> & PropsLocale<'chat'>;
116
+ declare module '@prettier-ai/dsh-client-ui-slots' {
117
+ interface SessionStandardProps {
118
+ /** Selector hook over the current Conversation binding's Chat target. */
119
+ useChat: UseChat;
120
+ }
121
+ interface LocaleNamespaceMap {
122
+ /** Chat target, transcript node, statistics, and details copy. */
123
+ chat: import('../locale.ts').ChatKey;
124
+ }
125
+ interface SlotMap {
126
+ /**
127
+ * Final Chat node renderer, keyed by `ChatNodeKind`. The component receives
128
+ * the typed node, shared Chat actions, and Turn-data hook. Reusing a key
129
+ * replaces that node renderer; a kind with no occupant renders no row.
130
+ */
131
+ 'conversation.chat.node': {
132
+ kind: 'keyed';
133
+ scope: 'session';
134
+ owner: ChatNodeOwnerProps;
135
+ keyProps: {
136
+ [Kind in ChatNodeKind]: {
137
+ node: ChatNode<Kind>;
138
+ };
139
+ };
140
+ hookContext: string;
141
+ inject: ChatNodeTurnDataInjected;
142
+ };
143
+ /**
144
+ * Renderer for one consecutive group of durable message images. The owner
145
+ * supplies image references, an authorized loader, and alignment. A
146
+ * registration replaces the shipped gallery; without one, images are omitted.
147
+ */
148
+ 'conversation.message.images': {
149
+ kind: 'single';
150
+ scope: 'session';
151
+ owner: MessageImagesOwnerProps;
152
+ };
153
+ /**
154
+ * Command row keyed by the command name. The component receives the folded
155
+ * command lifecycle and linked compaction when present. Reusing a key
156
+ * replaces that command renderer; an unoccupied key uses the generic card.
157
+ */
158
+ 'conversation.chat.commandview': {
159
+ kind: 'keyed';
160
+ scope: 'session';
161
+ owner: CommandRowOwnerProps;
162
+ };
163
+ /**
164
+ * Selector-routed extension before a completed Turn's action row. The
165
+ * component receives the Turn, closing sequence, and file opener. The first
166
+ * selector that accepts the owner renders; an all-declined chain is empty.
167
+ */
168
+ 'conversation.chat.turnTail': {
169
+ kind: 'chain';
170
+ scope: 'session';
171
+ owner: TurnTailOwnerProps;
172
+ };
173
+ /**
174
+ * Ordered actions for one finalized assistant message. Each entry receives
175
+ * the durable message id; a fresh `id` adds an action and reusing one replaces
176
+ * that entry. With no entries, the standard action row remains unchanged.
177
+ */
178
+ 'conversation.chat.assistant-actions': {
179
+ kind: 'list';
180
+ scope: 'session';
181
+ owner: AssistantActionOwnerProps;
182
+ };
183
+ /**
184
+ * Whole details-panel body for the selected Tool call. The component receives
185
+ * the running or settled block and optional workspace root. A registration
186
+ * replaces the shipped Tool details renderer; absence uses the raw fallback.
187
+ */
188
+ 'conversation.details.tool': {
189
+ kind: 'single';
190
+ scope: 'session';
191
+ owner: DetailsToolOwnerProps;
192
+ };
193
+ }
194
+ }
195
+ //# sourceMappingURL=slots.d.ts.map
@@ -0,0 +1,65 @@
1
+ import type { ConversationNode, ConversationTimelineSnapshot, PartialAssistant, RunningToolCall } from '@prettier-ai/dsh-client-ui-conversation/client';
2
+ import type { ChatConversationViewNode } from './chat-nodes.ts';
3
+ export type { AssistantBlock, AssistantMessageNode, AssistantProvenanceView, AssistantRequestConfig, AssistantTiming, CommandNode, CompactionSummaryNode, ContextMessageNode, ConversationNode, ModelRetryNode, PartialAssistant, RunningToolCall, SteeringMessageNode, TodoItem, ToolCallBlock, ToolResultNode, TurnErrorNode, TurnMaxTokensNode, UnknownSurfaceNode, UserMessageNode, } from '@prettier-ai/dsh-client-ui-conversation/client';
4
+ /** Stable live per-key reader for Chat nodes. */
5
+ export interface ChatNodeStore {
6
+ /** @param key - stable Conversation Context key. @returns current Node, when visible or hidden. */
7
+ get(key: string): ChatConversationViewNode | undefined;
8
+ /** @returns all currently materialized Nodes without imposing render order. */
9
+ values(): readonly ChatConversationViewNode[];
10
+ }
11
+ /** One loaded Turn projected into the compact Chat navigation rail. */
12
+ export interface TurnNavigationItem {
13
+ readonly turn: number;
14
+ /** Stable Conversation Context key the rail scrolls to. */
15
+ readonly anchorKey: string;
16
+ /** Bounded prompt preview; empty when the loaded window starts mid-Turn. */
17
+ readonly prompt: string;
18
+ /** Bounded assistant-response preview; empty until the Turn answers. */
19
+ readonly response: string;
20
+ }
21
+ /** Stable live navigation projection of the loaded Turns. */
22
+ export interface ChatTurnNavigationIndex {
23
+ /**
24
+ * Loaded Turns that have a visible anchor, in timeline order. The array
25
+ * identity changes exactly when a Turn enters, leaves, or changes preview,
26
+ * so a renderer can select it directly as its change signal.
27
+ * @returns current navigation items.
28
+ */
29
+ items(): readonly TurnNavigationItem[];
30
+ }
31
+ /** Stable live Location index for Chat nodes. */
32
+ export interface ChatLocationNodeIndex {
33
+ /** @param turn - owning turn. @returns ordered Chat Node keys in the turn. */
34
+ getTurn(turn: number): readonly string[];
35
+ /** @param turn - owning turn. @param step - owning step. @returns ordered Chat Node keys in the step. */
36
+ getStep(turn: number, step: number): readonly string[];
37
+ }
38
+ /** Compatibility projection backing StatsLine and the legacy top-level snapshot fields. */
39
+ export interface LegacyConversationSlice {
40
+ readonly nodes: readonly ConversationNode[];
41
+ readonly turnTimings: ReadonlyMap<number, {
42
+ readonly startTime: number;
43
+ readonly endTime?: number;
44
+ }>;
45
+ readonly turnEnds: ReadonlyMap<number, number>;
46
+ readonly partial: PartialAssistant | null;
47
+ readonly runningCalls: readonly RunningToolCall[];
48
+ }
49
+ /** Incremental Chat publication with immutable order and stable live keyed readers. */
50
+ export interface ChatSnapshot {
51
+ readonly order: readonly string[];
52
+ readonly nodes: ChatNodeStore;
53
+ readonly locations: ChatLocationNodeIndex;
54
+ readonly navigation: ChatTurnNavigationIndex;
55
+ readonly timeline: ConversationTimelineSnapshot;
56
+ readonly legacy: LegacyConversationSlice;
57
+ }
58
+ declare module '@prettier-ai/dsh-client-ui-conversation/client' {
59
+ interface ConversationViewSnapshotMap {
60
+ chat: ChatSnapshot;
61
+ }
62
+ }
63
+ /** Empty Chat target used before a view builder is registered. */
64
+ export declare const EMPTY_CHAT_SNAPSHOT: ChatSnapshot;
65
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1,22 @@
1
+ /** Chat-owned selection state shared by the transcript and details panel. */
2
+ import type { TurnProcessGeneration } from './turn-process.ts';
3
+ /** Tool call identity as carried by Chat nodes. */
4
+ export type ToolCallId = string;
5
+ /** Selection target for the Chat details linkage channel. */
6
+ export interface SelectionTarget {
7
+ turnSeq: number;
8
+ stepSeq?: number;
9
+ callId?: ToolCallId;
10
+ toolName?: string;
11
+ }
12
+ /** One manually expanded Turn answer generation. */
13
+ export interface TurnProcessViewEntry {
14
+ readonly turn: number;
15
+ readonly generation: TurnProcessGeneration;
16
+ }
17
+ /** Per-Session state shared only by the Chat view and details surface. */
18
+ export interface ChatStoreState {
19
+ selection: SelectionTarget | null;
20
+ turnProcesses: TurnProcessViewEntry[];
21
+ }
22
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1,38 @@
1
+ import type { AssistantMessageNode, ConversationNode } from './snapshot.ts';
2
+ /** Latency and decode-throughput readings for one turn's footer. */
3
+ export interface TurnMetrics {
4
+ /** First-step TTFT in ms; absent when that step carries no recorded timing. */
5
+ ttftMs?: number;
6
+ /** Decode throughput over steps carrying both timing and provider usage. */
7
+ tokensPerSecond?: number;
8
+ }
9
+ /** One assistant step's derivable latency facts; null marks an unrecorded part. */
10
+ export interface StepReading {
11
+ /** step/start → first token delta, in ms. */
12
+ ttftMs: number | null;
13
+ /** First token delta → final message, in ms. */
14
+ decodeMs: number | null;
15
+ /** Provider-reported completion tokens. */
16
+ outputTokens: number | null;
17
+ }
18
+ type AssistantNode = AssistantMessageNode;
19
+ /**
20
+ * Read one assistant node's TTFT, decode wall time, and output tokens.
21
+ * @param node - A settled assistant node.
22
+ * @returns Per-part readings with `null` for unrecorded values.
23
+ */
24
+ export declare function assistantStepReading(node: AssistantNode): StepReading;
25
+ /**
26
+ * Fold assistant nodes into per-turn footer metrics.
27
+ *
28
+ * TTFT is the turn's lowest-step request-dispatch-to-first-token reading, so
29
+ * it is only meaningful when the turn's start is inside
30
+ * the loaded window (the caller gates on `turnTimings`, which shares that
31
+ * window). Throughput divides summed output tokens by summed decode wall time,
32
+ * counting only steps that carry both.
33
+ * @param nodes - Snapshot nodes of the loaded window.
34
+ * @returns Turn number → available metrics; turns with none are absent.
35
+ */
36
+ export declare function deriveTurnMetrics(nodes: readonly ConversationNode[]): Map<number, TurnMetrics>;
37
+ export {};
38
+ //# sourceMappingURL=turn-metrics.d.ts.map
@@ -0,0 +1,48 @@
1
+ /** Turn-local process window encoded as a reference-stable Location-data scalar. */
2
+ export type TurnProcessSignature = string;
3
+ /** Stable identity of one finalized answer generation, independent of its exact ordering anchor. */
4
+ export type TurnProcessGeneration = string;
5
+ /** Current process range and finalized answer boundary derived from one Turn. */
6
+ export interface TurnProcessSpec {
7
+ readonly turn: number;
8
+ /** Stable control-node anchor source, including currently ineligible evidence. */
9
+ readonly controlAnchorSeq: number;
10
+ readonly processStartSeq: number;
11
+ readonly answerAnchorSeq: number | null;
12
+ readonly answerStep: number | null;
13
+ readonly inlineReasoning: boolean;
14
+ /** Reply-bearing durable Assistant messages before the final answer. */
15
+ readonly messageCount: number;
16
+ /** Durable non-subagent Tool calls recorded by this Turn. */
17
+ readonly toolCallCount: number;
18
+ /** Tool calls whose configured name identifies a subagent delegation. */
19
+ readonly subagentCount: number;
20
+ }
21
+ /** Chat Node kinds that remain independent of a Turn's process disclosure. */
22
+ export declare const TURN_PROCESS_INDEPENDENT_KINDS: ReadonlySet<string>;
23
+ /**
24
+ * Identify one finalized answer generation without using its ordering anchor.
25
+ * @param spec - current Turn process specification.
26
+ * @returns stable identity until the finalized answer Step is withdrawn or replaced.
27
+ */
28
+ export declare function turnProcessGeneration(spec: TurnProcessSpec): TurnProcessGeneration;
29
+ /**
30
+ * Encode one process specification as a primitive Location-data value.
31
+ * @param spec - current Turn process specification.
32
+ * @returns reference-stable scalar for equal specifications.
33
+ */
34
+ export declare function encodeTurnProcess(spec: TurnProcessSpec): TurnProcessSignature;
35
+ /**
36
+ * Decode a same-process signature produced by {@link encodeTurnProcess}.
37
+ * @param signature - encoded Turn process value.
38
+ * @returns decoded process specification.
39
+ */
40
+ export declare function decodeTurnProcess(signature: TurnProcessSignature): TurnProcessSpec;
41
+ /**
42
+ * Recognize the shipped subagent delegation name and its configured variants.
43
+ * Control tools use distinct names such as `send_message` and `list_agents`.
44
+ * @param name - durable Tool-call name.
45
+ * @returns whether the call creates or forks a subagent.
46
+ */
47
+ export declare function isSubagentDelegationTool(name: string): boolean;
48
+ //# sourceMappingURL=turn-process.d.ts.map
@@ -0,0 +1,37 @@
1
+ import type { Context } from '@prettier-ai/cordis';
2
+ import type { ConversationMatch, ConversationNodeDefinition } from '@prettier-ai/dsh-client-ui-conversation/client';
3
+ import type { AssistantChatData } from '../contract/chat-nodes.ts';
4
+ import type { AssistantBlock } from '../contract/snapshot.ts';
5
+ declare module '../contract/chat-nodes.ts' {
6
+ interface ChatNodeDataMap {
7
+ /** Streaming, settled, or interrupted Assistant step. */
8
+ 'assistant-step': AssistantChatData;
9
+ }
10
+ }
11
+ declare module '@prettier-ai/dsh-client-ui-conversation/client' {
12
+ interface ConversationStepDataMap {
13
+ /** Streaming, settled, or interrupted Assistant material for this Step. */
14
+ 'assistant-step': AssistantChatData;
15
+ }
16
+ }
17
+ interface AssistantState {
18
+ readonly turn: number;
19
+ readonly step: number;
20
+ readonly blocks: readonly (AssistantBlock | undefined)[];
21
+ readonly visibleBlocks: number;
22
+ readonly firstVisibleSeq: number | undefined;
23
+ readonly firstVisibleTime: number | undefined;
24
+ readonly firstTokenTime: number | undefined;
25
+ readonly hidden: boolean;
26
+ readonly final: ConversationMatch | undefined;
27
+ readonly usage: unknown;
28
+ }
29
+ /** Per-step Assistant streaming/final/interruption Definition. */
30
+ export declare const assistantDefinition: ConversationNodeDefinition<AssistantState>;
31
+ /**
32
+ * Register the Assistant lifecycle business contribution.
33
+ * @param ctx - owning UI Conversation context.
34
+ */
35
+ export declare function registerAssistantConversationNode(ctx: Context): void;
36
+ export {};
37
+ //# sourceMappingURL=assistant.d.ts.map