@townco/ui 0.1.6 → 0.1.7

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 (250) hide show
  1. package/README.md +11 -11
  2. package/dist/core/hooks/use-chat-input.d.ts +17 -17
  3. package/dist/core/hooks/use-chat-input.js +55 -64
  4. package/dist/core/hooks/use-chat-messages.d.ts +11 -11
  5. package/dist/core/hooks/use-chat-messages.js +114 -121
  6. package/dist/core/hooks/use-chat-session.d.ts +5 -5
  7. package/dist/core/hooks/use-chat-session.js +80 -78
  8. package/dist/core/index.d.ts +1 -1
  9. package/dist/core/index.js +1 -1
  10. package/dist/core/schemas/chat.d.ts +56 -83
  11. package/dist/core/schemas/chat.js +25 -27
  12. package/dist/core/store/chat-store.d.ts +22 -28
  13. package/dist/core/store/chat-store.js +50 -59
  14. package/dist/gui/components/Button.d.ts +7 -23
  15. package/dist/gui/components/Button.js +27 -40
  16. package/dist/gui/components/Card.d.ts +7 -26
  17. package/dist/gui/components/Card.js +8 -54
  18. package/dist/gui/components/ChatInput.d.ts +36 -58
  19. package/dist/gui/components/ChatInput.js +121 -191
  20. package/dist/gui/components/ChatSecondaryPanel.d.ts +11 -14
  21. package/dist/gui/components/ChatSecondaryPanel.js +38 -115
  22. package/dist/gui/components/ChatStatus.d.ts +2 -4
  23. package/dist/gui/components/ChatStatus.js +34 -45
  24. package/dist/gui/components/Conversation.d.ts +14 -17
  25. package/dist/gui/components/Conversation.js +83 -143
  26. package/dist/gui/components/Dialog.d.ts +11 -57
  27. package/dist/gui/components/Dialog.js +8 -84
  28. package/dist/gui/components/HeightTransition.d.ts +7 -12
  29. package/dist/gui/components/HeightTransition.js +77 -88
  30. package/dist/gui/components/Input.d.ts +6 -13
  31. package/dist/gui/components/Input.js +16 -27
  32. package/dist/gui/components/Label.d.ts +1 -7
  33. package/dist/gui/components/Label.js +2 -12
  34. package/dist/gui/components/MarkdownRenderer.d.ts +4 -6
  35. package/dist/gui/components/MarkdownRenderer.js +81 -178
  36. package/dist/gui/components/Message.d.ts +18 -25
  37. package/dist/gui/components/Message.js +23 -44
  38. package/dist/gui/components/MessageContent.d.ts +22 -29
  39. package/dist/gui/components/MessageContent.js +85 -157
  40. package/dist/gui/components/Reasoning.d.ts +24 -30
  41. package/dist/gui/components/Reasoning.js +60 -187
  42. package/dist/gui/components/Response.d.ts +9 -11
  43. package/dist/gui/components/Response.js +90 -229
  44. package/dist/gui/components/Select.d.ts +10 -69
  45. package/dist/gui/components/Select.js +12 -118
  46. package/dist/gui/components/Tabs.d.ts +4 -24
  47. package/dist/gui/components/Tabs.js +4 -32
  48. package/dist/gui/components/Task.d.ts +24 -28
  49. package/dist/gui/components/Task.js +31 -164
  50. package/dist/gui/components/Textarea.d.ts +7 -15
  51. package/dist/gui/components/Textarea.js +46 -63
  52. package/dist/gui/components/ThinkingBlock.d.ts +10 -20
  53. package/dist/gui/components/ThinkingBlock.js +35 -134
  54. package/dist/gui/components/TodoList.d.ts +10 -12
  55. package/dist/gui/components/TodoList.js +7 -22
  56. package/dist/gui/components/TodoListItem.d.ts +6 -9
  57. package/dist/gui/components/TodoListItem.js +4 -18
  58. package/dist/gui/components/index.d.ts +8 -59
  59. package/dist/gui/components/index.js +8 -42
  60. package/dist/gui/lib/utils.js +1 -1
  61. package/dist/index.d.ts +1 -1
  62. package/dist/index.js +1 -1
  63. package/dist/index.test.js +1 -0
  64. package/dist/sdk/client/acp-client.d.ts +76 -88
  65. package/dist/sdk/client/acp-client.js +217 -215
  66. package/dist/sdk/index.d.ts +1 -1
  67. package/dist/sdk/index.js +1 -1
  68. package/dist/sdk/schemas/agent.d.ts +64 -111
  69. package/dist/sdk/schemas/agent.js +24 -24
  70. package/dist/sdk/schemas/message.d.ts +147 -245
  71. package/dist/sdk/schemas/message.js +40 -40
  72. package/dist/sdk/schemas/session.d.ts +135 -219
  73. package/dist/sdk/schemas/session.js +27 -27
  74. package/dist/sdk/transports/http.d.ts +55 -55
  75. package/dist/sdk/transports/http.js +469 -472
  76. package/dist/sdk/transports/stdio.d.ts +20 -20
  77. package/dist/sdk/transports/stdio.js +286 -289
  78. package/dist/sdk/transports/types.d.ts +42 -42
  79. package/dist/sdk/transports/websocket.d.ts +12 -12
  80. package/dist/sdk/transports/websocket.js +46 -52
  81. package/dist/tui/components/ChatView.d.ts +2 -4
  82. package/dist/tui/components/ChatView.js +18 -51
  83. package/dist/tui/components/GameOfLife.js +35 -64
  84. package/dist/tui/components/InputBox.d.ts +11 -18
  85. package/dist/tui/components/InputBox.js +10 -70
  86. package/dist/tui/components/MessageList.d.ts +2 -4
  87. package/dist/tui/components/MessageList.js +10 -37
  88. package/dist/tui/components/MultiSelect.d.ts +10 -15
  89. package/dist/tui/components/MultiSelect.js +73 -116
  90. package/dist/tui/components/ReadlineInput.d.ts +6 -12
  91. package/dist/tui/components/ReadlineInput.js +237 -252
  92. package/dist/tui/components/SingleSelect.d.ts +9 -15
  93. package/dist/tui/components/SingleSelect.js +43 -84
  94. package/dist/tui/components/StatusBar.d.ts +6 -11
  95. package/dist/tui/components/StatusBar.js +67 -102
  96. package/dist/tui/index.d.ts +1 -1
  97. package/dist/tui/index.js +1 -1
  98. package/package.json +2 -2
  99. package/dist/core/hooks/index.d.ts.map +0 -1
  100. package/dist/core/hooks/index.js.map +0 -1
  101. package/dist/core/hooks/use-chat-input.d.ts.map +0 -1
  102. package/dist/core/hooks/use-chat-input.js.map +0 -1
  103. package/dist/core/hooks/use-chat-messages.d.ts.map +0 -1
  104. package/dist/core/hooks/use-chat-messages.js.map +0 -1
  105. package/dist/core/hooks/use-chat-session.d.ts.map +0 -1
  106. package/dist/core/hooks/use-chat-session.js.map +0 -1
  107. package/dist/core/hooks/use-media-query.d.ts +0 -39
  108. package/dist/core/hooks/use-media-query.js +0 -80
  109. package/dist/core/index.d.ts.map +0 -1
  110. package/dist/core/index.js.map +0 -1
  111. package/dist/core/schemas/chat.d.ts.map +0 -1
  112. package/dist/core/schemas/chat.js.map +0 -1
  113. package/dist/core/schemas/index.d.ts.map +0 -1
  114. package/dist/core/schemas/index.js.map +0 -1
  115. package/dist/core/store/chat-store.d.ts.map +0 -1
  116. package/dist/core/store/chat-store.js.map +0 -1
  117. package/dist/gui/components/Button.d.ts.map +0 -1
  118. package/dist/gui/components/Button.js.map +0 -1
  119. package/dist/gui/components/Card.d.ts.map +0 -1
  120. package/dist/gui/components/Card.js.map +0 -1
  121. package/dist/gui/components/ChatHeader.d.ts +0 -65
  122. package/dist/gui/components/ChatHeader.js +0 -189
  123. package/dist/gui/components/ChatInput.d.ts.map +0 -1
  124. package/dist/gui/components/ChatInput.js.map +0 -1
  125. package/dist/gui/components/ChatInterface.d.ts +0 -12
  126. package/dist/gui/components/ChatInterface.d.ts.map +0 -1
  127. package/dist/gui/components/ChatInterface.js +0 -204
  128. package/dist/gui/components/ChatInterface.js.map +0 -1
  129. package/dist/gui/components/ChatLayout.d.ts +0 -82
  130. package/dist/gui/components/ChatLayout.js +0 -232
  131. package/dist/gui/components/ChatPanelTabContent.d.ts +0 -27
  132. package/dist/gui/components/ChatPanelTabContent.js +0 -93
  133. package/dist/gui/components/ChatPreview.d.ts +0 -12
  134. package/dist/gui/components/ChatPreview.d.ts.map +0 -1
  135. package/dist/gui/components/ChatPreview.js +0 -214
  136. package/dist/gui/components/ChatPreview.js.map +0 -1
  137. package/dist/gui/components/ChatSecondaryPanel.d.ts.map +0 -1
  138. package/dist/gui/components/ChatSecondaryPanel.js.map +0 -1
  139. package/dist/gui/components/ChatSidebar.d.ts +0 -27
  140. package/dist/gui/components/ChatSidebar.js +0 -57
  141. package/dist/gui/components/ChatStatus.d.ts.map +0 -1
  142. package/dist/gui/components/ChatStatus.js.map +0 -1
  143. package/dist/gui/components/ChatView.d.ts +0 -8
  144. package/dist/gui/components/ChatView.d.ts.map +0 -1
  145. package/dist/gui/components/ChatView.js +0 -42
  146. package/dist/gui/components/ChatView.js.map +0 -1
  147. package/dist/gui/components/ConfigPanel.d.ts +0 -20
  148. package/dist/gui/components/ConfigPanel.d.ts.map +0 -1
  149. package/dist/gui/components/ConfigPanel.js +0 -225
  150. package/dist/gui/components/ConfigPanel.js.map +0 -1
  151. package/dist/gui/components/Conversation.d.ts.map +0 -1
  152. package/dist/gui/components/Conversation.js.map +0 -1
  153. package/dist/gui/components/Dialog.d.ts.map +0 -1
  154. package/dist/gui/components/Dialog.js.map +0 -1
  155. package/dist/gui/components/DropdownMenu.d.ts +0 -108
  156. package/dist/gui/components/DropdownMenu.js +0 -215
  157. package/dist/gui/components/HeightTransition.d.ts.map +0 -1
  158. package/dist/gui/components/HeightTransition.js.map +0 -1
  159. package/dist/gui/components/Input.d.ts.map +0 -1
  160. package/dist/gui/components/Input.js.map +0 -1
  161. package/dist/gui/components/InputBox.d.ts +0 -21
  162. package/dist/gui/components/InputBox.d.ts.map +0 -1
  163. package/dist/gui/components/InputBox.js +0 -90
  164. package/dist/gui/components/InputBox.js.map +0 -1
  165. package/dist/gui/components/Label.d.ts.map +0 -1
  166. package/dist/gui/components/Label.js.map +0 -1
  167. package/dist/gui/components/MarkdownRenderer.d.ts.map +0 -1
  168. package/dist/gui/components/MarkdownRenderer.js.map +0 -1
  169. package/dist/gui/components/Message.d.ts.map +0 -1
  170. package/dist/gui/components/Message.js.map +0 -1
  171. package/dist/gui/components/MessageContent.d.ts.map +0 -1
  172. package/dist/gui/components/MessageContent.js.map +0 -1
  173. package/dist/gui/components/MessageList.d.ts.map +0 -1
  174. package/dist/gui/components/MessageList.js.map +0 -1
  175. package/dist/gui/components/PlaygroundLayout.d.ts +0 -14
  176. package/dist/gui/components/PlaygroundLayout.d.ts.map +0 -1
  177. package/dist/gui/components/PlaygroundLayout.js +0 -49
  178. package/dist/gui/components/PlaygroundLayout.js.map +0 -1
  179. package/dist/gui/components/Reasoning.d.ts.map +0 -1
  180. package/dist/gui/components/Reasoning.js.map +0 -1
  181. package/dist/gui/components/Response.d.ts.map +0 -1
  182. package/dist/gui/components/Response.js.map +0 -1
  183. package/dist/gui/components/Select.d.ts.map +0 -1
  184. package/dist/gui/components/Select.js.map +0 -1
  185. package/dist/gui/components/Sonner.d.ts +0 -7
  186. package/dist/gui/components/Sonner.js +0 -34
  187. package/dist/gui/components/StatusBar.d.ts +0 -12
  188. package/dist/gui/components/StatusBar.d.ts.map +0 -1
  189. package/dist/gui/components/StatusBar.js +0 -58
  190. package/dist/gui/components/StatusBar.js.map +0 -1
  191. package/dist/gui/components/Tabs.d.ts.map +0 -1
  192. package/dist/gui/components/Tabs.js.map +0 -1
  193. package/dist/gui/components/Task.d.ts.map +0 -1
  194. package/dist/gui/components/Task.js.map +0 -1
  195. package/dist/gui/components/Textarea.d.ts.map +0 -1
  196. package/dist/gui/components/Textarea.js.map +0 -1
  197. package/dist/gui/components/ThinkingBlock.d.ts.map +0 -1
  198. package/dist/gui/components/ThinkingBlock.js.map +0 -1
  199. package/dist/gui/components/TodoList.d.ts.map +0 -1
  200. package/dist/gui/components/TodoList.js.map +0 -1
  201. package/dist/gui/components/TodoListItem.d.ts.map +0 -1
  202. package/dist/gui/components/TodoListItem.js.map +0 -1
  203. package/dist/gui/components/index.d.ts.map +0 -1
  204. package/dist/gui/components/index.js.map +0 -1
  205. package/dist/gui/index.d.ts.map +0 -1
  206. package/dist/gui/index.js.map +0 -1
  207. package/dist/gui/lib/utils.d.ts.map +0 -1
  208. package/dist/gui/lib/utils.js.map +0 -1
  209. package/dist/index.d.ts.map +0 -1
  210. package/dist/index.js.map +0 -1
  211. package/dist/sdk/client/acp-client.d.ts.map +0 -1
  212. package/dist/sdk/client/acp-client.js.map +0 -1
  213. package/dist/sdk/client/index.d.ts.map +0 -1
  214. package/dist/sdk/client/index.js.map +0 -1
  215. package/dist/sdk/index.d.ts.map +0 -1
  216. package/dist/sdk/index.js.map +0 -1
  217. package/dist/sdk/schemas/agent.d.ts.map +0 -1
  218. package/dist/sdk/schemas/agent.js.map +0 -1
  219. package/dist/sdk/schemas/index.d.ts.map +0 -1
  220. package/dist/sdk/schemas/index.js.map +0 -1
  221. package/dist/sdk/schemas/message.d.ts.map +0 -1
  222. package/dist/sdk/schemas/message.js.map +0 -1
  223. package/dist/sdk/schemas/session.d.ts.map +0 -1
  224. package/dist/sdk/schemas/session.js.map +0 -1
  225. package/dist/sdk/transports/http.d.ts.map +0 -1
  226. package/dist/sdk/transports/http.js.map +0 -1
  227. package/dist/sdk/transports/index.d.ts.map +0 -1
  228. package/dist/sdk/transports/index.js.map +0 -1
  229. package/dist/sdk/transports/stdio.d.ts.map +0 -1
  230. package/dist/sdk/transports/stdio.js.map +0 -1
  231. package/dist/sdk/transports/types.d.ts.map +0 -1
  232. package/dist/sdk/transports/types.js.map +0 -1
  233. package/dist/sdk/transports/websocket.d.ts.map +0 -1
  234. package/dist/sdk/transports/websocket.js.map +0 -1
  235. package/dist/tui/components/ChatView.d.ts.map +0 -1
  236. package/dist/tui/components/ChatView.js.map +0 -1
  237. package/dist/tui/components/GameOfLife.d.ts.map +0 -1
  238. package/dist/tui/components/GameOfLife.js.map +0 -1
  239. package/dist/tui/components/InputBox.d.ts.map +0 -1
  240. package/dist/tui/components/InputBox.js.map +0 -1
  241. package/dist/tui/components/MessageList.d.ts.map +0 -1
  242. package/dist/tui/components/MessageList.js.map +0 -1
  243. package/dist/tui/components/ReadlineInput.d.ts.map +0 -1
  244. package/dist/tui/components/ReadlineInput.js.map +0 -1
  245. package/dist/tui/components/StatusBar.d.ts.map +0 -1
  246. package/dist/tui/components/StatusBar.js.map +0 -1
  247. package/dist/tui/components/index.d.ts.map +0 -1
  248. package/dist/tui/components/index.js.map +0 -1
  249. package/dist/tui/index.d.ts.map +0 -1
  250. package/dist/tui/index.js.map +0 -1
@@ -4,82 +4,84 @@ import { useChatStore } from "../store/chat-store.js";
4
4
  * Hook for managing chat session lifecycle
5
5
  */
6
6
  export function useChatSession(client) {
7
- const connectionStatus = useChatStore((state) => state.connectionStatus);
8
- const sessionId = useChatStore((state) => state.sessionId);
9
- const setConnectionStatus = useChatStore(
10
- (state) => state.setConnectionStatus,
11
- );
12
- const setSessionId = useChatStore((state) => state.setSessionId);
13
- const setError = useChatStore((state) => state.setError);
14
- const clearMessages = useChatStore((state) => state.clearMessages);
15
- /**
16
- * Connect to the agent
17
- */
18
- const connect = useCallback(async () => {
19
- if (!client) {
20
- setError("No client available");
21
- return;
22
- }
23
- try {
24
- setConnectionStatus("connecting");
25
- setError(null);
26
- await client.connect();
27
- setConnectionStatus("connected");
28
- } catch (error) {
29
- console.log(error);
30
- const message = error instanceof Error ? error.message : String(error);
31
- setError(message);
32
- setConnectionStatus("error");
33
- }
34
- }, [client, setConnectionStatus, setError]);
35
- /**
36
- * Start a new session
37
- */
38
- const startSession = useCallback(async () => {
39
- if (!client) {
40
- setError("No client available");
41
- return;
42
- }
43
- try {
44
- const id = await client.startSession();
45
- setSessionId(id);
46
- clearMessages();
47
- } catch (error) {
48
- const message = error instanceof Error ? error.message : String(error);
49
- setError(message);
50
- }
51
- }, [client, setSessionId, setError, clearMessages]);
52
- /**
53
- * Disconnect from the agent
54
- */
55
- const disconnect = useCallback(async () => {
56
- if (!client) return;
57
- try {
58
- await client.disconnect();
59
- setConnectionStatus("disconnected");
60
- setSessionId(null);
61
- } catch (error) {
62
- const message = error instanceof Error ? error.message : String(error);
63
- setError(message);
64
- }
65
- }, [client, setConnectionStatus, setSessionId, setError]);
66
- // Auto-connect on mount if client is available
67
- useEffect(() => {
68
- if (client && connectionStatus === "disconnected") {
69
- connect();
70
- }
71
- }, [client, connectionStatus, connect]);
72
- // Auto-start session after connecting
73
- useEffect(() => {
74
- if (connectionStatus === "connected" && !sessionId) {
75
- startSession();
76
- }
77
- }, [connectionStatus, sessionId, startSession]);
78
- return {
79
- connectionStatus,
80
- sessionId,
81
- connect,
82
- startSession,
83
- disconnect,
84
- };
7
+ const connectionStatus = useChatStore((state) => state.connectionStatus);
8
+ const sessionId = useChatStore((state) => state.sessionId);
9
+ const setConnectionStatus = useChatStore((state) => state.setConnectionStatus);
10
+ const setSessionId = useChatStore((state) => state.setSessionId);
11
+ const setError = useChatStore((state) => state.setError);
12
+ const clearMessages = useChatStore((state) => state.clearMessages);
13
+ /**
14
+ * Connect to the agent
15
+ */
16
+ const connect = useCallback(async () => {
17
+ if (!client) {
18
+ setError("No client available");
19
+ return;
20
+ }
21
+ try {
22
+ setConnectionStatus("connecting");
23
+ setError(null);
24
+ await client.connect();
25
+ setConnectionStatus("connected");
26
+ }
27
+ catch (error) {
28
+ console.log(error);
29
+ const message = error instanceof Error ? error.message : String(error);
30
+ setError(message);
31
+ setConnectionStatus("error");
32
+ }
33
+ }, [client, setConnectionStatus, setError]);
34
+ /**
35
+ * Start a new session
36
+ */
37
+ const startSession = useCallback(async () => {
38
+ if (!client) {
39
+ setError("No client available");
40
+ return;
41
+ }
42
+ try {
43
+ const id = await client.startSession();
44
+ setSessionId(id);
45
+ clearMessages();
46
+ }
47
+ catch (error) {
48
+ const message = error instanceof Error ? error.message : String(error);
49
+ setError(message);
50
+ }
51
+ }, [client, setSessionId, setError, clearMessages]);
52
+ /**
53
+ * Disconnect from the agent
54
+ */
55
+ const disconnect = useCallback(async () => {
56
+ if (!client)
57
+ return;
58
+ try {
59
+ await client.disconnect();
60
+ setConnectionStatus("disconnected");
61
+ setSessionId(null);
62
+ }
63
+ catch (error) {
64
+ const message = error instanceof Error ? error.message : String(error);
65
+ setError(message);
66
+ }
67
+ }, [client, setConnectionStatus, setSessionId, setError]);
68
+ // Auto-connect on mount if client is available
69
+ useEffect(() => {
70
+ if (client && connectionStatus === "disconnected") {
71
+ connect();
72
+ }
73
+ }, [client, connectionStatus, connect]);
74
+ // Auto-start session after connecting
75
+ useEffect(() => {
76
+ if (connectionStatus === "connected" && !sessionId) {
77
+ startSession();
78
+ }
79
+ }, [connectionStatus, sessionId, startSession]);
80
+ return {
81
+ connectionStatus,
82
+ sessionId,
83
+ connect,
84
+ startSession,
85
+ disconnect,
86
+ };
85
87
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @town/ui/core
2
+ * @townco/ui/core
3
3
  *
4
4
  * Headless UI components for chat
5
5
  * Contains business logic, state management, and hooks
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @town/ui/core
2
+ * @townco/ui/core
3
3
  *
4
4
  * Headless UI components for chat
5
5
  * Contains business logic, state management, and hooks
@@ -5,101 +5,74 @@ import { z } from "zod";
5
5
  /**
6
6
  * Display message schema (UI representation of messages)
7
7
  */
8
- export declare const DisplayMessage: z.ZodObject<
9
- {
10
- id: z.ZodString;
11
- role: z.ZodEnum<{
12
- user: "user";
13
- assistant: "assistant";
14
- system: "system";
15
- }>;
16
- content: z.ZodString;
17
- timestamp: z.ZodISODateTime;
18
- isStreaming: z.ZodDefault<z.ZodBoolean>;
19
- streamingStartTime: z.ZodOptional<z.ZodNumber>;
20
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
21
- },
22
- z.core.$strip
23
- >;
8
+ export declare const DisplayMessage: z.ZodObject<{
9
+ id: z.ZodString;
10
+ role: z.ZodEnum<{
11
+ user: "user";
12
+ assistant: "assistant";
13
+ system: "system";
14
+ }>;
15
+ content: z.ZodString;
16
+ timestamp: z.ZodISODateTime;
17
+ isStreaming: z.ZodDefault<z.ZodBoolean>;
18
+ streamingStartTime: z.ZodOptional<z.ZodNumber>;
19
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
20
+ }, z.core.$strip>;
24
21
  export type DisplayMessage = z.infer<typeof DisplayMessage>;
25
22
  /**
26
23
  * Input state schema
27
24
  */
28
- export declare const InputState: z.ZodObject<
29
- {
30
- value: z.ZodString;
31
- isSubmitting: z.ZodBoolean;
32
- attachedFiles: z.ZodArray<
33
- z.ZodObject<
34
- {
35
- name: z.ZodString;
36
- path: z.ZodString;
37
- size: z.ZodNumber;
38
- mimeType: z.ZodString;
39
- },
40
- z.core.$strip
41
- >
42
- >;
43
- },
44
- z.core.$strip
45
- >;
25
+ export declare const InputState: z.ZodObject<{
26
+ value: z.ZodString;
27
+ isSubmitting: z.ZodBoolean;
28
+ attachedFiles: z.ZodArray<z.ZodObject<{
29
+ name: z.ZodString;
30
+ path: z.ZodString;
31
+ size: z.ZodNumber;
32
+ mimeType: z.ZodString;
33
+ }, z.core.$strip>>;
34
+ }, z.core.$strip>;
46
35
  export type InputState = z.infer<typeof InputState>;
47
36
  /**
48
37
  * Chat session UI state
49
38
  */
50
- export declare const ChatSessionState: z.ZodObject<
51
- {
52
- sessionId: z.ZodNullable<z.ZodString>;
53
- isConnected: z.ZodBoolean;
54
- isStreaming: z.ZodBoolean;
55
- messages: z.ZodArray<
56
- z.ZodObject<
57
- {
58
- id: z.ZodString;
59
- role: z.ZodEnum<{
60
- user: "user";
61
- assistant: "assistant";
62
- system: "system";
63
- }>;
64
- content: z.ZodString;
65
- timestamp: z.ZodISODateTime;
66
- isStreaming: z.ZodDefault<z.ZodBoolean>;
67
- streamingStartTime: z.ZodOptional<z.ZodNumber>;
68
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
69
- },
70
- z.core.$strip
71
- >
72
- >;
73
- input: z.ZodObject<
74
- {
75
- value: z.ZodString;
76
- isSubmitting: z.ZodBoolean;
77
- attachedFiles: z.ZodArray<
78
- z.ZodObject<
79
- {
80
- name: z.ZodString;
81
- path: z.ZodString;
82
- size: z.ZodNumber;
83
- mimeType: z.ZodString;
84
- },
85
- z.core.$strip
86
- >
87
- >;
88
- },
89
- z.core.$strip
90
- >;
91
- error: z.ZodNullable<z.ZodString>;
92
- },
93
- z.core.$strip
94
- >;
39
+ export declare const ChatSessionState: z.ZodObject<{
40
+ sessionId: z.ZodNullable<z.ZodString>;
41
+ isConnected: z.ZodBoolean;
42
+ isStreaming: z.ZodBoolean;
43
+ messages: z.ZodArray<z.ZodObject<{
44
+ id: z.ZodString;
45
+ role: z.ZodEnum<{
46
+ user: "user";
47
+ assistant: "assistant";
48
+ system: "system";
49
+ }>;
50
+ content: z.ZodString;
51
+ timestamp: z.ZodISODateTime;
52
+ isStreaming: z.ZodDefault<z.ZodBoolean>;
53
+ streamingStartTime: z.ZodOptional<z.ZodNumber>;
54
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
55
+ }, z.core.$strip>>;
56
+ input: z.ZodObject<{
57
+ value: z.ZodString;
58
+ isSubmitting: z.ZodBoolean;
59
+ attachedFiles: z.ZodArray<z.ZodObject<{
60
+ name: z.ZodString;
61
+ path: z.ZodString;
62
+ size: z.ZodNumber;
63
+ mimeType: z.ZodString;
64
+ }, z.core.$strip>>;
65
+ }, z.core.$strip>;
66
+ error: z.ZodNullable<z.ZodString>;
67
+ }, z.core.$strip>;
95
68
  export type ChatSessionState = z.infer<typeof ChatSessionState>;
96
69
  /**
97
70
  * Connection status
98
71
  */
99
72
  export declare const ConnectionStatus: z.ZodEnum<{
100
- error: "error";
101
- disconnected: "disconnected";
102
- connecting: "connecting";
103
- connected: "connected";
73
+ error: "error";
74
+ connecting: "connecting";
75
+ connected: "connected";
76
+ disconnected: "disconnected";
104
77
  }>;
105
78
  export type ConnectionStatus = z.infer<typeof ConnectionStatus>;
@@ -6,46 +6,44 @@ import { z } from "zod";
6
6
  * Display message schema (UI representation of messages)
7
7
  */
8
8
  export const DisplayMessage = z.object({
9
- id: z.string(),
10
- role: z.enum(["user", "assistant", "system"]),
11
- content: z.string(),
12
- timestamp: z.iso.datetime(),
13
- isStreaming: z.boolean().default(false),
14
- streamingStartTime: z.number().optional(), // Unix timestamp when streaming started
15
- metadata: z.record(z.string(), z.unknown()).optional(),
9
+ id: z.string(),
10
+ role: z.enum(["user", "assistant", "system"]),
11
+ content: z.string(),
12
+ timestamp: z.iso.datetime(),
13
+ isStreaming: z.boolean().default(false),
14
+ streamingStartTime: z.number().optional(), // Unix timestamp when streaming started
15
+ metadata: z.record(z.string(), z.unknown()).optional(),
16
16
  });
17
17
  /**
18
18
  * Input state schema
19
19
  */
20
20
  export const InputState = z.object({
21
- value: z.string(),
22
- isSubmitting: z.boolean(),
23
- attachedFiles: z.array(
24
- z.object({
25
- name: z.string(),
26
- path: z.string(),
27
- size: z.number(),
28
- mimeType: z.string(),
29
- }),
30
- ),
21
+ value: z.string(),
22
+ isSubmitting: z.boolean(),
23
+ attachedFiles: z.array(z.object({
24
+ name: z.string(),
25
+ path: z.string(),
26
+ size: z.number(),
27
+ mimeType: z.string(),
28
+ })),
31
29
  });
32
30
  /**
33
31
  * Chat session UI state
34
32
  */
35
33
  export const ChatSessionState = z.object({
36
- sessionId: z.string().nullable(),
37
- isConnected: z.boolean(),
38
- isStreaming: z.boolean(),
39
- messages: z.array(DisplayMessage),
40
- input: InputState,
41
- error: z.string().nullable(),
34
+ sessionId: z.string().nullable(),
35
+ isConnected: z.boolean(),
36
+ isStreaming: z.boolean(),
37
+ messages: z.array(DisplayMessage),
38
+ input: InputState,
39
+ error: z.string().nullable(),
42
40
  });
43
41
  /**
44
42
  * Connection status
45
43
  */
46
44
  export const ConnectionStatus = z.enum([
47
- "disconnected",
48
- "connecting",
49
- "connected",
50
- "error",
45
+ "disconnected",
46
+ "connecting",
47
+ "connected",
48
+ "error",
51
49
  ]);
@@ -1,36 +1,30 @@
1
- import type {
2
- ConnectionStatus,
3
- DisplayMessage,
4
- InputState,
5
- } from "../schemas/index.js";
1
+ import type { ConnectionStatus, DisplayMessage, InputState } from "../schemas/index.js";
6
2
  /**
7
3
  * Chat store state
8
4
  */
9
5
  export interface ChatStore {
10
- connectionStatus: ConnectionStatus;
11
- sessionId: string | null;
12
- error: string | null;
13
- messages: DisplayMessage[];
14
- isStreaming: boolean;
15
- streamingStartTime: number | null;
16
- input: InputState;
17
- setConnectionStatus: (status: ConnectionStatus) => void;
18
- setSessionId: (id: string | null) => void;
19
- setError: (error: string | null) => void;
20
- addMessage: (message: DisplayMessage) => void;
21
- updateMessage: (id: string, updates: Partial<DisplayMessage>) => void;
22
- clearMessages: () => void;
23
- setIsStreaming: (streaming: boolean) => void;
24
- setStreamingStartTime: (time: number | null) => void;
25
- setInputValue: (value: string) => void;
26
- setInputSubmitting: (submitting: boolean) => void;
27
- addFileAttachment: (file: InputState["attachedFiles"][number]) => void;
28
- removeFileAttachment: (index: number) => void;
29
- clearInput: () => void;
6
+ connectionStatus: ConnectionStatus;
7
+ sessionId: string | null;
8
+ error: string | null;
9
+ messages: DisplayMessage[];
10
+ isStreaming: boolean;
11
+ streamingStartTime: number | null;
12
+ input: InputState;
13
+ setConnectionStatus: (status: ConnectionStatus) => void;
14
+ setSessionId: (id: string | null) => void;
15
+ setError: (error: string | null) => void;
16
+ addMessage: (message: DisplayMessage) => void;
17
+ updateMessage: (id: string, updates: Partial<DisplayMessage>) => void;
18
+ clearMessages: () => void;
19
+ setIsStreaming: (streaming: boolean) => void;
20
+ setStreamingStartTime: (time: number | null) => void;
21
+ setInputValue: (value: string) => void;
22
+ setInputSubmitting: (submitting: boolean) => void;
23
+ addFileAttachment: (file: InputState["attachedFiles"][number]) => void;
24
+ removeFileAttachment: (index: number) => void;
25
+ clearInput: () => void;
30
26
  }
31
27
  /**
32
28
  * Create chat store
33
29
  */
34
- export declare const useChatStore: import("zustand").UseBoundStore<
35
- import("zustand").StoreApi<ChatStore>
36
- >;
30
+ export declare const useChatStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ChatStore>>;
@@ -3,63 +3,54 @@ import { create } from "zustand";
3
3
  * Create chat store
4
4
  */
5
5
  export const useChatStore = create((set) => ({
6
- // Initial state
7
- connectionStatus: "disconnected",
8
- sessionId: null,
9
- error: null,
10
- messages: [],
11
- isStreaming: false,
12
- streamingStartTime: null,
13
- input: {
14
- value: "",
15
- isSubmitting: false,
16
- attachedFiles: [],
17
- },
18
- // Actions
19
- setConnectionStatus: (status) => set({ connectionStatus: status }),
20
- setSessionId: (id) => set({ sessionId: id }),
21
- setError: (error) => set({ error }),
22
- addMessage: (message) =>
23
- set((state) => ({
24
- messages: [...state.messages, message],
25
- })),
26
- updateMessage: (id, updates) =>
27
- set((state) => ({
28
- messages: state.messages.map((msg) =>
29
- msg.id === id ? { ...msg, ...updates } : msg,
30
- ),
31
- })),
32
- clearMessages: () => set({ messages: [] }),
33
- setIsStreaming: (streaming) => set({ isStreaming: streaming }),
34
- setStreamingStartTime: (time) => set({ streamingStartTime: time }),
35
- setInputValue: (value) =>
36
- set((state) => ({
37
- input: { ...state.input, value },
38
- })),
39
- setInputSubmitting: (submitting) =>
40
- set((state) => ({
41
- input: { ...state.input, isSubmitting: submitting },
42
- })),
43
- addFileAttachment: (file) =>
44
- set((state) => ({
45
- input: {
46
- ...state.input,
47
- attachedFiles: [...state.input.attachedFiles, file],
48
- },
49
- })),
50
- removeFileAttachment: (index) =>
51
- set((state) => ({
52
- input: {
53
- ...state.input,
54
- attachedFiles: state.input.attachedFiles.filter((_, i) => i !== index),
55
- },
56
- })),
57
- clearInput: () =>
58
- set((_state) => ({
59
- input: {
60
- value: "",
61
- isSubmitting: false,
62
- attachedFiles: [],
63
- },
64
- })),
6
+ // Initial state
7
+ connectionStatus: "disconnected",
8
+ sessionId: null,
9
+ error: null,
10
+ messages: [],
11
+ isStreaming: false,
12
+ streamingStartTime: null,
13
+ input: {
14
+ value: "",
15
+ isSubmitting: false,
16
+ attachedFiles: [],
17
+ },
18
+ // Actions
19
+ setConnectionStatus: (status) => set({ connectionStatus: status }),
20
+ setSessionId: (id) => set({ sessionId: id }),
21
+ setError: (error) => set({ error }),
22
+ addMessage: (message) => set((state) => ({
23
+ messages: [...state.messages, message],
24
+ })),
25
+ updateMessage: (id, updates) => set((state) => ({
26
+ messages: state.messages.map((msg) => msg.id === id ? { ...msg, ...updates } : msg),
27
+ })),
28
+ clearMessages: () => set({ messages: [] }),
29
+ setIsStreaming: (streaming) => set({ isStreaming: streaming }),
30
+ setStreamingStartTime: (time) => set({ streamingStartTime: time }),
31
+ setInputValue: (value) => set((state) => ({
32
+ input: { ...state.input, value },
33
+ })),
34
+ setInputSubmitting: (submitting) => set((state) => ({
35
+ input: { ...state.input, isSubmitting: submitting },
36
+ })),
37
+ addFileAttachment: (file) => set((state) => ({
38
+ input: {
39
+ ...state.input,
40
+ attachedFiles: [...state.input.attachedFiles, file],
41
+ },
42
+ })),
43
+ removeFileAttachment: (index) => set((state) => ({
44
+ input: {
45
+ ...state.input,
46
+ attachedFiles: state.input.attachedFiles.filter((_, i) => i !== index),
47
+ },
48
+ })),
49
+ clearInput: () => set((_state) => ({
50
+ input: {
51
+ value: "",
52
+ isSubmitting: false,
53
+ attachedFiles: [],
54
+ },
55
+ })),
65
56
  }));
@@ -1,27 +1,11 @@
1
1
  import { type VariantProps } from "class-variance-authority";
2
2
  import * as React from "react";
3
- declare const buttonVariants: (
4
- props?:
5
- | ({
6
- variant?:
7
- | "default"
8
- | "destructive"
9
- | "outline"
10
- | "secondary"
11
- | "ghost"
12
- | "link"
13
- | null
14
- | undefined;
15
- size?: "default" | "sm" | "lg" | "icon" | null | undefined;
16
- } & import("class-variance-authority/types").ClassProp)
17
- | undefined,
18
- ) => string;
19
- export interface ButtonProps
20
- extends React.ButtonHTMLAttributes<HTMLButtonElement>,
21
- VariantProps<typeof buttonVariants> {
22
- asChild?: boolean;
3
+ declare const buttonVariants: (props?: ({
4
+ variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
5
+ size?: "default" | "sm" | "lg" | "icon" | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
+ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
8
+ asChild?: boolean;
23
9
  }
24
- declare const Button: React.ForwardRefExoticComponent<
25
- ButtonProps & React.RefAttributes<HTMLButtonElement>
26
- >;
10
+ declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
27
11
  export { Button, buttonVariants };