@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.
- package/README.md +11 -11
- package/dist/core/hooks/use-chat-input.d.ts +17 -17
- package/dist/core/hooks/use-chat-input.js +55 -64
- package/dist/core/hooks/use-chat-messages.d.ts +11 -11
- package/dist/core/hooks/use-chat-messages.js +114 -121
- package/dist/core/hooks/use-chat-session.d.ts +5 -5
- package/dist/core/hooks/use-chat-session.js +80 -78
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/schemas/chat.d.ts +56 -83
- package/dist/core/schemas/chat.js +25 -27
- package/dist/core/store/chat-store.d.ts +22 -28
- package/dist/core/store/chat-store.js +50 -59
- package/dist/gui/components/Button.d.ts +7 -23
- package/dist/gui/components/Button.js +27 -40
- package/dist/gui/components/Card.d.ts +7 -26
- package/dist/gui/components/Card.js +8 -54
- package/dist/gui/components/ChatInput.d.ts +36 -58
- package/dist/gui/components/ChatInput.js +121 -191
- package/dist/gui/components/ChatSecondaryPanel.d.ts +11 -14
- package/dist/gui/components/ChatSecondaryPanel.js +38 -115
- package/dist/gui/components/ChatStatus.d.ts +2 -4
- package/dist/gui/components/ChatStatus.js +34 -45
- package/dist/gui/components/Conversation.d.ts +14 -17
- package/dist/gui/components/Conversation.js +83 -143
- package/dist/gui/components/Dialog.d.ts +11 -57
- package/dist/gui/components/Dialog.js +8 -84
- package/dist/gui/components/HeightTransition.d.ts +7 -12
- package/dist/gui/components/HeightTransition.js +77 -88
- package/dist/gui/components/Input.d.ts +6 -13
- package/dist/gui/components/Input.js +16 -27
- package/dist/gui/components/Label.d.ts +1 -7
- package/dist/gui/components/Label.js +2 -12
- package/dist/gui/components/MarkdownRenderer.d.ts +4 -6
- package/dist/gui/components/MarkdownRenderer.js +81 -178
- package/dist/gui/components/Message.d.ts +18 -25
- package/dist/gui/components/Message.js +23 -44
- package/dist/gui/components/MessageContent.d.ts +22 -29
- package/dist/gui/components/MessageContent.js +85 -157
- package/dist/gui/components/Reasoning.d.ts +24 -30
- package/dist/gui/components/Reasoning.js +60 -187
- package/dist/gui/components/Response.d.ts +9 -11
- package/dist/gui/components/Response.js +90 -229
- package/dist/gui/components/Select.d.ts +10 -69
- package/dist/gui/components/Select.js +12 -118
- package/dist/gui/components/Tabs.d.ts +4 -24
- package/dist/gui/components/Tabs.js +4 -32
- package/dist/gui/components/Task.d.ts +24 -28
- package/dist/gui/components/Task.js +31 -164
- package/dist/gui/components/Textarea.d.ts +7 -15
- package/dist/gui/components/Textarea.js +46 -63
- package/dist/gui/components/ThinkingBlock.d.ts +10 -20
- package/dist/gui/components/ThinkingBlock.js +35 -134
- package/dist/gui/components/TodoList.d.ts +10 -12
- package/dist/gui/components/TodoList.js +7 -22
- package/dist/gui/components/TodoListItem.d.ts +6 -9
- package/dist/gui/components/TodoListItem.js +4 -18
- package/dist/gui/components/index.d.ts +8 -59
- package/dist/gui/components/index.js +8 -42
- package/dist/gui/lib/utils.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.test.js +1 -0
- package/dist/sdk/client/acp-client.d.ts +76 -88
- package/dist/sdk/client/acp-client.js +217 -215
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/schemas/agent.d.ts +64 -111
- package/dist/sdk/schemas/agent.js +24 -24
- package/dist/sdk/schemas/message.d.ts +147 -245
- package/dist/sdk/schemas/message.js +40 -40
- package/dist/sdk/schemas/session.d.ts +135 -219
- package/dist/sdk/schemas/session.js +27 -27
- package/dist/sdk/transports/http.d.ts +55 -55
- package/dist/sdk/transports/http.js +469 -472
- package/dist/sdk/transports/stdio.d.ts +20 -20
- package/dist/sdk/transports/stdio.js +286 -289
- package/dist/sdk/transports/types.d.ts +42 -42
- package/dist/sdk/transports/websocket.d.ts +12 -12
- package/dist/sdk/transports/websocket.js +46 -52
- package/dist/tui/components/ChatView.d.ts +2 -4
- package/dist/tui/components/ChatView.js +18 -51
- package/dist/tui/components/GameOfLife.js +35 -64
- package/dist/tui/components/InputBox.d.ts +11 -18
- package/dist/tui/components/InputBox.js +10 -70
- package/dist/tui/components/MessageList.d.ts +2 -4
- package/dist/tui/components/MessageList.js +10 -37
- package/dist/tui/components/MultiSelect.d.ts +10 -15
- package/dist/tui/components/MultiSelect.js +73 -116
- package/dist/tui/components/ReadlineInput.d.ts +6 -12
- package/dist/tui/components/ReadlineInput.js +237 -252
- package/dist/tui/components/SingleSelect.d.ts +9 -15
- package/dist/tui/components/SingleSelect.js +43 -84
- package/dist/tui/components/StatusBar.d.ts +6 -11
- package/dist/tui/components/StatusBar.js +67 -102
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/package.json +2 -2
- package/dist/core/hooks/index.d.ts.map +0 -1
- package/dist/core/hooks/index.js.map +0 -1
- package/dist/core/hooks/use-chat-input.d.ts.map +0 -1
- package/dist/core/hooks/use-chat-input.js.map +0 -1
- package/dist/core/hooks/use-chat-messages.d.ts.map +0 -1
- package/dist/core/hooks/use-chat-messages.js.map +0 -1
- package/dist/core/hooks/use-chat-session.d.ts.map +0 -1
- package/dist/core/hooks/use-chat-session.js.map +0 -1
- package/dist/core/hooks/use-media-query.d.ts +0 -39
- package/dist/core/hooks/use-media-query.js +0 -80
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/core/schemas/chat.d.ts.map +0 -1
- package/dist/core/schemas/chat.js.map +0 -1
- package/dist/core/schemas/index.d.ts.map +0 -1
- package/dist/core/schemas/index.js.map +0 -1
- package/dist/core/store/chat-store.d.ts.map +0 -1
- package/dist/core/store/chat-store.js.map +0 -1
- package/dist/gui/components/Button.d.ts.map +0 -1
- package/dist/gui/components/Button.js.map +0 -1
- package/dist/gui/components/Card.d.ts.map +0 -1
- package/dist/gui/components/Card.js.map +0 -1
- package/dist/gui/components/ChatHeader.d.ts +0 -65
- package/dist/gui/components/ChatHeader.js +0 -189
- package/dist/gui/components/ChatInput.d.ts.map +0 -1
- package/dist/gui/components/ChatInput.js.map +0 -1
- package/dist/gui/components/ChatInterface.d.ts +0 -12
- package/dist/gui/components/ChatInterface.d.ts.map +0 -1
- package/dist/gui/components/ChatInterface.js +0 -204
- package/dist/gui/components/ChatInterface.js.map +0 -1
- package/dist/gui/components/ChatLayout.d.ts +0 -82
- package/dist/gui/components/ChatLayout.js +0 -232
- package/dist/gui/components/ChatPanelTabContent.d.ts +0 -27
- package/dist/gui/components/ChatPanelTabContent.js +0 -93
- package/dist/gui/components/ChatPreview.d.ts +0 -12
- package/dist/gui/components/ChatPreview.d.ts.map +0 -1
- package/dist/gui/components/ChatPreview.js +0 -214
- package/dist/gui/components/ChatPreview.js.map +0 -1
- package/dist/gui/components/ChatSecondaryPanel.d.ts.map +0 -1
- package/dist/gui/components/ChatSecondaryPanel.js.map +0 -1
- package/dist/gui/components/ChatSidebar.d.ts +0 -27
- package/dist/gui/components/ChatSidebar.js +0 -57
- package/dist/gui/components/ChatStatus.d.ts.map +0 -1
- package/dist/gui/components/ChatStatus.js.map +0 -1
- package/dist/gui/components/ChatView.d.ts +0 -8
- package/dist/gui/components/ChatView.d.ts.map +0 -1
- package/dist/gui/components/ChatView.js +0 -42
- package/dist/gui/components/ChatView.js.map +0 -1
- package/dist/gui/components/ConfigPanel.d.ts +0 -20
- package/dist/gui/components/ConfigPanel.d.ts.map +0 -1
- package/dist/gui/components/ConfigPanel.js +0 -225
- package/dist/gui/components/ConfigPanel.js.map +0 -1
- package/dist/gui/components/Conversation.d.ts.map +0 -1
- package/dist/gui/components/Conversation.js.map +0 -1
- package/dist/gui/components/Dialog.d.ts.map +0 -1
- package/dist/gui/components/Dialog.js.map +0 -1
- package/dist/gui/components/DropdownMenu.d.ts +0 -108
- package/dist/gui/components/DropdownMenu.js +0 -215
- package/dist/gui/components/HeightTransition.d.ts.map +0 -1
- package/dist/gui/components/HeightTransition.js.map +0 -1
- package/dist/gui/components/Input.d.ts.map +0 -1
- package/dist/gui/components/Input.js.map +0 -1
- package/dist/gui/components/InputBox.d.ts +0 -21
- package/dist/gui/components/InputBox.d.ts.map +0 -1
- package/dist/gui/components/InputBox.js +0 -90
- package/dist/gui/components/InputBox.js.map +0 -1
- package/dist/gui/components/Label.d.ts.map +0 -1
- package/dist/gui/components/Label.js.map +0 -1
- package/dist/gui/components/MarkdownRenderer.d.ts.map +0 -1
- package/dist/gui/components/MarkdownRenderer.js.map +0 -1
- package/dist/gui/components/Message.d.ts.map +0 -1
- package/dist/gui/components/Message.js.map +0 -1
- package/dist/gui/components/MessageContent.d.ts.map +0 -1
- package/dist/gui/components/MessageContent.js.map +0 -1
- package/dist/gui/components/MessageList.d.ts.map +0 -1
- package/dist/gui/components/MessageList.js.map +0 -1
- package/dist/gui/components/PlaygroundLayout.d.ts +0 -14
- package/dist/gui/components/PlaygroundLayout.d.ts.map +0 -1
- package/dist/gui/components/PlaygroundLayout.js +0 -49
- package/dist/gui/components/PlaygroundLayout.js.map +0 -1
- package/dist/gui/components/Reasoning.d.ts.map +0 -1
- package/dist/gui/components/Reasoning.js.map +0 -1
- package/dist/gui/components/Response.d.ts.map +0 -1
- package/dist/gui/components/Response.js.map +0 -1
- package/dist/gui/components/Select.d.ts.map +0 -1
- package/dist/gui/components/Select.js.map +0 -1
- package/dist/gui/components/Sonner.d.ts +0 -7
- package/dist/gui/components/Sonner.js +0 -34
- package/dist/gui/components/StatusBar.d.ts +0 -12
- package/dist/gui/components/StatusBar.d.ts.map +0 -1
- package/dist/gui/components/StatusBar.js +0 -58
- package/dist/gui/components/StatusBar.js.map +0 -1
- package/dist/gui/components/Tabs.d.ts.map +0 -1
- package/dist/gui/components/Tabs.js.map +0 -1
- package/dist/gui/components/Task.d.ts.map +0 -1
- package/dist/gui/components/Task.js.map +0 -1
- package/dist/gui/components/Textarea.d.ts.map +0 -1
- package/dist/gui/components/Textarea.js.map +0 -1
- package/dist/gui/components/ThinkingBlock.d.ts.map +0 -1
- package/dist/gui/components/ThinkingBlock.js.map +0 -1
- package/dist/gui/components/TodoList.d.ts.map +0 -1
- package/dist/gui/components/TodoList.js.map +0 -1
- package/dist/gui/components/TodoListItem.d.ts.map +0 -1
- package/dist/gui/components/TodoListItem.js.map +0 -1
- package/dist/gui/components/index.d.ts.map +0 -1
- package/dist/gui/components/index.js.map +0 -1
- package/dist/gui/index.d.ts.map +0 -1
- package/dist/gui/index.js.map +0 -1
- package/dist/gui/lib/utils.d.ts.map +0 -1
- package/dist/gui/lib/utils.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/sdk/client/acp-client.d.ts.map +0 -1
- package/dist/sdk/client/acp-client.js.map +0 -1
- package/dist/sdk/client/index.d.ts.map +0 -1
- package/dist/sdk/client/index.js.map +0 -1
- package/dist/sdk/index.d.ts.map +0 -1
- package/dist/sdk/index.js.map +0 -1
- package/dist/sdk/schemas/agent.d.ts.map +0 -1
- package/dist/sdk/schemas/agent.js.map +0 -1
- package/dist/sdk/schemas/index.d.ts.map +0 -1
- package/dist/sdk/schemas/index.js.map +0 -1
- package/dist/sdk/schemas/message.d.ts.map +0 -1
- package/dist/sdk/schemas/message.js.map +0 -1
- package/dist/sdk/schemas/session.d.ts.map +0 -1
- package/dist/sdk/schemas/session.js.map +0 -1
- package/dist/sdk/transports/http.d.ts.map +0 -1
- package/dist/sdk/transports/http.js.map +0 -1
- package/dist/sdk/transports/index.d.ts.map +0 -1
- package/dist/sdk/transports/index.js.map +0 -1
- package/dist/sdk/transports/stdio.d.ts.map +0 -1
- package/dist/sdk/transports/stdio.js.map +0 -1
- package/dist/sdk/transports/types.d.ts.map +0 -1
- package/dist/sdk/transports/types.js.map +0 -1
- package/dist/sdk/transports/websocket.d.ts.map +0 -1
- package/dist/sdk/transports/websocket.js.map +0 -1
- package/dist/tui/components/ChatView.d.ts.map +0 -1
- package/dist/tui/components/ChatView.js.map +0 -1
- package/dist/tui/components/GameOfLife.d.ts.map +0 -1
- package/dist/tui/components/GameOfLife.js.map +0 -1
- package/dist/tui/components/InputBox.d.ts.map +0 -1
- package/dist/tui/components/InputBox.js.map +0 -1
- package/dist/tui/components/MessageList.d.ts.map +0 -1
- package/dist/tui/components/MessageList.js.map +0 -1
- package/dist/tui/components/ReadlineInput.d.ts.map +0 -1
- package/dist/tui/components/ReadlineInput.js.map +0 -1
- package/dist/tui/components/StatusBar.d.ts.map +0 -1
- package/dist/tui/components/StatusBar.js.map +0 -1
- package/dist/tui/components/index.d.ts.map +0 -1
- package/dist/tui/components/index.js.map +0 -1
- package/dist/tui/index.d.ts.map +0 -1
- 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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
}
|
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.js
CHANGED
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 };
|