@townco/ui 0.1.15 → 0.1.17
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/dist/core/hooks/index.d.ts +1 -0
- package/dist/core/hooks/index.js +1 -0
- package/dist/core/hooks/use-chat-messages.d.ts +50 -11
- package/dist/core/hooks/use-chat-session.d.ts +5 -5
- package/dist/core/hooks/use-tool-calls.d.ts +52 -0
- package/dist/core/hooks/use-tool-calls.js +61 -0
- package/dist/core/schemas/chat.d.ts +166 -83
- package/dist/core/schemas/chat.js +27 -27
- package/dist/core/schemas/index.d.ts +1 -0
- package/dist/core/schemas/index.js +1 -0
- package/dist/core/schemas/tool-call.d.ts +174 -0
- package/dist/core/schemas/tool-call.js +130 -0
- package/dist/core/store/chat-store.d.ts +28 -28
- package/dist/core/store/chat-store.js +123 -59
- package/dist/gui/components/ChatLayout.js +11 -10
- package/dist/gui/components/Dialog.js +8 -84
- package/dist/gui/components/Label.js +2 -12
- package/dist/gui/components/MessageContent.js +4 -1
- package/dist/gui/components/Select.js +12 -118
- package/dist/gui/components/Tabs.js +4 -32
- package/dist/gui/components/ToolCall.d.ts +8 -0
- package/dist/gui/components/ToolCall.js +100 -0
- package/dist/gui/components/ToolCallList.d.ts +9 -0
- package/dist/gui/components/ToolCallList.js +22 -0
- package/dist/gui/components/index.d.ts +2 -0
- package/dist/gui/components/index.js +2 -0
- package/dist/gui/components/resizable.d.ts +7 -0
- package/dist/gui/components/resizable.js +7 -0
- package/dist/sdk/schemas/session.d.ts +390 -220
- package/dist/sdk/schemas/session.js +74 -29
- package/dist/sdk/transports/http.js +705 -472
- package/dist/sdk/transports/stdio.js +187 -32
- package/dist/tui/components/ChatView.js +19 -51
- package/dist/tui/components/MessageList.d.ts +2 -4
- package/dist/tui/components/MessageList.js +13 -37
- package/dist/tui/components/ToolCall.d.ts +9 -0
- package/dist/tui/components/ToolCall.js +41 -0
- package/dist/tui/components/ToolCallList.d.ts +8 -0
- package/dist/tui/components/ToolCallList.js +17 -0
- package/dist/tui/components/index.d.ts +2 -0
- package/dist/tui/components/index.js +2 -0
- package/package.json +4 -2
package/dist/core/hooks/index.js
CHANGED
|
@@ -3,15 +3,54 @@ import type { AcpClient } from "../../sdk/client/index.js";
|
|
|
3
3
|
* Hook for managing chat messages
|
|
4
4
|
*/
|
|
5
5
|
export declare function useChatMessages(client: AcpClient | null): {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
messages: {
|
|
7
|
+
id: string;
|
|
8
|
+
role: "user" | "assistant" | "system";
|
|
9
|
+
content: string;
|
|
10
|
+
timestamp: string;
|
|
11
|
+
isStreaming: boolean;
|
|
12
|
+
streamingStartTime?: number | undefined;
|
|
13
|
+
metadata?: Record<string, unknown> | undefined;
|
|
14
|
+
toolCalls?: {
|
|
15
|
+
id: string;
|
|
16
|
+
title: string;
|
|
17
|
+
kind: "read" | "edit" | "delete" | "move" | "search" | "execute" | "think" | "fetch" | "switch_mode" | "other";
|
|
18
|
+
status: "pending" | "in_progress" | "completed" | "failed";
|
|
19
|
+
locations?: {
|
|
20
|
+
path: string;
|
|
21
|
+
line?: number | null | undefined;
|
|
22
|
+
}[] | undefined;
|
|
23
|
+
rawInput?: Record<string, unknown> | undefined;
|
|
24
|
+
rawOutput?: Record<string, unknown> | undefined;
|
|
25
|
+
content?: ({
|
|
26
|
+
type: "content";
|
|
27
|
+
content: {
|
|
28
|
+
type: "text";
|
|
29
|
+
text: string;
|
|
30
|
+
};
|
|
31
|
+
} | {
|
|
32
|
+
type: "text";
|
|
33
|
+
text: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: "diff";
|
|
36
|
+
path: string;
|
|
37
|
+
oldText: string;
|
|
38
|
+
newText: string;
|
|
39
|
+
line?: number | null | undefined;
|
|
40
|
+
} | {
|
|
41
|
+
type: "terminal";
|
|
42
|
+
terminalId: string;
|
|
43
|
+
})[] | undefined;
|
|
44
|
+
error?: string | undefined;
|
|
45
|
+
startedAt?: number | undefined;
|
|
46
|
+
completedAt?: number | undefined;
|
|
47
|
+
tokenUsage?: {
|
|
48
|
+
inputTokens?: number | undefined;
|
|
49
|
+
outputTokens?: number | undefined;
|
|
50
|
+
totalTokens?: number | undefined;
|
|
51
|
+
} | undefined;
|
|
52
|
+
}[] | undefined;
|
|
53
|
+
}[];
|
|
54
|
+
isStreaming: boolean;
|
|
55
|
+
sendMessage: (content: string) => Promise<void>;
|
|
17
56
|
};
|
|
@@ -3,9 +3,9 @@ import type { AcpClient } from "../../sdk/client/index.js";
|
|
|
3
3
|
* Hook for managing chat session lifecycle
|
|
4
4
|
*/
|
|
5
5
|
export declare function useChatSession(client: AcpClient | null): {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
connectionStatus: "connecting" | "connected" | "error" | "disconnected";
|
|
7
|
+
sessionId: string | null;
|
|
8
|
+
connect: () => Promise<void>;
|
|
9
|
+
startSession: () => Promise<void>;
|
|
10
|
+
disconnect: () => Promise<void>;
|
|
11
11
|
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { AcpClient } from "../../sdk/client/acp-client.js";
|
|
2
|
+
import type { ToolCall } from "../schemas/tool-call.js";
|
|
3
|
+
/**
|
|
4
|
+
* Hook to track and manage tool calls from ACP sessions
|
|
5
|
+
*
|
|
6
|
+
* Subscribes to session updates and tracks tool call lifecycle:
|
|
7
|
+
* - Receives initial tool_call notifications
|
|
8
|
+
* - Merges incremental tool_call_update notifications
|
|
9
|
+
* - Associates tool calls with sessions
|
|
10
|
+
*/
|
|
11
|
+
export declare function useToolCalls(client: AcpClient | null): {
|
|
12
|
+
toolCalls: Record<string, {
|
|
13
|
+
id: string;
|
|
14
|
+
title: string;
|
|
15
|
+
kind: "read" | "edit" | "delete" | "move" | "search" | "execute" | "think" | "fetch" | "switch_mode" | "other";
|
|
16
|
+
status: "pending" | "in_progress" | "completed" | "failed";
|
|
17
|
+
locations?: {
|
|
18
|
+
path: string;
|
|
19
|
+
line?: number | null | undefined;
|
|
20
|
+
}[] | undefined;
|
|
21
|
+
rawInput?: Record<string, unknown> | undefined;
|
|
22
|
+
rawOutput?: Record<string, unknown> | undefined;
|
|
23
|
+
content?: ({
|
|
24
|
+
type: "content";
|
|
25
|
+
content: {
|
|
26
|
+
type: "text";
|
|
27
|
+
text: string;
|
|
28
|
+
};
|
|
29
|
+
} | {
|
|
30
|
+
type: "text";
|
|
31
|
+
text: string;
|
|
32
|
+
} | {
|
|
33
|
+
type: "diff";
|
|
34
|
+
path: string;
|
|
35
|
+
oldText: string;
|
|
36
|
+
newText: string;
|
|
37
|
+
line?: number | null | undefined;
|
|
38
|
+
} | {
|
|
39
|
+
type: "terminal";
|
|
40
|
+
terminalId: string;
|
|
41
|
+
})[] | undefined;
|
|
42
|
+
error?: string | undefined;
|
|
43
|
+
startedAt?: number | undefined;
|
|
44
|
+
completedAt?: number | undefined;
|
|
45
|
+
tokenUsage?: {
|
|
46
|
+
inputTokens?: number | undefined;
|
|
47
|
+
outputTokens?: number | undefined;
|
|
48
|
+
totalTokens?: number | undefined;
|
|
49
|
+
} | undefined;
|
|
50
|
+
}[]>;
|
|
51
|
+
getToolCallsForSession: (sessionId: string) => ToolCall[];
|
|
52
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useChatStore } from "../store/chat-store.js";
|
|
3
|
+
/**
|
|
4
|
+
* Hook to track and manage tool calls from ACP sessions
|
|
5
|
+
*
|
|
6
|
+
* Subscribes to session updates and tracks tool call lifecycle:
|
|
7
|
+
* - Receives initial tool_call notifications
|
|
8
|
+
* - Merges incremental tool_call_update notifications
|
|
9
|
+
* - Associates tool calls with sessions
|
|
10
|
+
*/
|
|
11
|
+
export function useToolCalls(client) {
|
|
12
|
+
const toolCalls = useChatStore((state) => state.toolCalls);
|
|
13
|
+
const addToolCall = useChatStore((state) => state.addToolCall);
|
|
14
|
+
const updateToolCall = useChatStore((state) => state.updateToolCall);
|
|
15
|
+
const addToolCallToCurrentMessage = useChatStore((state) => state.addToolCallToCurrentMessage);
|
|
16
|
+
const updateToolCallInCurrentMessage = useChatStore((state) => state.updateToolCallInCurrentMessage);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (!client)
|
|
19
|
+
return;
|
|
20
|
+
// Subscribe to session updates for tool calls
|
|
21
|
+
const unsubscribe = client.onSessionUpdate((update) => {
|
|
22
|
+
if (update.type === "tool_call") {
|
|
23
|
+
// Initial tool call notification
|
|
24
|
+
// Add to session-level tool calls (for sidebar)
|
|
25
|
+
addToolCall(update.sessionId, update.toolCall);
|
|
26
|
+
// Also add to current assistant message (for inline display)
|
|
27
|
+
addToolCallToCurrentMessage(update.toolCall);
|
|
28
|
+
}
|
|
29
|
+
else if (update.type === "tool_call_update") {
|
|
30
|
+
// Tool call update notification
|
|
31
|
+
// Update session-level tool calls (for sidebar)
|
|
32
|
+
updateToolCall(update.sessionId, update.toolCallUpdate);
|
|
33
|
+
// Also update in current assistant message (for inline display)
|
|
34
|
+
updateToolCallInCurrentMessage(update.toolCallUpdate);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return () => {
|
|
38
|
+
unsubscribe();
|
|
39
|
+
};
|
|
40
|
+
}, [
|
|
41
|
+
client,
|
|
42
|
+
addToolCall,
|
|
43
|
+
updateToolCall,
|
|
44
|
+
addToolCallToCurrentMessage,
|
|
45
|
+
updateToolCallInCurrentMessage,
|
|
46
|
+
]);
|
|
47
|
+
return {
|
|
48
|
+
toolCalls,
|
|
49
|
+
getToolCallsForSession: (sessionId) => {
|
|
50
|
+
// First try the exact session ID
|
|
51
|
+
const exactMatch = toolCalls[sessionId];
|
|
52
|
+
if (exactMatch && exactMatch.length > 0) {
|
|
53
|
+
return exactMatch;
|
|
54
|
+
}
|
|
55
|
+
// If no exact match, return all tool calls from all sessions
|
|
56
|
+
// This handles the case where the UI session ID doesn't match the ACP session ID
|
|
57
|
+
const allToolCalls = Object.values(toolCalls).flat();
|
|
58
|
+
return allToolCalls;
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -5,101 +5,184 @@ 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
|
-
|
|
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
|
+
toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
title: z.ZodString;
|
|
23
|
+
kind: z.ZodEnum<{
|
|
24
|
+
read: "read";
|
|
25
|
+
edit: "edit";
|
|
26
|
+
delete: "delete";
|
|
27
|
+
move: "move";
|
|
28
|
+
search: "search";
|
|
29
|
+
execute: "execute";
|
|
30
|
+
think: "think";
|
|
31
|
+
fetch: "fetch";
|
|
32
|
+
switch_mode: "switch_mode";
|
|
33
|
+
other: "other";
|
|
34
|
+
}>;
|
|
35
|
+
status: z.ZodEnum<{
|
|
36
|
+
pending: "pending";
|
|
37
|
+
in_progress: "in_progress";
|
|
38
|
+
completed: "completed";
|
|
39
|
+
failed: "failed";
|
|
40
|
+
}>;
|
|
41
|
+
locations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
42
|
+
path: z.ZodString;
|
|
43
|
+
line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
44
|
+
}, z.core.$strip>>>;
|
|
45
|
+
rawInput: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
46
|
+
rawOutput: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
47
|
+
content: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
48
|
+
type: z.ZodLiteral<"content">;
|
|
49
|
+
content: z.ZodObject<{
|
|
50
|
+
type: z.ZodLiteral<"text">;
|
|
51
|
+
text: z.ZodString;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
54
|
+
type: z.ZodLiteral<"text">;
|
|
55
|
+
text: z.ZodString;
|
|
56
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
57
|
+
type: z.ZodLiteral<"diff">;
|
|
58
|
+
path: z.ZodString;
|
|
59
|
+
oldText: z.ZodString;
|
|
60
|
+
newText: z.ZodString;
|
|
61
|
+
line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
62
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
63
|
+
type: z.ZodLiteral<"terminal">;
|
|
64
|
+
terminalId: z.ZodString;
|
|
65
|
+
}, z.core.$strip>], "type">>>;
|
|
66
|
+
error: z.ZodOptional<z.ZodString>;
|
|
67
|
+
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
completedAt: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
tokenUsage: z.ZodOptional<z.ZodObject<{
|
|
70
|
+
inputTokens: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
outputTokens: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
totalTokens: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
}, z.core.$strip>>;
|
|
74
|
+
}, z.core.$strip>>>;
|
|
75
|
+
}, z.core.$strip>;
|
|
24
76
|
export type DisplayMessage = z.infer<typeof DisplayMessage>;
|
|
25
77
|
/**
|
|
26
78
|
* Input state schema
|
|
27
79
|
*/
|
|
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
|
-
>;
|
|
80
|
+
export declare const InputState: z.ZodObject<{
|
|
81
|
+
value: z.ZodString;
|
|
82
|
+
isSubmitting: z.ZodBoolean;
|
|
83
|
+
attachedFiles: z.ZodArray<z.ZodObject<{
|
|
84
|
+
name: z.ZodString;
|
|
85
|
+
path: z.ZodString;
|
|
86
|
+
size: z.ZodNumber;
|
|
87
|
+
mimeType: z.ZodString;
|
|
88
|
+
}, z.core.$strip>>;
|
|
89
|
+
}, z.core.$strip>;
|
|
46
90
|
export type InputState = z.infer<typeof InputState>;
|
|
47
91
|
/**
|
|
48
92
|
* Chat session UI state
|
|
49
93
|
*/
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
>;
|
|
94
|
+
export declare const ChatSessionState: z.ZodObject<{
|
|
95
|
+
sessionId: z.ZodNullable<z.ZodString>;
|
|
96
|
+
isConnected: z.ZodBoolean;
|
|
97
|
+
isStreaming: z.ZodBoolean;
|
|
98
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
99
|
+
id: z.ZodString;
|
|
100
|
+
role: z.ZodEnum<{
|
|
101
|
+
user: "user";
|
|
102
|
+
assistant: "assistant";
|
|
103
|
+
system: "system";
|
|
104
|
+
}>;
|
|
105
|
+
content: z.ZodString;
|
|
106
|
+
timestamp: z.ZodISODateTime;
|
|
107
|
+
isStreaming: z.ZodDefault<z.ZodBoolean>;
|
|
108
|
+
streamingStartTime: z.ZodOptional<z.ZodNumber>;
|
|
109
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
110
|
+
toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
111
|
+
id: z.ZodString;
|
|
112
|
+
title: z.ZodString;
|
|
113
|
+
kind: z.ZodEnum<{
|
|
114
|
+
read: "read";
|
|
115
|
+
edit: "edit";
|
|
116
|
+
delete: "delete";
|
|
117
|
+
move: "move";
|
|
118
|
+
search: "search";
|
|
119
|
+
execute: "execute";
|
|
120
|
+
think: "think";
|
|
121
|
+
fetch: "fetch";
|
|
122
|
+
switch_mode: "switch_mode";
|
|
123
|
+
other: "other";
|
|
124
|
+
}>;
|
|
125
|
+
status: z.ZodEnum<{
|
|
126
|
+
pending: "pending";
|
|
127
|
+
in_progress: "in_progress";
|
|
128
|
+
completed: "completed";
|
|
129
|
+
failed: "failed";
|
|
130
|
+
}>;
|
|
131
|
+
locations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
132
|
+
path: z.ZodString;
|
|
133
|
+
line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
134
|
+
}, z.core.$strip>>>;
|
|
135
|
+
rawInput: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
136
|
+
rawOutput: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
137
|
+
content: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
138
|
+
type: z.ZodLiteral<"content">;
|
|
139
|
+
content: z.ZodObject<{
|
|
140
|
+
type: z.ZodLiteral<"text">;
|
|
141
|
+
text: z.ZodString;
|
|
142
|
+
}, z.core.$strip>;
|
|
143
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
144
|
+
type: z.ZodLiteral<"text">;
|
|
145
|
+
text: z.ZodString;
|
|
146
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
147
|
+
type: z.ZodLiteral<"diff">;
|
|
148
|
+
path: z.ZodString;
|
|
149
|
+
oldText: z.ZodString;
|
|
150
|
+
newText: z.ZodString;
|
|
151
|
+
line: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
152
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
153
|
+
type: z.ZodLiteral<"terminal">;
|
|
154
|
+
terminalId: z.ZodString;
|
|
155
|
+
}, z.core.$strip>], "type">>>;
|
|
156
|
+
error: z.ZodOptional<z.ZodString>;
|
|
157
|
+
startedAt: z.ZodOptional<z.ZodNumber>;
|
|
158
|
+
completedAt: z.ZodOptional<z.ZodNumber>;
|
|
159
|
+
tokenUsage: z.ZodOptional<z.ZodObject<{
|
|
160
|
+
inputTokens: z.ZodOptional<z.ZodNumber>;
|
|
161
|
+
outputTokens: z.ZodOptional<z.ZodNumber>;
|
|
162
|
+
totalTokens: z.ZodOptional<z.ZodNumber>;
|
|
163
|
+
}, z.core.$strip>>;
|
|
164
|
+
}, z.core.$strip>>>;
|
|
165
|
+
}, z.core.$strip>>;
|
|
166
|
+
input: z.ZodObject<{
|
|
167
|
+
value: z.ZodString;
|
|
168
|
+
isSubmitting: z.ZodBoolean;
|
|
169
|
+
attachedFiles: z.ZodArray<z.ZodObject<{
|
|
170
|
+
name: z.ZodString;
|
|
171
|
+
path: z.ZodString;
|
|
172
|
+
size: z.ZodNumber;
|
|
173
|
+
mimeType: z.ZodString;
|
|
174
|
+
}, z.core.$strip>>;
|
|
175
|
+
}, z.core.$strip>;
|
|
176
|
+
error: z.ZodNullable<z.ZodString>;
|
|
177
|
+
}, z.core.$strip>;
|
|
95
178
|
export type ChatSessionState = z.infer<typeof ChatSessionState>;
|
|
96
179
|
/**
|
|
97
180
|
* Connection status
|
|
98
181
|
*/
|
|
99
182
|
export declare const ConnectionStatus: z.ZodEnum<{
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
183
|
+
error: "error";
|
|
184
|
+
connecting: "connecting";
|
|
185
|
+
connected: "connected";
|
|
186
|
+
disconnected: "disconnected";
|
|
104
187
|
}>;
|
|
105
188
|
export type ConnectionStatus = z.infer<typeof ConnectionStatus>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { ToolCallSchema } from "./tool-call.js";
|
|
2
3
|
/**
|
|
3
4
|
* Chat UI state schemas
|
|
4
5
|
*/
|
|
@@ -6,46 +7,45 @@ import { z } from "zod";
|
|
|
6
7
|
* Display message schema (UI representation of messages)
|
|
7
8
|
*/
|
|
8
9
|
export const DisplayMessage = z.object({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
id: z.string(),
|
|
11
|
+
role: z.enum(["user", "assistant", "system"]),
|
|
12
|
+
content: z.string(),
|
|
13
|
+
timestamp: z.iso.datetime(),
|
|
14
|
+
isStreaming: z.boolean().default(false),
|
|
15
|
+
streamingStartTime: z.number().optional(), // Unix timestamp when streaming started
|
|
16
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
17
|
+
toolCalls: z.array(ToolCallSchema).optional(),
|
|
16
18
|
});
|
|
17
19
|
/**
|
|
18
20
|
* Input state schema
|
|
19
21
|
*/
|
|
20
22
|
export const InputState = z.object({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}),
|
|
30
|
-
),
|
|
23
|
+
value: z.string(),
|
|
24
|
+
isSubmitting: z.boolean(),
|
|
25
|
+
attachedFiles: z.array(z.object({
|
|
26
|
+
name: z.string(),
|
|
27
|
+
path: z.string(),
|
|
28
|
+
size: z.number(),
|
|
29
|
+
mimeType: z.string(),
|
|
30
|
+
})),
|
|
31
31
|
});
|
|
32
32
|
/**
|
|
33
33
|
* Chat session UI state
|
|
34
34
|
*/
|
|
35
35
|
export const ChatSessionState = z.object({
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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(),
|
|
42
42
|
});
|
|
43
43
|
/**
|
|
44
44
|
* Connection status
|
|
45
45
|
*/
|
|
46
46
|
export const ConnectionStatus = z.enum([
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
"disconnected",
|
|
48
|
+
"connecting",
|
|
49
|
+
"connected",
|
|
50
|
+
"error",
|
|
51
51
|
]);
|