@tangle-network/ui 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +21 -0
  3. package/README.md +33 -0
  4. package/dist/active-sessions-store-CeOmXgv5.d.ts +85 -0
  5. package/dist/artifact-pane-DvJyPWV4.d.ts +24 -0
  6. package/dist/auth.d.ts +74 -0
  7. package/dist/auth.js +15 -0
  8. package/dist/button-CMQuQEW_.d.ts +17 -0
  9. package/dist/chat.d.ts +232 -0
  10. package/dist/chat.js +30 -0
  11. package/dist/chunk-2NFQRQOD.js +1009 -0
  12. package/dist/chunk-2VH6PUXD.js +186 -0
  13. package/dist/chunk-34A66VBG.js +214 -0
  14. package/dist/chunk-3OI2QKFD.js +0 -0
  15. package/dist/chunk-4CLN43XT.js +45 -0
  16. package/dist/chunk-54SQQMMM.js +156 -0
  17. package/dist/chunk-5Z5ZYMOJ.js +0 -0
  18. package/dist/chunk-66BNMOVT.js +167 -0
  19. package/dist/chunk-6BGQA4BQ.js +0 -0
  20. package/dist/chunk-7UO2ZMRQ.js +133 -0
  21. package/dist/chunk-BX6AQMUS.js +183 -0
  22. package/dist/chunk-CD53GZOM.js +59 -0
  23. package/dist/chunk-CSAIKY36.js +54 -0
  24. package/dist/chunk-EEE55AVS.js +1201 -0
  25. package/dist/chunk-GYPQXTJU.js +230 -0
  26. package/dist/chunk-HFL6R6IF.js +37 -0
  27. package/dist/chunk-HJKCSXCH.js +737 -0
  28. package/dist/chunk-LISXUB4D.js +1222 -0
  29. package/dist/chunk-LQS34IGP.js +0 -0
  30. package/dist/chunk-MKTSMWVD.js +109 -0
  31. package/dist/chunk-NKDZ7GZE.js +192 -0
  32. package/dist/chunk-OEX7NZE3.js +321 -0
  33. package/dist/chunk-Q56BYXQF.js +61 -0
  34. package/dist/chunk-Q7EIIWTC.js +0 -0
  35. package/dist/chunk-REJESC5U.js +117 -0
  36. package/dist/chunk-RQGKSCEZ.js +0 -0
  37. package/dist/chunk-RQHJBTEU.js +10 -0
  38. package/dist/chunk-TMFOPHHN.js +299 -0
  39. package/dist/chunk-XGKULLYE.js +40 -0
  40. package/dist/chunk-XIHMJ7ZQ.js +614 -0
  41. package/dist/chunk-YJ2G3XO5.js +1048 -0
  42. package/dist/chunk-YNN4O57I.js +754 -0
  43. package/dist/code-block-DjXf8eOG.d.ts +19 -0
  44. package/dist/document-editor-pane-A5LT5H4N.js +12 -0
  45. package/dist/document-editor-pane-DyDEX_Zm.d.ts +124 -0
  46. package/dist/editor.d.ts +120 -0
  47. package/dist/editor.js +34 -0
  48. package/dist/files.d.ts +175 -0
  49. package/dist/files.js +20 -0
  50. package/dist/hooks.d.ts +56 -0
  51. package/dist/hooks.js +41 -0
  52. package/dist/index.d.ts +43 -0
  53. package/dist/index.js +446 -0
  54. package/dist/markdown.d.ts +15 -0
  55. package/dist/markdown.js +14 -0
  56. package/dist/message-BHWbxBtT.d.ts +15 -0
  57. package/dist/openui.d.ts +115 -0
  58. package/dist/openui.js +12 -0
  59. package/dist/parts-dj7AcUg0.d.ts +36 -0
  60. package/dist/primitives.d.ts +332 -0
  61. package/dist/primitives.js +191 -0
  62. package/dist/run-PfLmDAox.d.ts +41 -0
  63. package/dist/run.d.ts +69 -0
  64. package/dist/run.js +36 -0
  65. package/dist/sdk-hooks.d.ts +285 -0
  66. package/dist/sdk-hooks.js +31 -0
  67. package/dist/stores.d.ts +17 -0
  68. package/dist/stores.js +76 -0
  69. package/dist/tool-call-feed-Bs3MyQMT.d.ts +68 -0
  70. package/dist/tool-display-z4JcDmMQ.d.ts +32 -0
  71. package/dist/tool-previews.d.ts +48 -0
  72. package/dist/tool-previews.js +21 -0
  73. package/dist/types.d.ts +19 -0
  74. package/dist/types.js +1 -0
  75. package/dist/utils.d.ts +45 -0
  76. package/dist/utils.js +32 -0
  77. package/package.json +193 -0
  78. package/src/auth/auth.tsx +228 -0
  79. package/src/auth/index.ts +13 -0
  80. package/src/auth/login-layout.tsx +46 -0
  81. package/src/chat/agent-timeline.stories.tsx +429 -0
  82. package/src/chat/agent-timeline.tsx +360 -0
  83. package/src/chat/chat-container.tsx +486 -0
  84. package/src/chat/chat-input.stories.tsx +142 -0
  85. package/src/chat/chat-input.tsx +389 -0
  86. package/src/chat/chat-message.stories.tsx +237 -0
  87. package/src/chat/chat-message.tsx +129 -0
  88. package/src/chat/index.ts +18 -0
  89. package/src/chat/message-list.stories.tsx +336 -0
  90. package/src/chat/message-list.tsx +79 -0
  91. package/src/chat/thinking-indicator.stories.tsx +56 -0
  92. package/src/chat/thinking-indicator.tsx +30 -0
  93. package/src/chat/user-message.stories.tsx +92 -0
  94. package/src/chat/user-message.tsx +43 -0
  95. package/src/editor/document-editor-pane.tsx +351 -0
  96. package/src/editor/editor-provider.tsx +428 -0
  97. package/src/editor/editor-toolbar.tsx +130 -0
  98. package/src/editor/index.ts +31 -0
  99. package/src/editor/markdown-conversion.ts +21 -0
  100. package/src/editor/markdown-document-editor.tsx +137 -0
  101. package/src/editor/tiptap-editor.tsx +331 -0
  102. package/src/editor/use-editor.ts +221 -0
  103. package/src/files/file-artifact-pane.tsx +183 -0
  104. package/src/files/file-preview.tsx +342 -0
  105. package/src/files/file-tabs.tsx +71 -0
  106. package/src/files/file-tree.tsx +258 -0
  107. package/src/files/index.ts +17 -0
  108. package/src/files/rich-file-tree.stories.tsx +104 -0
  109. package/src/files/rich-file-tree.test.tsx +42 -0
  110. package/src/files/rich-file-tree.tsx +232 -0
  111. package/src/hooks/index.ts +10 -0
  112. package/src/hooks/use-auth.ts +153 -0
  113. package/src/hooks/use-auto-scroll.ts +59 -0
  114. package/src/hooks/use-dropdown-menu.ts +40 -0
  115. package/src/hooks/use-live-time.test.tsx +40 -0
  116. package/src/hooks/use-live-time.ts +27 -0
  117. package/src/hooks/use-realtime-session.ts +319 -0
  118. package/src/hooks/use-run-collapse-state.ts +25 -0
  119. package/src/hooks/use-run-groups.ts +111 -0
  120. package/src/hooks/use-sdk-session.ts +575 -0
  121. package/src/hooks/use-sse-stream.ts +475 -0
  122. package/src/hooks/use-tool-call-stream.ts +96 -0
  123. package/src/index.ts +14 -0
  124. package/src/lib/utils.ts +6 -0
  125. package/src/markdown/code-block.tsx +198 -0
  126. package/src/markdown/index.ts +2 -0
  127. package/src/markdown/markdown.stories.tsx +190 -0
  128. package/src/markdown/markdown.tsx +62 -0
  129. package/src/openui/index.ts +20 -0
  130. package/src/openui/openui-artifact-renderer.tsx +542 -0
  131. package/src/primitives/artifact-pane.tsx +91 -0
  132. package/src/primitives/avatar.stories.tsx +95 -0
  133. package/src/primitives/avatar.tsx +47 -0
  134. package/src/primitives/badge.stories.tsx +57 -0
  135. package/src/primitives/badge.tsx +97 -0
  136. package/src/primitives/button.stories.tsx +48 -0
  137. package/src/primitives/button.tsx +115 -0
  138. package/src/primitives/card.stories.tsx +53 -0
  139. package/src/primitives/card.tsx +98 -0
  140. package/src/primitives/code-block.stories.tsx +115 -0
  141. package/src/primitives/code-block.tsx +22 -0
  142. package/src/primitives/design-tokens.stories.tsx +162 -0
  143. package/src/primitives/dialog.stories.tsx +176 -0
  144. package/src/primitives/dialog.tsx +137 -0
  145. package/src/primitives/drop-zone.stories.tsx +123 -0
  146. package/src/primitives/drop-zone.tsx +131 -0
  147. package/src/primitives/dropdown-menu.stories.tsx +122 -0
  148. package/src/primitives/dropdown-menu.tsx +214 -0
  149. package/src/primitives/empty-state.stories.tsx +81 -0
  150. package/src/primitives/empty-state.tsx +40 -0
  151. package/src/primitives/index.ts +118 -0
  152. package/src/primitives/input.stories.tsx +113 -0
  153. package/src/primitives/input.tsx +136 -0
  154. package/src/primitives/label.stories.tsx +84 -0
  155. package/src/primitives/label.tsx +24 -0
  156. package/src/primitives/progress.stories.tsx +93 -0
  157. package/src/primitives/progress.tsx +50 -0
  158. package/src/primitives/segmented-control.test.tsx +328 -0
  159. package/src/primitives/segmented-control.tsx +154 -0
  160. package/src/primitives/select.stories.tsx +164 -0
  161. package/src/primitives/select.tsx +158 -0
  162. package/src/primitives/sidebar-drop-zone.stories.tsx +100 -0
  163. package/src/primitives/sidebar-drop-zone.tsx +149 -0
  164. package/src/primitives/skeleton.stories.tsx +79 -0
  165. package/src/primitives/skeleton.tsx +55 -0
  166. package/src/primitives/stat-card.stories.tsx +137 -0
  167. package/src/primitives/stat-card.tsx +97 -0
  168. package/src/primitives/switch.stories.tsx +85 -0
  169. package/src/primitives/switch.tsx +28 -0
  170. package/src/primitives/table.stories.tsx +170 -0
  171. package/src/primitives/table.tsx +116 -0
  172. package/src/primitives/tabs.stories.tsx +180 -0
  173. package/src/primitives/tabs.tsx +71 -0
  174. package/src/primitives/terminal-display.stories.tsx +191 -0
  175. package/src/primitives/terminal-display.tsx +189 -0
  176. package/src/primitives/theme-toggle.stories.tsx +32 -0
  177. package/src/primitives/theme-toggle.tsx +96 -0
  178. package/src/primitives/toast.stories.tsx +155 -0
  179. package/src/primitives/toast.tsx +190 -0
  180. package/src/primitives/upload-progress.stories.tsx +120 -0
  181. package/src/primitives/upload-progress.tsx +110 -0
  182. package/src/run/expanded-tool-detail.stories.tsx +182 -0
  183. package/src/run/expanded-tool-detail.tsx +186 -0
  184. package/src/run/index.ts +13 -0
  185. package/src/run/inline-thinking-item.stories.tsx +136 -0
  186. package/src/run/inline-thinking-item.tsx +120 -0
  187. package/src/run/inline-tool-item.stories.tsx +222 -0
  188. package/src/run/inline-tool-item.tsx +190 -0
  189. package/src/run/run-group.stories.tsx +322 -0
  190. package/src/run/run-group.tsx +569 -0
  191. package/src/run/run-item-primitives.tsx +17 -0
  192. package/src/run/tool-call-feed.stories.tsx +294 -0
  193. package/src/run/tool-call-feed.tsx +192 -0
  194. package/src/run/tool-call-step.stories.tsx +198 -0
  195. package/src/run/tool-call-step.tsx +240 -0
  196. package/src/sdk-hooks.ts +38 -0
  197. package/src/stores/active-sessions-store.ts +455 -0
  198. package/src/stores/chat-store.ts +43 -0
  199. package/src/stores/index.ts +2 -0
  200. package/src/tool-previews/command-preview.tsx +116 -0
  201. package/src/tool-previews/diff-preview.tsx +85 -0
  202. package/src/tool-previews/glob-results-preview.tsx +98 -0
  203. package/src/tool-previews/grep-results-preview.tsx +157 -0
  204. package/src/tool-previews/index.ts +22 -0
  205. package/src/tool-previews/preview-primitives.tsx +84 -0
  206. package/src/tool-previews/question-preview.tsx +101 -0
  207. package/src/tool-previews/web-search-preview.tsx +117 -0
  208. package/src/tool-previews/write-file-preview.tsx +80 -0
  209. package/src/types/branding.ts +11 -0
  210. package/src/types/index.ts +5 -0
  211. package/src/types/message.ts +13 -0
  212. package/src/types/parts.ts +51 -0
  213. package/src/types/run.ts +56 -0
  214. package/src/types/tool-display.ts +41 -0
  215. package/src/utils/copy-text.ts +30 -0
  216. package/src/utils/format.test.ts +43 -0
  217. package/src/utils/format.ts +56 -0
  218. package/src/utils/index.ts +10 -0
  219. package/src/utils/time-ago.ts +9 -0
  220. package/src/utils/tool-display.ts +238 -0
@@ -0,0 +1,285 @@
1
+ import * as React from 'react';
2
+ import { RefObject } from 'react';
3
+ import { R as Run, G as GroupedMessage } from './run-PfLmDAox.js';
4
+ import { S as SessionMessage } from './message-BHWbxBtT.js';
5
+ import { S as SessionPart } from './parts-dj7AcUg0.js';
6
+ import { R as RegisterActiveSessionOptions, g as ActiveSessionTransportMode, c as ActiveSessionConnectionState } from './active-sessions-store-CeOmXgv5.js';
7
+ import { F as FeedSegment } from './tool-call-feed-Bs3MyQMT.js';
8
+ import 'nanostores';
9
+ import 'react/jsx-runtime';
10
+
11
+ /**
12
+ * Scroll-to-bottom behaviour: sticks to the bottom while streaming,
13
+ * pauses when user scrolls up, resumes when user scrolls back down.
14
+ */
15
+ declare function useAutoScroll(containerRef: RefObject<HTMLElement | null>, deps?: unknown[]): {
16
+ isAtBottom: boolean;
17
+ scrollToBottom: () => void;
18
+ };
19
+
20
+ interface UseDropdownMenuOptions {
21
+ closeOnEsc?: boolean;
22
+ }
23
+ declare function useDropdownMenu(options?: UseDropdownMenuOptions): {
24
+ open: boolean;
25
+ setOpen: React.Dispatch<React.SetStateAction<boolean>>;
26
+ ref: React.RefObject<HTMLDivElement | null>;
27
+ toggle: () => void;
28
+ close: () => void;
29
+ };
30
+
31
+ /**
32
+ * Manages per-run collapse state with auto-collapse after run completion.
33
+ *
34
+ * - Runs stay expanded by default
35
+ * - Collapse is manual only
36
+ */
37
+ declare function useRunCollapseState(runs: Run[]): {
38
+ isCollapsed: (runId: string) => boolean;
39
+ toggleCollapse: (runId: string) => void;
40
+ };
41
+
42
+ interface UseRunGroupsOptions {
43
+ messages: SessionMessage[];
44
+ partMap: Record<string, SessionPart[]>;
45
+ isStreaming: boolean;
46
+ }
47
+ declare function useRunGroups({ messages, partMap, isStreaming, }: UseRunGroupsOptions): GroupedMessage[];
48
+
49
+ /**
50
+ * useToolCallStream — parses SSE events into ToolCallFeed segments.
51
+ *
52
+ * Takes raw SSE event data from the orchestrator stream and produces
53
+ * structured FeedSegments that ToolCallFeed can render.
54
+ */
55
+
56
+ interface UseToolCallStreamReturn {
57
+ /** Current feed segments (text + tool calls interleaved) */
58
+ segments: FeedSegment[];
59
+ /** Push a raw SSE event into the stream */
60
+ pushEvent: (event: {
61
+ type: string;
62
+ data: Record<string, unknown>;
63
+ }) => void;
64
+ /** Push a text delta (from message.part.updated) */
65
+ pushText: (delta: string) => void;
66
+ /** Mark a tool call as complete */
67
+ completeToolCall: (id: string, result: {
68
+ output?: string;
69
+ error?: string;
70
+ duration?: number;
71
+ }) => void;
72
+ /** Reset the stream */
73
+ reset: () => void;
74
+ }
75
+ declare function useToolCallStream(): UseToolCallStreamReturn;
76
+
77
+ interface SdkSessionAttachment {
78
+ name: string;
79
+ size?: number;
80
+ }
81
+ interface SdkSessionSeed {
82
+ id: string;
83
+ role: SessionMessage["role"];
84
+ createdAt?: number | string | Date;
85
+ content?: string;
86
+ attachments?: SdkSessionAttachment[];
87
+ parts?: SessionPart[];
88
+ }
89
+ interface SdkSessionEvent {
90
+ type: string;
91
+ data?: Record<string, unknown>;
92
+ }
93
+ interface BeginAssistantMessageOptions {
94
+ id?: string;
95
+ role?: Extract<SessionMessage["role"], "assistant" | "system">;
96
+ createdAt?: number | string | Date;
97
+ }
98
+ interface AppendUserMessageOptions {
99
+ id?: string;
100
+ role?: Extract<SessionMessage["role"], "user" | "system">;
101
+ content: string;
102
+ createdAt?: number | string | Date;
103
+ attachments?: SdkSessionAttachment[];
104
+ }
105
+ interface CompleteAssistantMessageOptions {
106
+ messageId?: string;
107
+ finalText?: string;
108
+ }
109
+ interface ApplySdkEventOptions {
110
+ messageId?: string;
111
+ }
112
+ interface UseSdkSessionOptions {
113
+ initialMessages?: SdkSessionSeed[];
114
+ }
115
+ interface UseSdkSessionReturn {
116
+ messages: SessionMessage[];
117
+ partMap: Record<string, SessionPart[]>;
118
+ isStreaming: boolean;
119
+ activeAssistantMessageId: string | null;
120
+ replaceHistory: (messages: SdkSessionSeed[]) => void;
121
+ appendUserMessage: (message: AppendUserMessageOptions) => string;
122
+ beginAssistantMessage: (options?: BeginAssistantMessageOptions) => string;
123
+ applySdkEvent: (event: SdkSessionEvent, options?: ApplySdkEventOptions) => void;
124
+ completeAssistantMessage: (options?: CompleteAssistantMessageOptions) => void;
125
+ failAssistantMessage: (error: string, options?: {
126
+ messageId?: string;
127
+ }) => void;
128
+ setStreaming: (value: boolean) => void;
129
+ reset: () => void;
130
+ }
131
+ declare function useSdkSession({ initialMessages, }?: UseSdkSessionOptions): UseSdkSessionReturn;
132
+
133
+ interface RealtimeSessionOptions extends RegisterActiveSessionOptions {
134
+ connectUrl?: string | null;
135
+ enabled?: boolean;
136
+ foreground?: boolean;
137
+ keepRegistered?: boolean;
138
+ reconnect?: boolean;
139
+ reconnectIntervalMs?: number;
140
+ maxReconnectAttempts?: number;
141
+ transportMode?: ActiveSessionTransportMode;
142
+ onEvent?: (event: SdkSessionEvent) => void;
143
+ onOpen?: () => void;
144
+ onClose?: () => void;
145
+ onError?: (error: Error) => void;
146
+ }
147
+ interface RealtimeSessionState {
148
+ connectionState: ActiveSessionConnectionState;
149
+ lastError: string | null;
150
+ reconnectAttempts: number;
151
+ isConnected: boolean;
152
+ }
153
+ interface RealtimeSessionTarget extends RealtimeSessionOptions {
154
+ key?: string;
155
+ }
156
+ interface RealtimeSessionRegistryProps {
157
+ sessions: RealtimeSessionTarget[];
158
+ }
159
+ declare function useRealtimeSession({ sessionId, projectId, projectLabel, title, href, metadata, connectUrl, enabled, foreground, keepRegistered, reconnect, reconnectIntervalMs, maxReconnectAttempts, transportMode, onEvent, onOpen, onClose, onError, }: RealtimeSessionOptions): RealtimeSessionState;
160
+ declare function RealtimeSessionRegistry({ sessions }: RealtimeSessionRegistryProps): React.FunctionComponentElement<RealtimeSessionTarget>[];
161
+
162
+ /**
163
+ * SSE Event data structure
164
+ */
165
+ interface SSEEvent<T = unknown> {
166
+ id?: string;
167
+ event: string;
168
+ data: T;
169
+ timestamp: number;
170
+ }
171
+ /**
172
+ * Connection state for SSE streams
173
+ */
174
+ type ConnectionState = "connecting" | "connected" | "reconnecting" | "disconnected" | "error";
175
+ /**
176
+ * SSE stream options
177
+ */
178
+ interface UseSSEStreamOptions<T = unknown> {
179
+ /** URL to connect to */
180
+ url: string;
181
+ /** Authorization header value */
182
+ authToken?: string;
183
+ /** Enable automatic reconnection (default: true) */
184
+ autoReconnect?: boolean;
185
+ /** Max reconnection attempts (default: 5) */
186
+ maxRetries?: number;
187
+ /** Base delay between reconnects in ms (default: 1000) */
188
+ reconnectDelay?: number;
189
+ /** Event types to listen for (default: all) */
190
+ eventTypes?: string[];
191
+ /** Callback for each event */
192
+ onEvent?: (event: SSEEvent<T>) => void;
193
+ /** Callback on connection state change */
194
+ onStateChange?: (state: ConnectionState) => void;
195
+ /** Callback on error */
196
+ onError?: (error: Error) => void;
197
+ /** Custom headers */
198
+ headers?: Record<string, string>;
199
+ /** Whether to start connected (default: true) */
200
+ enabled?: boolean;
201
+ }
202
+ /**
203
+ * SSE stream result
204
+ */
205
+ interface UseSSEStreamResult<T = unknown> {
206
+ /** Current connection state */
207
+ state: ConnectionState;
208
+ /** All received events */
209
+ events: SSEEvent<T>[];
210
+ /** Most recent event */
211
+ lastEvent: SSEEvent<T> | null;
212
+ /** Error if any */
213
+ error: Error | null;
214
+ /** Manually connect */
215
+ connect: () => void;
216
+ /** Manually disconnect */
217
+ disconnect: () => void;
218
+ /** Clear events buffer */
219
+ clearEvents: () => void;
220
+ /** Retry count */
221
+ retryCount: number;
222
+ /** Time since last event (ms) */
223
+ timeSinceLastEvent: number;
224
+ }
225
+ /**
226
+ * React hook for consuming SSE streams with automatic reconnection,
227
+ * event buffering, and state management.
228
+ *
229
+ * @example
230
+ * ```tsx
231
+ * const { events, state, lastEvent } = useSSEStream({
232
+ * url: '/api/v1/tasks/123/stream',
233
+ * authToken: 'Bearer xxx',
234
+ * onEvent: (e) => console.log('Event:', e),
235
+ * });
236
+ *
237
+ * return (
238
+ * <div>
239
+ * <p>Status: {state}</p>
240
+ * {events.map((e, i) => (
241
+ * <div key={i}>{e.event}: {JSON.stringify(e.data)}</div>
242
+ * ))}
243
+ * </div>
244
+ * );
245
+ * ```
246
+ */
247
+ declare function useSSEStream<T = unknown>(options: UseSSEStreamOptions<T>): UseSSEStreamResult<T>;
248
+ /**
249
+ * Typed event types for common streaming scenarios
250
+ */
251
+ interface TaskStreamEvent {
252
+ task_id: string;
253
+ status?: string;
254
+ progress?: number;
255
+ message?: string;
256
+ result?: unknown;
257
+ error?: string;
258
+ }
259
+ interface AgentStreamEvent {
260
+ type: "message.updated" | "tool_call" | "tool_result" | "llm_response" | "error" | "session.idle" | "execution.started" | "execution.result";
261
+ data: unknown;
262
+ timestamp?: number;
263
+ }
264
+ interface TerminalStreamEvent {
265
+ type: "output" | "input" | "error" | "exit";
266
+ data: string;
267
+ timestamp: number;
268
+ }
269
+ interface AutomationStreamEvent {
270
+ automation_id: string;
271
+ event_id?: string;
272
+ status?: string;
273
+ variant_id?: string;
274
+ output?: string;
275
+ action_result?: unknown;
276
+ error?: string;
277
+ }
278
+ interface BotStreamEvent {
279
+ bot_id: string;
280
+ type: "balance" | "trade" | "decision" | "log" | "error";
281
+ data: unknown;
282
+ timestamp: number;
283
+ }
284
+
285
+ export { type AgentStreamEvent, type AppendUserMessageOptions, type ApplySdkEventOptions, type AutomationStreamEvent, type BeginAssistantMessageOptions, type BotStreamEvent, type CompleteAssistantMessageOptions, type ConnectionState, type RealtimeSessionOptions, RealtimeSessionRegistry, type RealtimeSessionRegistryProps, type RealtimeSessionState, type RealtimeSessionTarget, type SSEEvent, type SdkSessionAttachment, type SdkSessionEvent, type SdkSessionSeed, type TaskStreamEvent, type TerminalStreamEvent, type UseRunGroupsOptions, type UseSSEStreamOptions, type UseSSEStreamResult, type UseSdkSessionOptions, type UseSdkSessionReturn, type UseToolCallStreamReturn, useAutoScroll, useDropdownMenu, useRealtimeSession, useRunCollapseState, useRunGroups, useSSEStream, useSdkSession, useToolCallStream };
@@ -0,0 +1,31 @@
1
+ import {
2
+ RealtimeSessionRegistry,
3
+ useDropdownMenu,
4
+ useRealtimeSession,
5
+ useSSEStream,
6
+ useSdkSession,
7
+ useToolCallStream
8
+ } from "./chunk-YJ2G3XO5.js";
9
+ import "./chunk-OEX7NZE3.js";
10
+ import {
11
+ useAutoScroll,
12
+ useRunCollapseState,
13
+ useRunGroups
14
+ } from "./chunk-54SQQMMM.js";
15
+ import "./chunk-7UO2ZMRQ.js";
16
+ import "./chunk-2VH6PUXD.js";
17
+ import "./chunk-BX6AQMUS.js";
18
+ import "./chunk-CD53GZOM.js";
19
+ import "./chunk-66BNMOVT.js";
20
+ import "./chunk-RQHJBTEU.js";
21
+ export {
22
+ RealtimeSessionRegistry,
23
+ useAutoScroll,
24
+ useDropdownMenu,
25
+ useRealtimeSession,
26
+ useRunCollapseState,
27
+ useRunGroups,
28
+ useSSEStream,
29
+ useSdkSession,
30
+ useToolCallStream
31
+ };
@@ -0,0 +1,17 @@
1
+ export { A as ActiveProjectActivity, a as ActiveSessionActivityOptions, b as ActiveSessionConnectionOptions, c as ActiveSessionConnectionState, d as ActiveSessionReconnectState, e as ActiveSessionRecord, f as ActiveSessionStatus, g as ActiveSessionTransportMode, h as ActiveSessionsState, R as RegisterActiveSessionOptions, S as SessionProjectKey, i as activeSessionsAtom, j as bumpActiveSessionActivity, k as getActiveSession, l as getAllActiveSessions, m as getAllProjectActivity, n as getSessionsByActivity, o as getSessionsForNavbar, p as getSessionsForProject, q as getTotalRunningSessionCount, r as hasBackgroundRunningSessions, s as registerActiveSession, t as resetActiveSessions, u as setActiveSessionAttention, v as setActiveSessionConnection, w as setActiveSessionError, x as setActiveSessionRunning, y as setForegroundActiveSession, z as unregisterActiveSession, B as updateActiveSessionMeta, C as useActiveSession, D as useActiveSessions, E as useActiveSessionsState, F as useHasBackgroundRunningSessions, G as useNavbarSessions, H as useProjectActivity, I as useProjectSessions, J as useSessionsByActivity, K as useTotalRunningSessions } from './active-sessions-store-CeOmXgv5.js';
2
+ import * as nanostores from 'nanostores';
3
+ import { S as SessionMessage } from './message-BHWbxBtT.js';
4
+ import { S as SessionPart } from './parts-dj7AcUg0.js';
5
+
6
+ /** Ordered list of messages in the current chat session. */
7
+ declare const messagesAtom: nanostores.PreinitializedWritableAtom<SessionMessage[]> & object;
8
+ /** Map of message ID → parts for that message. */
9
+ declare const partMapAtom: nanostores.PreinitializedMapStore<Record<string, SessionPart[]>> & object;
10
+ /** Whether the assistant is currently streaming a response. */
11
+ declare const isStreamingAtom: nanostores.PreinitializedWritableAtom<boolean> & object;
12
+ declare function addMessage(msg: SessionMessage): void;
13
+ declare function addParts(messageId: string, parts: SessionPart[]): void;
14
+ declare function updatePart(messageId: string, partIndex: number, part: SessionPart): void;
15
+ declare function clearChat(): void;
16
+
17
+ export { addMessage, addParts, clearChat, isStreamingAtom, messagesAtom, partMapAtom, updatePart };
package/dist/stores.js ADDED
@@ -0,0 +1,76 @@
1
+ import {
2
+ addMessage,
3
+ addParts,
4
+ clearChat,
5
+ isStreamingAtom,
6
+ messagesAtom,
7
+ partMapAtom,
8
+ updatePart
9
+ } from "./chunk-HFL6R6IF.js";
10
+ import {
11
+ activeSessionsAtom,
12
+ bumpActiveSessionActivity,
13
+ getActiveSession,
14
+ getAllActiveSessions,
15
+ getAllProjectActivity,
16
+ getSessionsByActivity,
17
+ getSessionsForNavbar,
18
+ getSessionsForProject,
19
+ getTotalRunningSessionCount,
20
+ hasBackgroundRunningSessions,
21
+ registerActiveSession,
22
+ resetActiveSessions,
23
+ setActiveSessionAttention,
24
+ setActiveSessionConnection,
25
+ setActiveSessionError,
26
+ setActiveSessionRunning,
27
+ setForegroundActiveSession,
28
+ unregisterActiveSession,
29
+ updateActiveSessionMeta,
30
+ useActiveSession,
31
+ useActiveSessions,
32
+ useActiveSessionsState,
33
+ useHasBackgroundRunningSessions,
34
+ useNavbarSessions,
35
+ useProjectActivity,
36
+ useProjectSessions,
37
+ useSessionsByActivity,
38
+ useTotalRunningSessions
39
+ } from "./chunk-OEX7NZE3.js";
40
+ export {
41
+ activeSessionsAtom,
42
+ addMessage,
43
+ addParts,
44
+ bumpActiveSessionActivity,
45
+ clearChat,
46
+ getActiveSession,
47
+ getAllActiveSessions,
48
+ getAllProjectActivity,
49
+ getSessionsByActivity,
50
+ getSessionsForNavbar,
51
+ getSessionsForProject,
52
+ getTotalRunningSessionCount,
53
+ hasBackgroundRunningSessions,
54
+ isStreamingAtom,
55
+ messagesAtom,
56
+ partMapAtom,
57
+ registerActiveSession,
58
+ resetActiveSessions,
59
+ setActiveSessionAttention,
60
+ setActiveSessionConnection,
61
+ setActiveSessionError,
62
+ setActiveSessionRunning,
63
+ setForegroundActiveSession,
64
+ unregisterActiveSession,
65
+ updateActiveSessionMeta,
66
+ updatePart,
67
+ useActiveSession,
68
+ useActiveSessions,
69
+ useActiveSessionsState,
70
+ useHasBackgroundRunningSessions,
71
+ useNavbarSessions,
72
+ useProjectActivity,
73
+ useProjectSessions,
74
+ useSessionsByActivity,
75
+ useTotalRunningSessions
76
+ };
@@ -0,0 +1,68 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+
4
+ type ToolCallType = "bash" | "read" | "write" | "edit" | "glob" | "grep" | "list" | "download" | "inspect" | "audit" | "unknown";
5
+ type ToolCallStatus = "running" | "success" | "error";
6
+ interface ToolCallStepProps {
7
+ type: ToolCallType;
8
+ label: string;
9
+ status: ToolCallStatus;
10
+ detail?: string;
11
+ output?: string;
12
+ /** Override syntax highlighting language; inferred from detail path if omitted */
13
+ language?: string;
14
+ duration?: number;
15
+ className?: string;
16
+ }
17
+ declare function ToolCallStep({ type, label, status, detail, output, language, duration, className, }: ToolCallStepProps): react_jsx_runtime.JSX.Element;
18
+ /**
19
+ * ToolCallGroup — groups multiple tool calls under a heading.
20
+ */
21
+ interface ToolCallGroupProps {
22
+ title?: string;
23
+ children: ReactNode;
24
+ className?: string;
25
+ }
26
+ declare function ToolCallGroup({ title, children, className }: ToolCallGroupProps): react_jsx_runtime.JSX.Element;
27
+
28
+ interface ToolCallData {
29
+ id: string;
30
+ type: ToolCallType;
31
+ label: string;
32
+ status: ToolCallStatus;
33
+ detail?: string;
34
+ output?: string;
35
+ duration?: number;
36
+ }
37
+ type FeedSegment = {
38
+ kind: "text";
39
+ content: string;
40
+ } | {
41
+ kind: "tool_call";
42
+ call: ToolCallData;
43
+ } | {
44
+ kind: "tool_group";
45
+ title?: string;
46
+ calls: ToolCallData[];
47
+ };
48
+ interface ToolCallFeedProps {
49
+ segments: FeedSegment[];
50
+ className?: string;
51
+ }
52
+ /**
53
+ * Renders a feed of interleaved text and tool calls.
54
+ */
55
+ declare function ToolCallFeed({ segments, className }: ToolCallFeedProps): react_jsx_runtime.JSX.Element | null;
56
+ /**
57
+ * Parse raw SSE tool events into FeedSegments.
58
+ *
59
+ * This is the bridge between the orchestrator's SSE stream format
60
+ * and the ToolCallFeed component. Consumers call this in their
61
+ * useToolCallStream hook.
62
+ */
63
+ declare function parseToolEvent(event: {
64
+ type: string;
65
+ data: Record<string, unknown>;
66
+ }): ToolCallData | null;
67
+
68
+ export { type FeedSegment as F, type ToolCallData as T, ToolCallFeed as a, type ToolCallFeedProps as b, ToolCallGroup as c, type ToolCallGroupProps as d, type ToolCallStatus as e, ToolCallStep as f, type ToolCallStepProps as g, type ToolCallType as h, parseToolEvent as p };
@@ -0,0 +1,32 @@
1
+ import { a as ToolPart } from './parts-dj7AcUg0.js';
2
+ import { ReactNode } from 'react';
3
+
4
+ /**
5
+ * Variant-specific rendering instructions for tool output.
6
+ * Maps directly to specialised preview components.
7
+ */
8
+ type DisplayVariant = "command" | "write-file" | "read-file" | "diff" | "question" | "web-search" | "grep" | "glob" | "default";
9
+ /**
10
+ * Custom renderer for tool details. Return a ReactNode to override the
11
+ * default ExpandedToolDetail, or null to fall back to the built-in renderer.
12
+ */
13
+ type CustomToolRenderer = (part: ToolPart) => ReactNode | null;
14
+ /**
15
+ * Visual metadata for a tool invocation — computed from the tool name,
16
+ * input, and output by `getToolDisplayMetadata()`.
17
+ */
18
+ interface ToolDisplayMetadata {
19
+ title: string;
20
+ description?: string;
21
+ inputTitle?: string;
22
+ outputTitle?: string;
23
+ inputLanguage?: string;
24
+ outputLanguage?: string;
25
+ hasDiffOutput?: boolean;
26
+ diffFilePath?: string;
27
+ displayVariant?: DisplayVariant;
28
+ commandSnippet?: string;
29
+ targetPath?: string;
30
+ }
31
+
32
+ export type { CustomToolRenderer as C, DisplayVariant as D, ToolDisplayMetadata as T };
@@ -0,0 +1,48 @@
1
+ import * as React from 'react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import { a as ToolPart } from './parts-dj7AcUg0.js';
4
+
5
+ interface CommandPreviewProps {
6
+ part: ToolPart;
7
+ }
8
+ /**
9
+ * Terminal-style command output preview.
10
+ * Shows the command, exit code, and stdout/stderr with expand/collapse.
11
+ */
12
+ declare const CommandPreview: React.MemoExoticComponent<({ part }: CommandPreviewProps) => react_jsx_runtime.JSX.Element>;
13
+
14
+ interface WriteFilePreviewProps {
15
+ part: ToolPart;
16
+ }
17
+ /**
18
+ * Preview for file write/create operations.
19
+ * Shows file path, line count, and the written content.
20
+ */
21
+ declare const WriteFilePreview: React.MemoExoticComponent<({ part }: WriteFilePreviewProps) => react_jsx_runtime.JSX.Element | null>;
22
+
23
+ interface GrepResultsPreviewProps {
24
+ part: ToolPart;
25
+ }
26
+ declare const GrepResultsPreview: React.MemoExoticComponent<({ part }: GrepResultsPreviewProps) => react_jsx_runtime.JSX.Element>;
27
+
28
+ interface GlobResultsPreviewProps {
29
+ part: ToolPart;
30
+ }
31
+ declare const GlobResultsPreview: React.MemoExoticComponent<({ part }: GlobResultsPreviewProps) => react_jsx_runtime.JSX.Element>;
32
+
33
+ interface WebSearchPreviewProps {
34
+ part: ToolPart;
35
+ }
36
+ declare const WebSearchPreview: React.MemoExoticComponent<({ part }: WebSearchPreviewProps) => react_jsx_runtime.JSX.Element>;
37
+
38
+ interface QuestionPreviewProps {
39
+ part: ToolPart;
40
+ }
41
+ declare const QuestionPreview: React.MemoExoticComponent<({ part }: QuestionPreviewProps) => react_jsx_runtime.JSX.Element>;
42
+
43
+ interface DiffPreviewProps {
44
+ part: ToolPart;
45
+ }
46
+ declare const DiffPreview: React.MemoExoticComponent<({ part }: DiffPreviewProps) => react_jsx_runtime.JSX.Element>;
47
+
48
+ export { CommandPreview, type CommandPreviewProps, DiffPreview, type DiffPreviewProps, GlobResultsPreview, type GlobResultsPreviewProps, GrepResultsPreview, type GrepResultsPreviewProps, QuestionPreview, type QuestionPreviewProps, WebSearchPreview, type WebSearchPreviewProps, WriteFilePreview, type WriteFilePreviewProps };
@@ -0,0 +1,21 @@
1
+ import "./chunk-3OI2QKFD.js";
2
+ import {
3
+ CommandPreview,
4
+ DiffPreview,
5
+ GlobResultsPreview,
6
+ GrepResultsPreview,
7
+ QuestionPreview,
8
+ WebSearchPreview,
9
+ WriteFilePreview
10
+ } from "./chunk-XIHMJ7ZQ.js";
11
+ import "./chunk-66BNMOVT.js";
12
+ import "./chunk-RQHJBTEU.js";
13
+ export {
14
+ CommandPreview,
15
+ DiffPreview,
16
+ GlobResultsPreview,
17
+ GrepResultsPreview,
18
+ QuestionPreview,
19
+ WebSearchPreview,
20
+ WriteFilePreview
21
+ };
@@ -0,0 +1,19 @@
1
+ export { S as SessionMessage } from './message-BHWbxBtT.js';
2
+ export { R as ReasoningPart, S as SessionPart, T as TextPart, a as ToolPart, b as ToolState, c as ToolStatus, d as ToolTime } from './parts-dj7AcUg0.js';
3
+ export { F as FinalTextPart, G as GroupedMessage, M as MessageRun, a as MessageUser, R as Run, b as RunStats, T as ToolCategory } from './run-PfLmDAox.js';
4
+ export { C as CustomToolRenderer, D as DisplayVariant, T as ToolDisplayMetadata } from './tool-display-z4JcDmMQ.js';
5
+ import 'react';
6
+
7
+ /** Visual branding for a run group header — injected by consuming app. */
8
+ interface AgentBranding {
9
+ label: string;
10
+ accentClass: string;
11
+ bgClass: string;
12
+ containerBgClass: string;
13
+ borderClass: string;
14
+ /** CSS class for the agent icon (legacy). Ignored when using lucide-react icons. */
15
+ iconClass: string;
16
+ textClass: string;
17
+ }
18
+
19
+ export type { AgentBranding };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ import "./chunk-6BGQA4BQ.js";
@@ -0,0 +1,45 @@
1
+ import { a as ToolPart } from './parts-dj7AcUg0.js';
2
+ import { T as ToolDisplayMetadata } from './tool-display-z4JcDmMQ.js';
3
+ import { T as ToolCategory } from './run-PfLmDAox.js';
4
+ import { ClassValue } from 'clsx';
5
+ import 'react';
6
+ import './message-BHWbxBtT.js';
7
+
8
+ /**
9
+ * Copy text to clipboard with a non-secure-context fallback.
10
+ * Returns true if a copy strategy likely succeeded.
11
+ */
12
+ declare function copyText(text: string): Promise<boolean>;
13
+
14
+ /** Format a duration in milliseconds to a human-readable string. */
15
+ declare function formatDuration(ms: number): string;
16
+ /** Truncate text to `max` characters, appending "..." if truncated. */
17
+ declare function truncateText(text: string, max: number): string;
18
+ /**
19
+ * Format an uptime duration in milliseconds with progressive
20
+ * granularity, so short-lived sandboxes don't render as "0d 0h".
21
+ * - < 60s → "Ns"
22
+ * - < 60m → "Nm Ss"
23
+ * - < 24h → "Nh Mm"
24
+ * - otherwise → "Nd Hh"
25
+ */
26
+ declare function formatUptime(ms: number): string;
27
+ /**
28
+ * Format a byte count using binary units (KiB/MiB/GiB, surfaced as
29
+ * "KB/MB/GB" for readability). KB and MB use one decimal below 10 and
30
+ * round above; GB keeps two decimals below 10 so half-GB changes stay
31
+ * visible on memory dashboards, and drops to one decimal above.
32
+ */
33
+ declare function formatBytes(bytes: number): string;
34
+
35
+ declare function timeAgo(ts: number): string;
36
+
37
+ declare const TOOL_CATEGORY_ICONS: Record<ToolCategory, string>;
38
+ declare function getToolCategory(toolName: string): ToolCategory;
39
+ declare function getToolDisplayMetadata(part: ToolPart): ToolDisplayMetadata;
40
+ /** Extract error text from a tool part, if any. */
41
+ declare function getToolErrorText(part: ToolPart, fallback?: string): string | undefined;
42
+
43
+ declare function cn(...inputs: ClassValue[]): string;
44
+
45
+ export { TOOL_CATEGORY_ICONS, cn, copyText, formatBytes, formatDuration, formatUptime, getToolCategory, getToolDisplayMetadata, getToolErrorText, timeAgo, truncateText };
package/dist/utils.js ADDED
@@ -0,0 +1,32 @@
1
+ import {
2
+ copyText,
3
+ timeAgo
4
+ } from "./chunk-XGKULLYE.js";
5
+ import {
6
+ formatBytes,
7
+ formatDuration,
8
+ formatUptime,
9
+ truncateText
10
+ } from "./chunk-4CLN43XT.js";
11
+ import {
12
+ TOOL_CATEGORY_ICONS,
13
+ getToolCategory,
14
+ getToolDisplayMetadata,
15
+ getToolErrorText
16
+ } from "./chunk-BX6AQMUS.js";
17
+ import {
18
+ cn
19
+ } from "./chunk-RQHJBTEU.js";
20
+ export {
21
+ TOOL_CATEGORY_ICONS,
22
+ cn,
23
+ copyText,
24
+ formatBytes,
25
+ formatDuration,
26
+ formatUptime,
27
+ getToolCategory,
28
+ getToolDisplayMetadata,
29
+ getToolErrorText,
30
+ timeAgo,
31
+ truncateText
32
+ };