@tangle-network/ui 11.12.0 → 11.13.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 (276) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/_virtual/_rolldown/runtime.js +13 -0
  3. package/dist/auth/auth.d.ts +53 -0
  4. package/dist/{auth-DOETfnd9.js → auth/auth.js} +7 -37
  5. package/dist/auth/login-layout.d.ts +20 -0
  6. package/dist/auth/login-layout.js +36 -0
  7. package/dist/auth.d.ts +2 -1
  8. package/dist/auth.js +2 -1
  9. package/dist/chat/agent-timeline.d.ts +83 -0
  10. package/dist/chat/agent-timeline.js +236 -0
  11. package/dist/chat/chat-container.d.ts +51 -0
  12. package/dist/chat/chat-container.js +309 -0
  13. package/dist/chat/chat-message.d.ts +22 -0
  14. package/dist/chat/chat-message.js +38 -0
  15. package/dist/chat/message-list.d.ts +32 -0
  16. package/dist/chat/message-list.js +37 -0
  17. package/dist/chat/thinking-indicator.d.ts +6 -0
  18. package/dist/chat/thinking-indicator.js +38 -0
  19. package/dist/chat/user-message.d.ts +21 -0
  20. package/dist/chat/user-message.js +42 -0
  21. package/dist/chat.d.ts +6 -1
  22. package/dist/chat.js +6 -1
  23. package/dist/editor/document-editor-pane.d.ts +37 -0
  24. package/dist/editor/document-editor-pane.js +199 -0
  25. package/dist/editor/editor-lazy.js +37 -0
  26. package/dist/editor/editor-loading.js +21 -0
  27. package/dist/editor/editor-peers.d.ts +6 -0
  28. package/dist/editor/editor-peers.js +155 -0
  29. package/dist/editor/editor-provider.d.ts +97 -0
  30. package/dist/editor/editor-provider.js +253 -0
  31. package/dist/editor/editor-toolbar.d.ts +11 -0
  32. package/dist/editor/editor-toolbar.js +106 -0
  33. package/dist/editor/markdown-conversion.js +23 -0
  34. package/dist/editor/markdown-document-editor.js +103 -0
  35. package/dist/editor/tiptap-editor.d.ts +45 -0
  36. package/dist/editor/tiptap-editor.js +271 -0
  37. package/dist/editor/use-editor.d.ts +67 -0
  38. package/dist/editor/use-editor.js +158 -0
  39. package/dist/editor.d.ts +6 -119
  40. package/dist/editor.js +5 -1
  41. package/dist/files/file-artifact-pane.d.ts +47 -0
  42. package/dist/files/file-artifact-pane.js +114 -0
  43. package/dist/files/file-format.d.ts +51 -0
  44. package/dist/{file-format-BgXbr-Ib.js → files/file-format.js} +1 -1
  45. package/dist/files/file-preview.d.ts +27 -0
  46. package/dist/files/file-preview.js +359 -0
  47. package/dist/files/file-tabs.d.ts +19 -0
  48. package/dist/files/file-tabs.js +48 -0
  49. package/dist/files/file-tree.d.ts +31 -0
  50. package/dist/files/file-tree.js +135 -0
  51. package/dist/files/rich-file-tree.d.ts +62 -0
  52. package/dist/files/rich-file-tree.js +122 -0
  53. package/dist/files.d.ts +6 -1
  54. package/dist/files.js +6 -2
  55. package/dist/hooks/use-auth.d.ts +40 -0
  56. package/dist/hooks/use-auth.js +91 -0
  57. package/dist/hooks/use-auto-scroll.d.ts +11 -0
  58. package/dist/hooks/use-auto-scroll.js +48 -0
  59. package/dist/hooks/use-dropdown-menu.d.ts +12 -0
  60. package/dist/hooks/use-dropdown-menu.js +31 -0
  61. package/dist/hooks/use-live-time.d.ts +7 -0
  62. package/dist/hooks/use-live-time.js +22 -0
  63. package/dist/hooks/use-realtime-session.d.ts +32 -0
  64. package/dist/hooks/use-realtime-session.js +235 -0
  65. package/dist/hooks/use-run-collapse-state.d.ts +13 -0
  66. package/dist/hooks/use-run-collapse-state.js +24 -0
  67. package/dist/hooks/use-run-groups.d.ts +11 -0
  68. package/dist/hooks/use-run-groups.js +85 -0
  69. package/dist/hooks/use-sdk-session.d.ts +59 -0
  70. package/dist/hooks/use-sdk-session.js +322 -0
  71. package/dist/hooks/use-sse-stream.d.ts +124 -0
  72. package/dist/hooks/use-sse-stream.js +229 -0
  73. package/dist/hooks/use-tool-call-stream.d.ts +23 -0
  74. package/dist/hooks/use-tool-call-stream.js +75 -0
  75. package/dist/hooks.d.ts +11 -49
  76. package/dist/hooks.js +10 -110
  77. package/dist/index.d.ts +99 -25
  78. package/dist/index.js +86 -36
  79. package/dist/lib/focus.d.ts +55 -0
  80. package/dist/{focus-BcE_SHqz.js → lib/focus.js} +1 -1
  81. package/dist/lib/utils.d.ts +4 -0
  82. package/dist/{utils-C_uf36nf.js → lib/utils.js} +1 -1
  83. package/dist/{code-block-B9miUPht.d.ts → markdown/code-block.d.ts} +5 -6
  84. package/dist/{code-block-B36KVUSN.js → markdown/code-block.js} +60 -55
  85. package/dist/{markdown-C0atSabr.d.ts → markdown/markdown.d.ts} +4 -5
  86. package/dist/{markdown-Db08KAYF.js → markdown/markdown.js} +3 -3
  87. package/dist/markdown.d.ts +2 -2
  88. package/dist/markdown.js +2 -2
  89. package/dist/{openui-artifact-renderer-fkBQaoLO.d.ts → openui/openui-artifact-renderer.d.ts} +20 -21
  90. package/dist/{openui-artifact-renderer-DG_i2lOR.js → openui/openui-artifact-renderer.js} +9 -7
  91. package/dist/{schema-BpW9rSSG.js → openui/schema-compiled.js} +2 -354
  92. package/dist/{schema-DAstk-J4.d.ts → openui/schema-data.d.ts} +3 -24
  93. package/dist/openui/schema-data.js +206 -0
  94. package/dist/openui-schema.d.ts +22 -3
  95. package/dist/openui-schema.js +138 -1
  96. package/dist/openui.d.ts +3 -2
  97. package/dist/openui.js +3 -2
  98. package/dist/{artifact-pane-BL_DFWNl.d.ts → primitives/artifact-pane.d.ts} +3 -4
  99. package/dist/{artifact-pane-DMXT9a8U.js → primitives/artifact-pane.js} +2 -2
  100. package/dist/primitives/avatar.d.ts +8 -0
  101. package/dist/primitives/avatar.js +25 -0
  102. package/dist/primitives/badge.d.ts +22 -0
  103. package/dist/primitives/badge.js +47 -0
  104. package/dist/{button-yoIv77e2.d.ts → primitives/button.d.ts} +2 -2
  105. package/dist/primitives/button.js +113 -0
  106. package/dist/primitives/card.d.ts +18 -0
  107. package/dist/primitives/card.js +52 -0
  108. package/dist/primitives/code-block.d.ts +6 -0
  109. package/dist/primitives/code-block.js +13 -0
  110. package/dist/primitives/dialog.d.ts +23 -0
  111. package/dist/primitives/dialog.js +59 -0
  112. package/dist/primitives/drop-zone.d.ts +23 -0
  113. package/dist/primitives/drop-zone.js +104 -0
  114. package/dist/primitives/dropdown-menu.d.ts +29 -0
  115. package/dist/{dropdown-menu-BpcLa5vF.js → primitives/dropdown-menu.js} +2 -23
  116. package/dist/primitives/empty-state.d.ts +11 -0
  117. package/dist/primitives/empty-state.js +32 -0
  118. package/dist/primitives/heading.d.ts +23 -0
  119. package/dist/primitives/heading.js +38 -0
  120. package/dist/primitives/input.d.ts +23 -0
  121. package/dist/primitives/input.js +110 -0
  122. package/dist/primitives/label.d.ts +6 -0
  123. package/dist/primitives/label.js +16 -0
  124. package/dist/primitives/metric-strip.d.ts +48 -0
  125. package/dist/primitives/metric-strip.js +52 -0
  126. package/dist/primitives/page-header.d.ts +25 -0
  127. package/dist/primitives/page-header.js +47 -0
  128. package/dist/primitives/page-shell.d.ts +14 -0
  129. package/dist/primitives/page-shell.js +17 -0
  130. package/dist/primitives/progress.d.ts +9 -0
  131. package/dist/primitives/progress.js +29 -0
  132. package/dist/primitives/segmented-control.d.ts +40 -0
  133. package/dist/primitives/segmented-control.js +57 -0
  134. package/dist/primitives/select.d.ts +15 -0
  135. package/dist/primitives/select.js +74 -0
  136. package/dist/primitives/sidebar-drop-zone.d.ts +21 -0
  137. package/dist/primitives/sidebar-drop-zone.js +88 -0
  138. package/dist/primitives/skeleton.d.ts +10 -0
  139. package/dist/primitives/skeleton.js +50 -0
  140. package/dist/primitives/stat-card.d.ts +16 -0
  141. package/dist/primitives/stat-card.js +60 -0
  142. package/dist/primitives/status-pill.d.ts +44 -0
  143. package/dist/primitives/status-pill.js +119 -0
  144. package/dist/primitives/switch.d.ts +6 -0
  145. package/dist/primitives/switch.js +16 -0
  146. package/dist/primitives/table.d.ts +22 -0
  147. package/dist/primitives/table.js +63 -0
  148. package/dist/primitives/tabs.d.ts +13 -0
  149. package/dist/{tabs-BVHR6NkO.js → primitives/tabs.js} +3 -3
  150. package/dist/primitives/terminal-display.d.ts +25 -0
  151. package/dist/primitives/terminal-display.js +109 -0
  152. package/dist/primitives/text-shimmer.d.ts +16 -0
  153. package/dist/{text-shimmer-BUUo6I-g.js → primitives/text-shimmer.js} +2 -2
  154. package/dist/primitives/theme-toggle.d.ts +11 -0
  155. package/dist/primitives/theme-toggle.js +154 -0
  156. package/dist/primitives/toast.d.ts +29 -0
  157. package/dist/primitives/toast.js +142 -0
  158. package/dist/primitives/toolbar.d.ts +55 -0
  159. package/dist/primitives/toolbar.js +37 -0
  160. package/dist/primitives/upload-progress.d.ts +23 -0
  161. package/dist/primitives/upload-progress.js +72 -0
  162. package/dist/primitives.d.ts +35 -5
  163. package/dist/primitives.js +35 -9
  164. package/dist/{index-COgqsFAQ.d.ts → redaction/redacted-document.d.ts} +6 -7
  165. package/dist/{redaction-CGGB2ENG.js → redaction/redacted-document.js} +2 -2
  166. package/dist/redaction.d.ts +1 -1
  167. package/dist/redaction.js +1 -1
  168. package/dist/run/expandable-content.js +41 -0
  169. package/dist/run/expanded-tool-detail.d.ts +12 -0
  170. package/dist/run/expanded-tool-detail.js +163 -0
  171. package/dist/run/inline-thinking-item.d.ts +11 -0
  172. package/dist/run/inline-thinking-item.js +60 -0
  173. package/dist/run/inline-tool-item.d.ts +25 -0
  174. package/dist/run/inline-tool-item.js +63 -0
  175. package/dist/run/run-group.d.ts +26 -0
  176. package/dist/{run-group-BWGeesgs.js → run/run-group.js} +9 -60
  177. package/dist/run/run-item-primitives.d.ts +5 -0
  178. package/dist/{run-ZsIKPA6J.js → run/run-item-primitives.js} +2 -2
  179. package/dist/run/run-row-shell.d.ts +53 -0
  180. package/dist/run/run-row-shell.js +114 -0
  181. package/dist/{tool-call-feed-BeB1_4pX.d.ts → run/tool-call-feed.d.ts} +7 -12
  182. package/dist/{tool-call-feed-BpmMLpPX.js → run/tool-call-feed.js} +4 -4
  183. package/dist/run/tool-call-step.d.ts +5 -0
  184. package/dist/run/tool-call-step.js +82 -0
  185. package/dist/run.d.ts +8 -2
  186. package/dist/run.js +7 -4
  187. package/dist/sdk-hooks.d.ts +8 -1
  188. package/dist/sdk-hooks.js +8 -2
  189. package/dist/stores/active-sessions-store.d.ts +83 -0
  190. package/dist/{active-sessions-store-Gt1R0rFG.js → stores/active-sessions-store.js} +1 -1
  191. package/dist/stores/chat-store.d.ts +14 -0
  192. package/dist/stores/chat-store.js +33 -0
  193. package/dist/stores.d.ts +3 -16
  194. package/dist/stores.js +2 -33
  195. package/dist/tool-previews/command-preview.d.ts +11 -0
  196. package/dist/tool-previews/command-preview.js +91 -0
  197. package/dist/tool-previews/diff-preview.d.ts +7 -0
  198. package/dist/tool-previews/diff-preview.js +76 -0
  199. package/dist/tool-previews/glob-results-preview.d.ts +7 -0
  200. package/dist/tool-previews/glob-results-preview.js +53 -0
  201. package/dist/tool-previews/grep-results-preview.d.ts +7 -0
  202. package/dist/tool-previews/grep-results-preview.js +99 -0
  203. package/dist/tool-previews/preview-primitives.js +58 -0
  204. package/dist/tool-previews/question-preview.d.ts +7 -0
  205. package/dist/tool-previews/question-preview.js +63 -0
  206. package/dist/tool-previews/web-search-preview.d.ts +7 -0
  207. package/dist/tool-previews/web-search-preview.js +78 -0
  208. package/dist/tool-previews/write-file-preview.d.ts +11 -0
  209. package/dist/tool-previews/write-file-preview.js +52 -0
  210. package/dist/tool-previews.d.ts +7 -1
  211. package/dist/tool-previews.js +7 -1
  212. package/dist/{branding-26d5ARIr.d.ts → types/branding.d.ts} +2 -3
  213. package/dist/{message-vhUI0c5G.d.ts → types/message.d.ts} +2 -3
  214. package/dist/{parts-5mhy9yJ3.d.ts → types/parts.d.ts} +8 -9
  215. package/dist/{run-OyWmIDqu.d.ts → types/run.d.ts} +9 -10
  216. package/dist/{tool-display-DgmL5rIU.d.ts → types/tool-display.d.ts} +5 -6
  217. package/dist/types.d.ts +5 -5
  218. package/dist/utils/copy-text.d.ts +7 -0
  219. package/dist/{utils-Bl_CZ0Qp.js → utils/copy-text.js} +1 -11
  220. package/dist/utils/format.d.ts +22 -0
  221. package/dist/{format-DfcLWqMa.js → utils/format.js} +1 -1
  222. package/dist/utils/time-ago.d.ts +3 -0
  223. package/dist/utils/time-ago.js +11 -0
  224. package/dist/utils/tool-display.d.ts +16 -0
  225. package/dist/{tool-display-BAuAVa43.js → utils/tool-display.js} +1 -1
  226. package/dist/utils.d.ts +6 -1
  227. package/dist/utils.js +6 -5
  228. package/package.json +2 -2
  229. package/src/files/rich-file-tree.stories.tsx +1 -1
  230. package/src/files/rich-file-tree.tsx +12 -9
  231. package/src/markdown/code-block.test.tsx +80 -2
  232. package/src/markdown/code-block.tsx +76 -80
  233. package/src/primitives/button.stories.tsx +37 -1
  234. package/src/primitives/button.test.tsx +230 -0
  235. package/src/primitives/button.tsx +62 -14
  236. package/src/primitives/card-anatomy.stories.tsx +51 -0
  237. package/src/primitives/card.test.tsx +71 -0
  238. package/src/primitives/card.tsx +25 -13
  239. package/src/primitives/heading.stories.tsx +35 -0
  240. package/src/primitives/heading.test.tsx +56 -0
  241. package/src/primitives/heading.tsx +76 -0
  242. package/src/primitives/index.ts +8 -0
  243. package/src/primitives/input.stories.tsx +28 -0
  244. package/src/primitives/input.test.tsx +161 -0
  245. package/src/primitives/input.tsx +34 -28
  246. package/src/primitives/page-header.stories.tsx +51 -0
  247. package/src/primitives/page-header.test.tsx +48 -0
  248. package/src/primitives/page-header.tsx +35 -35
  249. package/src/primitives/page-shell.stories.tsx +89 -0
  250. package/src/primitives/page-shell.test.tsx +24 -0
  251. package/src/primitives/page-shell.tsx +26 -0
  252. package/src/primitives/table-wrapper.stories.tsx +54 -0
  253. package/src/primitives/table.test.tsx +72 -0
  254. package/src/primitives/table.tsx +33 -12
  255. package/src/primitives/theme-toggle.test.tsx +167 -0
  256. package/src/primitives/theme-toggle.tsx +111 -39
  257. package/dist/active-sessions-store-nl70ZnMC.d.ts +0 -84
  258. package/dist/button-C87nEe2R.js +0 -78
  259. package/dist/chat-DDvF2oGQ.js +0 -672
  260. package/dist/diff-preview-BcK3nRXb.js +0 -533
  261. package/dist/document-editor-pane-BilJfiCo.d.ts +0 -136
  262. package/dist/document-editor-pane-POsq5Q0o.js +0 -1279
  263. package/dist/files-hywocVZz.js +0 -753
  264. package/dist/index-2UntyjBb.d.ts +0 -52
  265. package/dist/index-BgUHilZm.d.ts +0 -108
  266. package/dist/index-CJ8wRfiC.d.ts +0 -236
  267. package/dist/index-CPDET_s1.d.ts +0 -549
  268. package/dist/index-Cg6gYAqh.d.ts +0 -73
  269. package/dist/index-Cs7j8V7l.d.ts +0 -203
  270. package/dist/index-DjKxO357.d.ts +0 -128
  271. package/dist/primitives-Bx59fT-U.js +0 -1239
  272. package/dist/table-Bss73DhB.js +0 -146
  273. package/dist/tool-call-step-DNebqhmX.js +0 -434
  274. package/dist/use-auto-scroll-C5Pjeqon.js +0 -153
  275. package/dist/use-sse-stream-DjqRuDft.js +0 -884
  276. package/dist/use-sse-stream-Dm6R5YWz.d.ts +0 -282
package/dist/sdk-hooks.js CHANGED
@@ -1,3 +1,9 @@
1
- import { n as useRunCollapseState, r as useRunGroups, t as useAutoScroll } from "./use-auto-scroll-C5Pjeqon.js";
2
- import { a as useToolCallStream, i as useRealtimeSession, n as useSdkSession, o as useDropdownMenu, r as RealtimeSessionRegistry, t as useSSEStream } from "./use-sse-stream-DjqRuDft.js";
1
+ import { useRunGroups } from "./hooks/use-run-groups.js";
2
+ import { useRunCollapseState } from "./hooks/use-run-collapse-state.js";
3
+ import { useAutoScroll } from "./hooks/use-auto-scroll.js";
4
+ import { useDropdownMenu } from "./hooks/use-dropdown-menu.js";
5
+ import { useToolCallStream } from "./hooks/use-tool-call-stream.js";
6
+ import { RealtimeSessionRegistry, useRealtimeSession } from "./hooks/use-realtime-session.js";
7
+ import { useSdkSession } from "./hooks/use-sdk-session.js";
8
+ import { useSSEStream } from "./hooks/use-sse-stream.js";
3
9
  export { RealtimeSessionRegistry, useAutoScroll, useDropdownMenu, useRealtimeSession, useRunCollapseState, useRunGroups, useSSEStream, useSdkSession, useToolCallStream };
@@ -0,0 +1,83 @@
1
+ //#region src/stores/active-sessions-store.d.ts
2
+ export type SessionProjectKey = string | number;
3
+ export type ActiveSessionStatus = "idle" | "running" | "attention-needed" | "error";
4
+ export type ActiveSessionReconnectState = "idle" | "reconnecting" | "failed";
5
+ export type ActiveSessionConnectionState = "disconnected" | "connecting" | "connected" | "reconnecting" | "error";
6
+ export type ActiveSessionTransportMode = "websocket" | "sse" | "polling" | "custom";
7
+ export interface ActiveSessionRecord {
8
+ sessionId: string;
9
+ projectId: SessionProjectKey | null;
10
+ projectLabel?: string;
11
+ title?: string;
12
+ href?: string;
13
+ registeredAt: number;
14
+ lastActivityAt: number;
15
+ lastEventAt: number | null;
16
+ status: ActiveSessionStatus;
17
+ isRunning: boolean;
18
+ isForeground: boolean;
19
+ needsAttention: boolean;
20
+ connectionState: ActiveSessionConnectionState;
21
+ reconnectState: ActiveSessionReconnectState;
22
+ transportMode: ActiveSessionTransportMode | null;
23
+ lastError: string | null;
24
+ metadata?: Record<string, unknown>;
25
+ }
26
+ export interface ActiveSessionsState {
27
+ sessions: Record<string, ActiveSessionRecord>;
28
+ lastUpdatedAt: number;
29
+ }
30
+ export interface RegisterActiveSessionOptions {
31
+ sessionId: string;
32
+ projectId?: SessionProjectKey | null;
33
+ projectLabel?: string;
34
+ title?: string;
35
+ href?: string;
36
+ metadata?: Record<string, unknown>;
37
+ }
38
+ export interface ActiveSessionConnectionOptions {
39
+ connectionState: ActiveSessionConnectionState;
40
+ reconnectState?: ActiveSessionReconnectState;
41
+ transportMode?: ActiveSessionTransportMode | null;
42
+ lastError?: string | null;
43
+ lastEventAt?: number | null;
44
+ }
45
+ export interface ActiveSessionActivityOptions {
46
+ lastEventAt?: number | null;
47
+ }
48
+ export interface ActiveProjectActivity {
49
+ projectId: SessionProjectKey;
50
+ projectLabel?: string;
51
+ activeSessionCount: number;
52
+ runningSessionIds: string[];
53
+ lastActivityAt: number;
54
+ }
55
+ export declare const activeSessionsAtom: import("nanostores").PreinitializedWritableAtom<ActiveSessionsState> & object;
56
+ export declare function registerActiveSession(options: RegisterActiveSessionOptions): void;
57
+ export declare function unregisterActiveSession(sessionId: string): void;
58
+ export declare function setForegroundActiveSession(sessionId: string | null): void;
59
+ export declare function updateActiveSessionMeta(sessionId: string, meta: Partial<Pick<ActiveSessionRecord, "title" | "href" | "projectId" | "projectLabel" | "metadata">>): void;
60
+ export declare function setActiveSessionConnection(sessionId: string, options: ActiveSessionConnectionOptions): void;
61
+ export declare function setActiveSessionRunning(sessionId: string, isRunning: boolean, options?: ActiveSessionActivityOptions): void;
62
+ export declare function setActiveSessionAttention(sessionId: string, needsAttention: boolean, options?: ActiveSessionActivityOptions): void;
63
+ export declare function setActiveSessionError(sessionId: string, error: string | null): void;
64
+ export declare function bumpActiveSessionActivity(sessionId: string, options?: ActiveSessionActivityOptions): void;
65
+ export declare function resetActiveSessions(): void;
66
+ export declare function getAllActiveSessions(state: ActiveSessionsState): ActiveSessionRecord[];
67
+ export declare function getActiveSession(state: ActiveSessionsState, sessionId: string): ActiveSessionRecord | null;
68
+ export declare function getSessionsForProject(state: ActiveSessionsState, projectId: SessionProjectKey): ActiveSessionRecord[];
69
+ export declare function getSessionsForNavbar(state: ActiveSessionsState, projectId?: SessionProjectKey | null): ActiveSessionRecord[];
70
+ export declare function getSessionsByActivity(state: ActiveSessionsState): ActiveSessionRecord[];
71
+ export declare function getTotalRunningSessionCount(state: ActiveSessionsState): number;
72
+ export declare function hasBackgroundRunningSessions(state: ActiveSessionsState): boolean;
73
+ export declare function getAllProjectActivity(state: ActiveSessionsState): ActiveProjectActivity[];
74
+ export declare function useActiveSessionsState(): ActiveSessionsState;
75
+ export declare function useActiveSessions(): ActiveSessionRecord[];
76
+ export declare function useActiveSession(sessionId: string | null): ActiveSessionRecord | null;
77
+ export declare function useProjectSessions(projectId: SessionProjectKey | null): ActiveSessionRecord[];
78
+ export declare function useNavbarSessions(projectId?: SessionProjectKey | null): ActiveSessionRecord[];
79
+ export declare function useSessionsByActivity(): ActiveSessionRecord[];
80
+ export declare function useProjectActivity(): ActiveProjectActivity[];
81
+ export declare function useTotalRunningSessions(): number;
82
+ export declare function useHasBackgroundRunningSessions(): boolean;
83
+ //#endregion
@@ -259,4 +259,4 @@ function useHasBackgroundRunningSessions() {
259
259
  return useMemo(() => hasBackgroundRunningSessions(state), [state]);
260
260
  }
261
261
  //#endregion
262
- export { useHasBackgroundRunningSessions as C, useSessionsByActivity as D, useProjectSessions as E, useTotalRunningSessions as O, useActiveSessionsState as S, useProjectActivity as T, setForegroundActiveSession as _, getAllProjectActivity as a, useActiveSession as b, getSessionsForProject as c, registerActiveSession as d, resetActiveSessions as f, setActiveSessionRunning as g, setActiveSessionError as h, getAllActiveSessions as i, getTotalRunningSessionCount as l, setActiveSessionConnection as m, bumpActiveSessionActivity as n, getSessionsByActivity as o, setActiveSessionAttention as p, getActiveSession as r, getSessionsForNavbar as s, activeSessionsAtom as t, hasBackgroundRunningSessions as u, unregisterActiveSession as v, useNavbarSessions as w, useActiveSessions as x, updateActiveSessionMeta as y };
262
+ export { activeSessionsAtom, bumpActiveSessionActivity, getActiveSession, getAllActiveSessions, getAllProjectActivity, getSessionsByActivity, getSessionsForNavbar, getSessionsForProject, getTotalRunningSessionCount, hasBackgroundRunningSessions, registerActiveSession, resetActiveSessions, setActiveSessionAttention, setActiveSessionConnection, setActiveSessionError, setActiveSessionRunning, setForegroundActiveSession, unregisterActiveSession, updateActiveSessionMeta, useActiveSession, useActiveSessions, useActiveSessionsState, useHasBackgroundRunningSessions, useNavbarSessions, useProjectActivity, useProjectSessions, useSessionsByActivity, useTotalRunningSessions };
@@ -0,0 +1,14 @@
1
+ import { SessionMessage } from "../types/message.js";
2
+ import { SessionPart } from "../types/parts.js";
3
+ //#region src/stores/chat-store.d.ts
4
+ /** Ordered list of messages in the current chat session. */
5
+ export declare const messagesAtom: import("nanostores").PreinitializedWritableAtom<SessionMessage[]> & object;
6
+ /** Map of message ID → parts for that message. */
7
+ export declare const partMapAtom: import("nanostores").PreinitializedMapStore<Record<string, SessionPart[]>> & object;
8
+ /** Whether the assistant is currently streaming a response. */
9
+ export declare const isStreamingAtom: import("nanostores").PreinitializedWritableAtom<boolean> & object;
10
+ export declare function addMessage(msg: SessionMessage): void;
11
+ export declare function addParts(messageId: string, parts: SessionPart[]): void;
12
+ export declare function updatePart(messageId: string, partIndex: number, part: SessionPart): void;
13
+ export declare function clearChat(): void;
14
+ //#endregion
@@ -0,0 +1,33 @@
1
+ import { atom, map } from "nanostores";
2
+ //#region src/stores/chat-store.ts
3
+ /** Ordered list of messages in the current chat session. */
4
+ const messagesAtom = atom([]);
5
+ /** Map of message ID → parts for that message. */
6
+ const partMapAtom = map({});
7
+ /** Whether the assistant is currently streaming a response. */
8
+ const isStreamingAtom = atom(false);
9
+ let insertionCounter = 0;
10
+ function addMessage(msg) {
11
+ const withIndex = {
12
+ ...msg,
13
+ _insertionIndex: insertionCounter++
14
+ };
15
+ messagesAtom.set([...messagesAtom.get(), withIndex]);
16
+ }
17
+ function addParts(messageId, parts) {
18
+ const existing = partMapAtom.get()[messageId] ?? [];
19
+ partMapAtom.setKey(messageId, [...existing, ...parts]);
20
+ }
21
+ function updatePart(messageId, partIndex, part) {
22
+ const existing = [...partMapAtom.get()[messageId] ?? []];
23
+ existing[partIndex] = part;
24
+ partMapAtom.setKey(messageId, existing);
25
+ }
26
+ function clearChat() {
27
+ messagesAtom.set([]);
28
+ partMapAtom.set({});
29
+ isStreamingAtom.set(false);
30
+ insertionCounter = 0;
31
+ }
32
+ //#endregion
33
+ export { addMessage, addParts, clearChat, isStreamingAtom, messagesAtom, partMapAtom, updatePart };
package/dist/stores.d.ts CHANGED
@@ -1,16 +1,3 @@
1
- import { t as SessionMessage } from "./message-vhUI0c5G.js";
2
- import { n as SessionPart } from "./parts-5mhy9yJ3.js";
3
- import { A as updateActiveSessionMeta, C as resetActiveSessions, D as setActiveSessionRunning, E as setActiveSessionError, F as useNavbarSessions, I as useProjectActivity, L as useProjectSessions, M as useActiveSessions, N as useActiveSessionsState, O as setForegroundActiveSession, P as useHasBackgroundRunningSessions, R as useSessionsByActivity, S as registerActiveSession, T as setActiveSessionConnection, _ as getSessionsByActivity, a as ActiveSessionReconnectState, b as getTotalRunningSessionCount, c as ActiveSessionTransportMode, d as SessionProjectKey, f as activeSessionsAtom, g as getAllProjectActivity, h as getAllActiveSessions, i as ActiveSessionConnectionState, j as useActiveSession, k as unregisterActiveSession, l as ActiveSessionsState, m as getActiveSession, n as ActiveSessionActivityOptions, o as ActiveSessionRecord, p as bumpActiveSessionActivity, r as ActiveSessionConnectionOptions, s as ActiveSessionStatus, t as ActiveProjectActivity, u as RegisterActiveSessionOptions, v as getSessionsForNavbar, w as setActiveSessionAttention, x as hasBackgroundRunningSessions, y as getSessionsForProject, z as useTotalRunningSessions } from "./active-sessions-store-nl70ZnMC.js";
4
- //#region src/stores/chat-store.d.ts
5
- /** Ordered list of messages in the current chat session. */
6
- export declare const messagesAtom: import("nanostores").PreinitializedWritableAtom<SessionMessage[]> & object;
7
- /** Map of message ID → parts for that message. */
8
- export declare const partMapAtom: import("nanostores").PreinitializedMapStore<Record<string, SessionPart[]>> & object;
9
- /** Whether the assistant is currently streaming a response. */
10
- export declare const isStreamingAtom: import("nanostores").PreinitializedWritableAtom<boolean> & object;
11
- export declare function addMessage(msg: SessionMessage): void;
12
- export declare function addParts(messageId: string, parts: SessionPart[]): void;
13
- export declare function updatePart(messageId: string, partIndex: number, part: SessionPart): void;
14
- export declare function clearChat(): void;
15
- //#endregion
16
- export { ActiveProjectActivity, ActiveSessionActivityOptions, ActiveSessionConnectionOptions, ActiveSessionConnectionState, ActiveSessionReconnectState, ActiveSessionRecord, ActiveSessionStatus, ActiveSessionTransportMode, ActiveSessionsState, RegisterActiveSessionOptions, SessionProjectKey, activeSessionsAtom, bumpActiveSessionActivity, getActiveSession, getAllActiveSessions, getAllProjectActivity, getSessionsByActivity, getSessionsForNavbar, getSessionsForProject, getTotalRunningSessionCount, hasBackgroundRunningSessions, registerActiveSession, resetActiveSessions, setActiveSessionAttention, setActiveSessionConnection, setActiveSessionError, setActiveSessionRunning, setForegroundActiveSession, unregisterActiveSession, updateActiveSessionMeta, useActiveSession, useActiveSessions, useActiveSessionsState, useHasBackgroundRunningSessions, useNavbarSessions, useProjectActivity, useProjectSessions, useSessionsByActivity, useTotalRunningSessions };
1
+ import { ActiveProjectActivity, ActiveSessionActivityOptions, ActiveSessionConnectionOptions, ActiveSessionConnectionState, ActiveSessionReconnectState, ActiveSessionRecord, ActiveSessionStatus, ActiveSessionTransportMode, ActiveSessionsState, RegisterActiveSessionOptions, SessionProjectKey, activeSessionsAtom, bumpActiveSessionActivity, getActiveSession, getAllActiveSessions, getAllProjectActivity, getSessionsByActivity, getSessionsForNavbar, getSessionsForProject, getTotalRunningSessionCount, hasBackgroundRunningSessions, registerActiveSession, resetActiveSessions, setActiveSessionAttention, setActiveSessionConnection, setActiveSessionError, setActiveSessionRunning, setForegroundActiveSession, unregisterActiveSession, updateActiveSessionMeta, useActiveSession, useActiveSessions, useActiveSessionsState, useHasBackgroundRunningSessions, useNavbarSessions, useProjectActivity, useProjectSessions, useSessionsByActivity, useTotalRunningSessions } from "./stores/active-sessions-store.js";
2
+ import { addMessage, addParts, clearChat, isStreamingAtom, messagesAtom, partMapAtom, updatePart } from "./stores/chat-store.js";
3
+ export { ActiveProjectActivity, ActiveSessionActivityOptions, ActiveSessionConnectionOptions, ActiveSessionConnectionState, ActiveSessionReconnectState, ActiveSessionRecord, ActiveSessionStatus, ActiveSessionTransportMode, ActiveSessionsState, RegisterActiveSessionOptions, SessionProjectKey, activeSessionsAtom, addMessage, addParts, bumpActiveSessionActivity, clearChat, getActiveSession, getAllActiveSessions, getAllProjectActivity, getSessionsByActivity, getSessionsForNavbar, getSessionsForProject, getTotalRunningSessionCount, hasBackgroundRunningSessions, isStreamingAtom, messagesAtom, partMapAtom, registerActiveSession, resetActiveSessions, setActiveSessionAttention, setActiveSessionConnection, setActiveSessionError, setActiveSessionRunning, setForegroundActiveSession, unregisterActiveSession, updateActiveSessionMeta, updatePart, useActiveSession, useActiveSessions, useActiveSessionsState, useHasBackgroundRunningSessions, useNavbarSessions, useProjectActivity, useProjectSessions, useSessionsByActivity, useTotalRunningSessions };
package/dist/stores.js CHANGED
@@ -1,34 +1,3 @@
1
- import { C as useHasBackgroundRunningSessions, D as useSessionsByActivity, E as useProjectSessions, O as useTotalRunningSessions, S as useActiveSessionsState, T as useProjectActivity, _ as setForegroundActiveSession, a as getAllProjectActivity, b as useActiveSession, c as getSessionsForProject, d as registerActiveSession, f as resetActiveSessions, g as setActiveSessionRunning, h as setActiveSessionError, i as getAllActiveSessions, l as getTotalRunningSessionCount, m as setActiveSessionConnection, n as bumpActiveSessionActivity, o as getSessionsByActivity, p as setActiveSessionAttention, r as getActiveSession, s as getSessionsForNavbar, t as activeSessionsAtom, u as hasBackgroundRunningSessions, v as unregisterActiveSession, w as useNavbarSessions, x as useActiveSessions, y as updateActiveSessionMeta } from "./active-sessions-store-Gt1R0rFG.js";
2
- import { atom, map } from "nanostores";
3
- //#region src/stores/chat-store.ts
4
- /** Ordered list of messages in the current chat session. */
5
- const messagesAtom = atom([]);
6
- /** Map of message ID → parts for that message. */
7
- const partMapAtom = map({});
8
- /** Whether the assistant is currently streaming a response. */
9
- const isStreamingAtom = atom(false);
10
- let insertionCounter = 0;
11
- function addMessage(msg) {
12
- const withIndex = {
13
- ...msg,
14
- _insertionIndex: insertionCounter++
15
- };
16
- messagesAtom.set([...messagesAtom.get(), withIndex]);
17
- }
18
- function addParts(messageId, parts) {
19
- const existing = partMapAtom.get()[messageId] ?? [];
20
- partMapAtom.setKey(messageId, [...existing, ...parts]);
21
- }
22
- function updatePart(messageId, partIndex, part) {
23
- const existing = [...partMapAtom.get()[messageId] ?? []];
24
- existing[partIndex] = part;
25
- partMapAtom.setKey(messageId, existing);
26
- }
27
- function clearChat() {
28
- messagesAtom.set([]);
29
- partMapAtom.set({});
30
- isStreamingAtom.set(false);
31
- insertionCounter = 0;
32
- }
33
- //#endregion
1
+ import { activeSessionsAtom, bumpActiveSessionActivity, getActiveSession, getAllActiveSessions, getAllProjectActivity, getSessionsByActivity, getSessionsForNavbar, getSessionsForProject, getTotalRunningSessionCount, hasBackgroundRunningSessions, registerActiveSession, resetActiveSessions, setActiveSessionAttention, setActiveSessionConnection, setActiveSessionError, setActiveSessionRunning, setForegroundActiveSession, unregisterActiveSession, updateActiveSessionMeta, useActiveSession, useActiveSessions, useActiveSessionsState, useHasBackgroundRunningSessions, useNavbarSessions, useProjectActivity, useProjectSessions, useSessionsByActivity, useTotalRunningSessions } from "./stores/active-sessions-store.js";
2
+ import { addMessage, addParts, clearChat, isStreamingAtom, messagesAtom, partMapAtom, updatePart } from "./stores/chat-store.js";
34
3
  export { activeSessionsAtom, addMessage, addParts, bumpActiveSessionActivity, clearChat, getActiveSession, getAllActiveSessions, getAllProjectActivity, getSessionsByActivity, getSessionsForNavbar, getSessionsForProject, getTotalRunningSessionCount, hasBackgroundRunningSessions, isStreamingAtom, messagesAtom, partMapAtom, registerActiveSession, resetActiveSessions, setActiveSessionAttention, setActiveSessionConnection, setActiveSessionError, setActiveSessionRunning, setForegroundActiveSession, unregisterActiveSession, updateActiveSessionMeta, updatePart, useActiveSession, useActiveSessions, useActiveSessionsState, useHasBackgroundRunningSessions, useNavbarSessions, useProjectActivity, useProjectSessions, useSessionsByActivity, useTotalRunningSessions };
@@ -0,0 +1,11 @@
1
+ import { ToolPart } from "../types/parts.js";
2
+ //#region src/tool-previews/command-preview.d.ts
3
+ export interface CommandPreviewProps {
4
+ part: ToolPart;
5
+ }
6
+ /**
7
+ * Terminal-style command output preview.
8
+ * Shows the command, exit code, and stdout/stderr with expand/collapse.
9
+ */
10
+ export declare const CommandPreview: import("react").MemoExoticComponent<({ part }: CommandPreviewProps) => import("react").JSX.Element>;
11
+ //#endregion
@@ -0,0 +1,91 @@
1
+ import { focusRing } from "../lib/focus.js";
2
+ import { cn } from "../lib/utils.js";
3
+ import { PreviewCard, PreviewError, PreviewLoading } from "./preview-primitives.js";
4
+ import { memo, useState } from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { ChevronDown, ChevronRight, Terminal } from "lucide-react";
7
+ //#region src/tool-previews/command-preview.tsx
8
+ /** Extract stdout/stderr/exitCode from tool output. */
9
+ function extractCommandOutput(output) {
10
+ if (!output) return {
11
+ stdout: "",
12
+ stderr: "",
13
+ exitCode: 0
14
+ };
15
+ if (typeof output === "string") return {
16
+ stdout: output,
17
+ stderr: "",
18
+ exitCode: 0
19
+ };
20
+ if (typeof output === "object" && output !== null) {
21
+ const obj = output;
22
+ return {
23
+ stdout: String(obj.stdout ?? obj.output ?? ""),
24
+ stderr: String(obj.stderr ?? ""),
25
+ exitCode: Number(obj.exitCode ?? obj.exit_code ?? obj.code ?? 0)
26
+ };
27
+ }
28
+ return {
29
+ stdout: String(output),
30
+ stderr: "",
31
+ exitCode: 0
32
+ };
33
+ }
34
+ /**
35
+ * Terminal-style command output preview.
36
+ * Shows the command, exit code, and stdout/stderr with expand/collapse.
37
+ */
38
+ const CommandPreview = memo(({ part }) => {
39
+ const [expanded, setExpanded] = useState(true);
40
+ const input = part.state.input;
41
+ const command = typeof input?.command === "string" ? input.command : String(input ?? "");
42
+ const output = part.state.status === "completed" ? extractCommandOutput(part.state.output) : null;
43
+ const isError = output ? output.exitCode !== 0 : part.state.status === "error";
44
+ const errorText = part.state.error;
45
+ const lineCount = output?.stdout ? output.stdout.split("\n").length : 0;
46
+ return /* @__PURE__ */ jsxs(PreviewCard, {
47
+ icon: /* @__PURE__ */ jsx(Terminal, { className: "h-4 w-4" }),
48
+ title: "Command",
49
+ description: command,
50
+ meta: output ? /* @__PURE__ */ jsxs("span", {
51
+ className: cn("inline-flex items-center rounded-full border px-2 py-0.5 font-mono", isError ? "border-[var(--surface-danger-border)] bg-[var(--surface-danger-bg)] text-[var(--surface-danger-text)]" : "border-[var(--surface-success-border)] bg-[var(--surface-success-bg)] text-[var(--surface-success-text)]"),
52
+ children: ["exit ", output.exitCode]
53
+ }) : null,
54
+ children: [
55
+ /* @__PURE__ */ jsxs("button", {
56
+ onClick: () => setExpanded((value) => !value),
57
+ className: cn("flex w-full items-center gap-2 rounded-[var(--radius-md)] border border-border bg-muted px-3 py-2 text-left transition-colors hover:border-[var(--border-strong)] hover:bg-accent/45", focusRing),
58
+ children: [
59
+ /* @__PURE__ */ jsx("code", {
60
+ className: "min-w-0 flex-1 truncate text-xs font-mono text-foreground",
61
+ children: command
62
+ }),
63
+ lineCount > 0 ? /* @__PURE__ */ jsxs("span", {
64
+ className: "shrink-0 text-xs text-muted-foreground",
65
+ children: [
66
+ lineCount,
67
+ " line",
68
+ lineCount === 1 ? "" : "s"
69
+ ]
70
+ }) : null,
71
+ expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3.5 w-3.5 text-muted-foreground" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3.5 w-3.5 text-muted-foreground" })
72
+ ]
73
+ }),
74
+ part.state.status === "running" ? /* @__PURE__ */ jsx(PreviewLoading, {}) : null,
75
+ errorText ? /* @__PURE__ */ jsx(PreviewError, { error: errorText }) : null,
76
+ expanded && output ? /* @__PURE__ */ jsxs("div", {
77
+ className: "overflow-hidden rounded-[var(--radius-md)] border border-border bg-muted",
78
+ children: [output.stdout ? /* @__PURE__ */ jsx("pre", {
79
+ className: "max-h-80 overflow-auto px-3 py-3 text-xs font-mono whitespace-pre-wrap break-all text-foreground",
80
+ children: output.stdout
81
+ }) : null, output.stderr ? /* @__PURE__ */ jsx("pre", {
82
+ className: "max-h-80 overflow-auto border-t border-border px-3 py-3 text-xs font-mono whitespace-pre-wrap break-all text-red-200",
83
+ children: output.stderr
84
+ }) : null]
85
+ }) : null
86
+ ]
87
+ });
88
+ });
89
+ CommandPreview.displayName = "CommandPreview";
90
+ //#endregion
91
+ export { CommandPreview };
@@ -0,0 +1,7 @@
1
+ import { ToolPart } from "../types/parts.js";
2
+ //#region src/tool-previews/diff-preview.d.ts
3
+ export interface DiffPreviewProps {
4
+ part: ToolPart;
5
+ }
6
+ export declare const DiffPreview: import("react").MemoExoticComponent<({ part }: DiffPreviewProps) => import("react").JSX.Element>;
7
+ //#endregion
@@ -0,0 +1,76 @@
1
+ import { CodeBlock } from "../markdown/code-block.js";
2
+ import { PreviewCard, PreviewEmpty, PreviewError, PreviewLoading } from "./preview-primitives.js";
3
+ import { memo } from "react";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { GitCompareArrows } from "lucide-react";
6
+ //#region src/tool-previews/diff-preview.tsx
7
+ function extractString(record, ...keys) {
8
+ for (const key of keys) {
9
+ const value = record[key];
10
+ if (typeof value === "string" && value.length > 0) return value;
11
+ }
12
+ }
13
+ function extractDiffPayload(part) {
14
+ const sources = [
15
+ part.state.input,
16
+ part.state.output,
17
+ part.state.metadata
18
+ ];
19
+ for (const source of sources) {
20
+ if (!source || typeof source !== "object") continue;
21
+ const record = source;
22
+ const diff = extractString(record, "diff", "patch", "unifiedDiff", "unified_diff");
23
+ const before = extractString(record, "oldString", "old_string", "before", "previous");
24
+ const after = extractString(record, "newString", "new_string", "after", "updated");
25
+ const path = extractString(record, "file_path", "filePath", "path");
26
+ if (diff || before || after) return {
27
+ path,
28
+ diff,
29
+ before,
30
+ after
31
+ };
32
+ }
33
+ return {};
34
+ }
35
+ const DiffPreview = memo(({ part }) => {
36
+ const payload = extractDiffPayload(part);
37
+ return /* @__PURE__ */ jsxs(PreviewCard, {
38
+ icon: /* @__PURE__ */ jsx(GitCompareArrows, { className: "h-4 w-4" }),
39
+ title: payload.path ? `Changes for ${payload.path}` : "File changes",
40
+ children: [
41
+ part.state.status === "running" ? /* @__PURE__ */ jsx(PreviewLoading, { label: "Computing changes…" }) : null,
42
+ part.state.error ? /* @__PURE__ */ jsx(PreviewError, { error: part.state.error }) : null,
43
+ !payload.diff && !payload.before && !payload.after ? /* @__PURE__ */ jsx(PreviewEmpty, { label: "No structured diff payload was provided." }) : null,
44
+ payload.diff ? /* @__PURE__ */ jsx(CodeBlock, {
45
+ code: payload.diff,
46
+ language: "diff",
47
+ className: "rounded-[var(--radius-md)]"
48
+ }) : null,
49
+ !payload.diff && payload.before ? /* @__PURE__ */ jsxs("div", {
50
+ className: "space-y-2",
51
+ children: [/* @__PURE__ */ jsx("div", {
52
+ className: "text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground",
53
+ children: "Before"
54
+ }), /* @__PURE__ */ jsx(CodeBlock, {
55
+ code: payload.before,
56
+ language: "text",
57
+ className: "rounded-[var(--radius-md)]"
58
+ })]
59
+ }) : null,
60
+ !payload.diff && payload.after ? /* @__PURE__ */ jsxs("div", {
61
+ className: "space-y-2",
62
+ children: [/* @__PURE__ */ jsx("div", {
63
+ className: "text-xs font-semibold uppercase tracking-[0.08em] text-muted-foreground",
64
+ children: "After"
65
+ }), /* @__PURE__ */ jsx(CodeBlock, {
66
+ code: payload.after,
67
+ language: "text",
68
+ className: "rounded-[var(--radius-md)]"
69
+ })]
70
+ }) : null
71
+ ]
72
+ });
73
+ });
74
+ DiffPreview.displayName = "DiffPreview";
75
+ //#endregion
76
+ export { DiffPreview };
@@ -0,0 +1,7 @@
1
+ import { ToolPart } from "../types/parts.js";
2
+ //#region src/tool-previews/glob-results-preview.d.ts
3
+ export interface GlobResultsPreviewProps {
4
+ part: ToolPart;
5
+ }
6
+ export declare const GlobResultsPreview: import("react").MemoExoticComponent<({ part }: GlobResultsPreviewProps) => import("react").JSX.Element>;
7
+ //#endregion
@@ -0,0 +1,53 @@
1
+ import { PreviewCard, PreviewEmpty, PreviewError, PreviewLoading } from "./preview-primitives.js";
2
+ import { memo, useMemo } from "react";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { FileText, FolderOpen } from "lucide-react";
5
+ //#region src/tool-previews/glob-results-preview.tsx
6
+ function coerceString(value) {
7
+ return typeof value === "string" && value.trim() ? value : void 0;
8
+ }
9
+ function extractPattern(input) {
10
+ if (!input || typeof input !== "object") return;
11
+ const record = input;
12
+ return coerceString(record.pattern) ?? coerceString(record.path);
13
+ }
14
+ function extractFiles(output) {
15
+ if (Array.isArray(output)) return output.map((item) => String(item)).filter(Boolean);
16
+ if (output && typeof output === "object") {
17
+ const record = output;
18
+ const candidate = record.files ?? record.matches ?? record.paths ?? record.results;
19
+ if (Array.isArray(candidate)) return candidate.map((item) => typeof item === "string" ? item : item && typeof item === "object" ? String(item.path ?? item.file ?? "") : "").filter(Boolean);
20
+ }
21
+ if (typeof output === "string") return output.split("\n").map((line) => line.trim()).filter(Boolean);
22
+ return [];
23
+ }
24
+ const GlobResultsPreview = memo(({ part }) => {
25
+ const pattern = extractPattern(part.state.input);
26
+ const files = useMemo(() => extractFiles(part.state.output), [part.state.output]);
27
+ return /* @__PURE__ */ jsxs(PreviewCard, {
28
+ icon: /* @__PURE__ */ jsx(FolderOpen, { className: "h-4 w-4" }),
29
+ title: pattern ? `Files for ${pattern}` : "File results",
30
+ description: files.length > 0 ? `${files.length} path${files.length === 1 ? "" : "s"}` : void 0,
31
+ children: [
32
+ part.state.status === "running" ? /* @__PURE__ */ jsx(PreviewLoading, { label: "Collecting files…" }) : null,
33
+ part.state.error ? /* @__PURE__ */ jsx(PreviewError, { error: part.state.error }) : null,
34
+ part.state.status === "completed" && files.length === 0 ? /* @__PURE__ */ jsx(PreviewEmpty, { label: "No matching files were returned." }) : null,
35
+ files.length > 0 ? /* @__PURE__ */ jsx("div", {
36
+ className: "grid gap-2 sm:grid-cols-2",
37
+ children: files.map((file) => {
38
+ const Icon = file.endsWith("/") ? FolderOpen : FileText;
39
+ return /* @__PURE__ */ jsxs("div", {
40
+ className: "flex items-center gap-2 rounded-[var(--radius-md)] border border-border bg-muted/55 px-3 py-2",
41
+ children: [/* @__PURE__ */ jsx(Icon, { className: "h-4 w-4 shrink-0 text-primary" }), /* @__PURE__ */ jsx("span", {
42
+ className: "min-w-0 truncate text-xs font-mono text-foreground",
43
+ children: file
44
+ })]
45
+ }, file);
46
+ })
47
+ }) : null
48
+ ]
49
+ });
50
+ });
51
+ GlobResultsPreview.displayName = "GlobResultsPreview";
52
+ //#endregion
53
+ export { GlobResultsPreview };
@@ -0,0 +1,7 @@
1
+ import { ToolPart } from "../types/parts.js";
2
+ //#region src/tool-previews/grep-results-preview.d.ts
3
+ export interface GrepResultsPreviewProps {
4
+ part: ToolPart;
5
+ }
6
+ export declare const GrepResultsPreview: import("react").MemoExoticComponent<({ part }: GrepResultsPreviewProps) => import("react").JSX.Element>;
7
+ //#endregion
@@ -0,0 +1,99 @@
1
+ import { PreviewCard, PreviewEmpty, PreviewError, PreviewLoading } from "./preview-primitives.js";
2
+ import { memo, useMemo } from "react";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { Search } from "lucide-react";
5
+ //#region src/tool-previews/grep-results-preview.tsx
6
+ function coerceString(value) {
7
+ return typeof value === "string" && value.trim() ? value : void 0;
8
+ }
9
+ function parseMatch(value) {
10
+ if (typeof value === "string") {
11
+ const [path, maybeLine, ...rest] = value.split(":");
12
+ const line = Number(maybeLine);
13
+ if (rest.length > 0 && Number.isFinite(line)) return {
14
+ path,
15
+ line,
16
+ text: rest.join(":").trim()
17
+ };
18
+ return {
19
+ path: "match",
20
+ text: value
21
+ };
22
+ }
23
+ if (!value || typeof value !== "object") return null;
24
+ const record = value;
25
+ const path = coerceString(record.path) ?? coerceString(record.file) ?? coerceString(record.filePath) ?? "match";
26
+ const lineValue = record.line ?? record.lineNumber ?? record.line_number;
27
+ const line = typeof lineValue === "number" ? lineValue : Number(lineValue);
28
+ const text = coerceString(record.text) ?? coerceString(record.content) ?? coerceString(record.lineText) ?? coerceString(record.preview);
29
+ if (!text) return null;
30
+ return {
31
+ path,
32
+ line: Number.isFinite(line) ? line : void 0,
33
+ text
34
+ };
35
+ }
36
+ function extractPattern(input) {
37
+ if (!input || typeof input !== "object") return;
38
+ const record = input;
39
+ return coerceString(record.pattern) ?? coerceString(record.query);
40
+ }
41
+ function extractMatches(output) {
42
+ if (Array.isArray(output)) return output.map(parseMatch).filter((value) => value !== null);
43
+ if (output && typeof output === "object") {
44
+ const record = output;
45
+ const candidates = [
46
+ record.matches,
47
+ record.results,
48
+ record.output
49
+ ];
50
+ for (const candidate of candidates) if (Array.isArray(candidate)) return candidate.map(parseMatch).filter((value) => value !== null);
51
+ }
52
+ if (typeof output === "string") return output.split("\n").map((line) => line.trim()).filter(Boolean).map(parseMatch).filter((value) => value !== null);
53
+ return [];
54
+ }
55
+ const GrepResultsPreview = memo(({ part }) => {
56
+ const pattern = extractPattern(part.state.input);
57
+ const matches = useMemo(() => extractMatches(part.state.output), [part.state.output]);
58
+ const groupedMatches = useMemo(() => {
59
+ const groups = /* @__PURE__ */ new Map();
60
+ for (const match of matches) {
61
+ const list = groups.get(match.path) ?? [];
62
+ list.push(match);
63
+ groups.set(match.path, list);
64
+ }
65
+ return [...groups.entries()];
66
+ }, [matches]);
67
+ return /* @__PURE__ */ jsxs(PreviewCard, {
68
+ icon: /* @__PURE__ */ jsx(Search, { className: "h-4 w-4" }),
69
+ title: pattern ? `Search results for "${pattern}"` : "Search results",
70
+ description: matches.length > 0 ? `${matches.length} match${matches.length === 1 ? "" : "es"}` : void 0,
71
+ children: [
72
+ part.state.status === "running" ? /* @__PURE__ */ jsx(PreviewLoading, { label: "Searching files…" }) : null,
73
+ part.state.error ? /* @__PURE__ */ jsx(PreviewError, { error: part.state.error }) : null,
74
+ part.state.status === "completed" && matches.length === 0 ? /* @__PURE__ */ jsx(PreviewEmpty, { label: "No matching files or lines were returned." }) : null,
75
+ groupedMatches.map(([path, pathMatches]) => /* @__PURE__ */ jsxs("div", {
76
+ className: "rounded-[var(--radius-md)] border border-border bg-muted/55",
77
+ children: [/* @__PURE__ */ jsx("div", {
78
+ className: "border-b border-border px-3 py-2 text-xs font-medium text-foreground",
79
+ children: path
80
+ }), /* @__PURE__ */ jsx("div", {
81
+ className: "divide-y divide-border",
82
+ children: pathMatches.map((match, index) => /* @__PURE__ */ jsxs("div", {
83
+ className: "grid grid-cols-[auto_minmax(0,1fr)] gap-3 px-3 py-2",
84
+ children: [/* @__PURE__ */ jsx("div", {
85
+ className: "pt-0.5 text-xs font-mono text-muted-foreground",
86
+ children: match.line ?? "·"
87
+ }), /* @__PURE__ */ jsx("pre", {
88
+ className: "overflow-x-auto whitespace-pre-wrap break-words text-xs font-mono text-foreground",
89
+ children: match.text
90
+ })]
91
+ }, `${path}-${match.line ?? index}-${index}`))
92
+ })]
93
+ }, path))
94
+ ]
95
+ });
96
+ });
97
+ GrepResultsPreview.displayName = "GrepResultsPreview";
98
+ //#endregion
99
+ export { GrepResultsPreview };
@@ -0,0 +1,58 @@
1
+ import { cn } from "../lib/utils.js";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { Loader2 } from "lucide-react";
4
+ //#region src/tool-previews/preview-primitives.tsx
5
+ function PreviewCard({ icon, title, description, meta, children, className }) {
6
+ return /* @__PURE__ */ jsxs("div", {
7
+ className: cn("overflow-hidden rounded-[var(--radius-lg)] border border-border bg-card shadow-[var(--shadow-card)]", className),
8
+ children: [/* @__PURE__ */ jsxs("div", {
9
+ className: "flex items-center gap-2.5 border-b border-border bg-card px-[var(--tool-card-px)] py-[var(--tool-card-py)]",
10
+ children: [
11
+ /* @__PURE__ */ jsx("div", {
12
+ className: "flex h-[var(--tool-icon-size)] w-[var(--tool-icon-size)] shrink-0 items-center justify-center rounded-[var(--radius-sm)] border border-[var(--border-accent)] bg-muted text-primary",
13
+ children: icon
14
+ }),
15
+ /* @__PURE__ */ jsx("div", {
16
+ className: "min-w-0 flex-1",
17
+ children: /* @__PURE__ */ jsxs("div", {
18
+ className: "flex items-center gap-2",
19
+ children: [/* @__PURE__ */ jsx("span", {
20
+ className: "text-xs font-semibold text-foreground",
21
+ children: title
22
+ }), description ? /* @__PURE__ */ jsx("span", {
23
+ className: "truncate text-xs font-mono text-muted-foreground",
24
+ children: description
25
+ }) : null]
26
+ })
27
+ }),
28
+ meta ? /* @__PURE__ */ jsx("div", {
29
+ className: "shrink-0 text-xs text-muted-foreground",
30
+ children: meta
31
+ }) : null
32
+ ]
33
+ }), children ? /* @__PURE__ */ jsx("div", {
34
+ className: "space-y-2 px-[var(--tool-card-px)] py-[var(--tool-card-py)]",
35
+ children
36
+ }) : null]
37
+ });
38
+ }
39
+ function PreviewEmpty({ label, className }) {
40
+ return /* @__PURE__ */ jsx("div", {
41
+ className: cn("rounded-[var(--radius-md)] border border-dashed border-border bg-muted px-3 py-2.5 text-xs text-muted-foreground", className),
42
+ children: label
43
+ });
44
+ }
45
+ function PreviewError({ error }) {
46
+ return /* @__PURE__ */ jsx("div", {
47
+ className: "rounded-[var(--radius-md)] border border-[var(--surface-danger-border)] bg-[var(--surface-danger-bg)] px-3 py-3 text-sm text-[var(--surface-danger-text)]",
48
+ children: error
49
+ });
50
+ }
51
+ function PreviewLoading({ label = "Running…" }) {
52
+ return /* @__PURE__ */ jsxs("div", {
53
+ className: "flex items-center gap-2 rounded-[var(--radius-md)] border border-border bg-muted px-3 py-2 text-xs text-muted-foreground",
54
+ children: [/* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin text-primary" }), /* @__PURE__ */ jsx("span", { children: label })]
55
+ });
56
+ }
57
+ //#endregion
58
+ export { PreviewCard, PreviewEmpty, PreviewError, PreviewLoading };