@townco/ui 0.1.0 → 0.1.3
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/use-chat-input.d.ts +17 -17
- package/dist/core/hooks/use-chat-input.js +64 -55
- package/dist/core/hooks/use-chat-messages.d.ts +11 -11
- package/dist/core/hooks/use-chat-messages.js +121 -114
- package/dist/core/hooks/use-chat-session.d.ts +5 -5
- package/dist/core/hooks/use-chat-session.js +78 -80
- package/dist/core/hooks/use-media-query.d.ts +5 -5
- package/dist/core/hooks/use-media-query.js +38 -38
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/schemas/chat.d.ts +83 -56
- package/dist/core/schemas/chat.js +27 -25
- package/dist/core/store/chat-store.d.ts +28 -22
- package/dist/core/store/chat-store.js +59 -50
- package/dist/gui/components/Button.d.ts +23 -7
- package/dist/gui/components/Button.js +40 -27
- package/dist/gui/components/Card.d.ts +26 -7
- package/dist/gui/components/Card.js +54 -8
- package/dist/gui/components/ChatHeader.d.ts +58 -31
- package/dist/gui/components/ChatHeader.js +171 -66
- package/dist/gui/components/ChatInput.d.ts +58 -36
- package/dist/gui/components/ChatInput.js +191 -121
- package/dist/gui/components/ChatInterface.d.ts +9 -6
- package/dist/gui/components/ChatInterface.js +162 -90
- package/dist/gui/components/ChatLayout.d.ts +71 -41
- package/dist/gui/components/ChatLayout.js +214 -87
- package/dist/gui/components/ChatPanelTabContent.d.ts +18 -9
- package/dist/gui/components/ChatPanelTabContent.js +88 -10
- package/dist/gui/components/ChatPreview.d.ts +9 -6
- package/dist/gui/components/ChatPreview.js +212 -162
- package/dist/gui/components/ChatSecondaryPanel.d.ts +14 -11
- package/dist/gui/components/ChatSecondaryPanel.js +115 -38
- package/dist/gui/components/ChatSidebar.d.ts +26 -13
- package/dist/gui/components/ChatSidebar.js +48 -14
- package/dist/gui/components/ChatStatus.d.ts +4 -2
- package/dist/gui/components/ChatStatus.js +45 -34
- package/dist/gui/components/ChatView.d.ts +5 -3
- package/dist/gui/components/ChatView.js +38 -9
- package/dist/gui/components/ConfigPanel.d.ts +16 -12
- package/dist/gui/components/ConfigPanel.js +218 -41
- package/dist/gui/components/Conversation.d.ts +17 -14
- package/dist/gui/components/Conversation.js +143 -83
- package/dist/gui/components/Dialog.d.ts +57 -11
- package/dist/gui/components/Dialog.js +84 -8
- package/dist/gui/components/DropdownMenu.d.ts +101 -20
- package/dist/gui/components/DropdownMenu.js +161 -14
- package/dist/gui/components/HeightTransition.d.ts +12 -7
- package/dist/gui/components/HeightTransition.js +88 -77
- package/dist/gui/components/Input.d.ts +13 -6
- package/dist/gui/components/Input.js +27 -16
- package/dist/gui/components/InputBox.d.ts +19 -12
- package/dist/gui/components/InputBox.js +86 -14
- package/dist/gui/components/Label.d.ts +7 -1
- package/dist/gui/components/Label.js +12 -2
- package/dist/gui/components/MarkdownRenderer.d.ts +6 -4
- package/dist/gui/components/MarkdownRenderer.js +178 -81
- package/dist/gui/components/Message.d.ts +25 -18
- package/dist/gui/components/Message.js +44 -23
- package/dist/gui/components/MessageContent.d.ts +29 -22
- package/dist/gui/components/MessageContent.js +157 -85
- package/dist/gui/components/PlaygroundLayout.d.ts +9 -5
- package/dist/gui/components/PlaygroundLayout.js +43 -12
- package/dist/gui/components/Reasoning.d.ts +30 -24
- package/dist/gui/components/Reasoning.js +187 -60
- package/dist/gui/components/Response.d.ts +11 -9
- package/dist/gui/components/Response.js +229 -90
- package/dist/gui/components/Select.d.ts +69 -10
- package/dist/gui/components/Select.js +118 -12
- package/dist/gui/components/Sonner.d.ts +3 -1
- package/dist/gui/components/Sonner.js +29 -18
- package/dist/gui/components/StatusBar.d.ts +9 -5
- package/dist/gui/components/StatusBar.js +56 -9
- package/dist/gui/components/Tabs.d.ts +24 -4
- package/dist/gui/components/Tabs.js +32 -4
- package/dist/gui/components/Task.d.ts +28 -24
- package/dist/gui/components/Task.js +164 -31
- package/dist/gui/components/Textarea.d.ts +15 -7
- package/dist/gui/components/Textarea.js +63 -46
- package/dist/gui/components/ThinkingBlock.d.ts +20 -10
- package/dist/gui/components/ThinkingBlock.js +134 -35
- package/dist/gui/components/TodoList.d.ts +12 -10
- package/dist/gui/components/TodoList.js +22 -7
- package/dist/gui/components/TodoListItem.d.ts +9 -6
- package/dist/gui/components/TodoListItem.js +18 -4
- package/dist/gui/components/index.d.ts +59 -8
- package/dist/gui/components/index.js +42 -8
- 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 +0 -1
- package/dist/sdk/client/acp-client.d.ts +88 -76
- package/dist/sdk/client/acp-client.js +215 -217
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/schemas/agent.d.ts +111 -64
- package/dist/sdk/schemas/agent.js +24 -24
- package/dist/sdk/schemas/message.d.ts +245 -147
- package/dist/sdk/schemas/message.js +40 -40
- package/dist/sdk/schemas/session.d.ts +219 -135
- package/dist/sdk/schemas/session.js +27 -27
- package/dist/sdk/transports/http.d.ts +55 -55
- package/dist/sdk/transports/http.js +472 -469
- package/dist/sdk/transports/stdio.d.ts +20 -20
- package/dist/sdk/transports/stdio.js +289 -286
- package/dist/sdk/transports/types.d.ts +42 -42
- package/dist/sdk/transports/websocket.d.ts +12 -12
- package/dist/sdk/transports/websocket.js +52 -46
- package/dist/tui/components/ChatView.d.ts +4 -2
- package/dist/tui/components/ChatView.js +51 -18
- package/dist/tui/components/GameOfLife.js +64 -35
- package/dist/tui/components/InputBox.d.ts +18 -11
- package/dist/tui/components/InputBox.js +70 -10
- package/dist/tui/components/MessageList.d.ts +4 -2
- package/dist/tui/components/MessageList.js +37 -10
- package/dist/tui/components/MultiSelect.d.ts +15 -9
- package/dist/tui/components/MultiSelect.js +116 -69
- package/dist/tui/components/ReadlineInput.d.ts +12 -6
- package/dist/tui/components/ReadlineInput.js +252 -237
- package/dist/tui/components/SingleSelect.d.ts +15 -9
- package/dist/tui/components/SingleSelect.js +84 -43
- package/dist/tui/components/StatusBar.d.ts +11 -6
- package/dist/tui/components/StatusBar.js +102 -67
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +1 -1
- package/package.json +2 -3
|
@@ -3,48 +3,48 @@ import { z } from "zod";
|
|
|
3
3
|
* Agent capability schema
|
|
4
4
|
*/
|
|
5
5
|
export const AgentCapability = z.object({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
name: z.string(),
|
|
7
|
+
description: z.string().optional(),
|
|
8
|
+
parameters: z.record(z.string(), z.unknown()).optional(),
|
|
9
9
|
});
|
|
10
10
|
/**
|
|
11
11
|
* Agent tool schema
|
|
12
12
|
*/
|
|
13
13
|
export const AgentTool = z.object({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
name: z.string(),
|
|
15
|
+
description: z.string(),
|
|
16
|
+
parameters: z.record(z.string(), z.unknown()),
|
|
17
|
+
required: z.array(z.string()).optional(),
|
|
18
18
|
});
|
|
19
19
|
/**
|
|
20
20
|
* Agent information schema
|
|
21
21
|
*/
|
|
22
22
|
export const AgentInfo = z.object({
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
name: z.string(),
|
|
24
|
+
version: z.string().optional(),
|
|
25
|
+
description: z.string().optional(),
|
|
26
|
+
author: z.string().optional(),
|
|
27
|
+
capabilities: z.array(AgentCapability).optional(),
|
|
28
|
+
tools: z.array(AgentTool).optional(),
|
|
29
|
+
supportedFormats: z.array(z.string()).optional(),
|
|
30
30
|
});
|
|
31
31
|
/**
|
|
32
32
|
* Agent status schema
|
|
33
33
|
*/
|
|
34
34
|
export const AgentStatus = z.enum([
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
"initializing",
|
|
36
|
+
"ready",
|
|
37
|
+
"busy",
|
|
38
|
+
"error",
|
|
39
|
+
"terminated",
|
|
40
40
|
]);
|
|
41
41
|
/**
|
|
42
42
|
* Agent state schema
|
|
43
43
|
*/
|
|
44
44
|
export const AgentState = z.object({
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
status: AgentStatus,
|
|
46
|
+
info: AgentInfo.optional(),
|
|
47
|
+
pid: z.number().optional(),
|
|
48
|
+
error: z.string().optional(),
|
|
49
|
+
uptime: z.number().optional(),
|
|
50
50
|
});
|
|
@@ -3,193 +3,291 @@ import { z } from "zod";
|
|
|
3
3
|
* Message role types
|
|
4
4
|
*/
|
|
5
5
|
export declare const MessageRole: z.ZodEnum<{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
user: "user";
|
|
7
|
+
assistant: "assistant";
|
|
8
|
+
system: "system";
|
|
9
|
+
tool: "tool";
|
|
10
10
|
}>;
|
|
11
11
|
export type MessageRole = z.infer<typeof MessageRole>;
|
|
12
12
|
/**
|
|
13
13
|
* Content type for messages
|
|
14
14
|
*/
|
|
15
15
|
export declare const ContentType: z.ZodEnum<{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
text: "text";
|
|
17
|
+
image: "image";
|
|
18
|
+
file: "file";
|
|
19
|
+
tool_call: "tool_call";
|
|
20
|
+
tool_result: "tool_result";
|
|
21
21
|
}>;
|
|
22
22
|
export type ContentType = z.infer<typeof ContentType>;
|
|
23
23
|
/**
|
|
24
24
|
* Base content schema
|
|
25
25
|
*/
|
|
26
|
-
export declare const BaseContent: z.ZodObject<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
26
|
+
export declare const BaseContent: z.ZodObject<
|
|
27
|
+
{
|
|
28
|
+
type: z.ZodEnum<{
|
|
29
|
+
text: "text";
|
|
30
|
+
image: "image";
|
|
31
|
+
file: "file";
|
|
32
|
+
tool_call: "tool_call";
|
|
33
|
+
tool_result: "tool_result";
|
|
34
|
+
}>;
|
|
35
|
+
},
|
|
36
|
+
z.core.$strip
|
|
37
|
+
>;
|
|
35
38
|
/**
|
|
36
39
|
* Text content
|
|
37
40
|
*/
|
|
38
|
-
export declare const TextContent: z.ZodObject<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
export declare const TextContent: z.ZodObject<
|
|
42
|
+
{
|
|
43
|
+
type: z.ZodLiteral<"text">;
|
|
44
|
+
text: z.ZodString;
|
|
45
|
+
},
|
|
46
|
+
z.core.$strip
|
|
47
|
+
>;
|
|
42
48
|
export type TextContent = z.infer<typeof TextContent>;
|
|
43
49
|
/**
|
|
44
50
|
* Image content
|
|
45
51
|
*/
|
|
46
|
-
export declare const ImageContent: z.ZodObject<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
export declare const ImageContent: z.ZodObject<
|
|
53
|
+
{
|
|
54
|
+
type: z.ZodLiteral<"image">;
|
|
55
|
+
url: z.ZodOptional<z.ZodString>;
|
|
56
|
+
data: z.ZodOptional<z.ZodString>;
|
|
57
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
58
|
+
},
|
|
59
|
+
z.core.$strip
|
|
60
|
+
>;
|
|
52
61
|
export type ImageContent = z.infer<typeof ImageContent>;
|
|
53
62
|
/**
|
|
54
63
|
* File attachment content
|
|
55
64
|
*/
|
|
56
|
-
export declare const FileContent: z.ZodObject<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
export declare const FileContent: z.ZodObject<
|
|
66
|
+
{
|
|
67
|
+
type: z.ZodLiteral<"file">;
|
|
68
|
+
name: z.ZodString;
|
|
69
|
+
path: z.ZodOptional<z.ZodString>;
|
|
70
|
+
url: z.ZodOptional<z.ZodString>;
|
|
71
|
+
mimeType: z.ZodString;
|
|
72
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
},
|
|
74
|
+
z.core.$strip
|
|
75
|
+
>;
|
|
64
76
|
export type FileContent = z.infer<typeof FileContent>;
|
|
65
77
|
/**
|
|
66
78
|
* Tool call content
|
|
67
79
|
*/
|
|
68
|
-
export declare const ToolCallContent: z.ZodObject<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
export declare const ToolCallContent: z.ZodObject<
|
|
81
|
+
{
|
|
82
|
+
type: z.ZodLiteral<"tool_call">;
|
|
83
|
+
id: z.ZodString;
|
|
84
|
+
name: z.ZodString;
|
|
85
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
86
|
+
},
|
|
87
|
+
z.core.$strip
|
|
88
|
+
>;
|
|
74
89
|
export type ToolCallContent = z.infer<typeof ToolCallContent>;
|
|
75
90
|
/**
|
|
76
91
|
* Tool result content
|
|
77
92
|
*/
|
|
78
|
-
export declare const ToolResultContent: z.ZodObject<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
93
|
+
export declare const ToolResultContent: z.ZodObject<
|
|
94
|
+
{
|
|
95
|
+
type: z.ZodLiteral<"tool_result">;
|
|
96
|
+
callId: z.ZodString;
|
|
97
|
+
result: z.ZodUnknown;
|
|
98
|
+
error: z.ZodOptional<z.ZodString>;
|
|
99
|
+
},
|
|
100
|
+
z.core.$strip
|
|
101
|
+
>;
|
|
84
102
|
export type ToolResultContent = z.infer<typeof ToolResultContent>;
|
|
85
103
|
/**
|
|
86
104
|
* Union of all content types
|
|
87
105
|
*/
|
|
88
|
-
export declare const Content: z.ZodDiscriminatedUnion<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
export declare const Content: z.ZodDiscriminatedUnion<
|
|
107
|
+
[
|
|
108
|
+
z.ZodObject<
|
|
109
|
+
{
|
|
110
|
+
type: z.ZodLiteral<"text">;
|
|
111
|
+
text: z.ZodString;
|
|
112
|
+
},
|
|
113
|
+
z.core.$strip
|
|
114
|
+
>,
|
|
115
|
+
z.ZodObject<
|
|
116
|
+
{
|
|
117
|
+
type: z.ZodLiteral<"image">;
|
|
118
|
+
url: z.ZodOptional<z.ZodString>;
|
|
119
|
+
data: z.ZodOptional<z.ZodString>;
|
|
120
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
121
|
+
},
|
|
122
|
+
z.core.$strip
|
|
123
|
+
>,
|
|
124
|
+
z.ZodObject<
|
|
125
|
+
{
|
|
126
|
+
type: z.ZodLiteral<"file">;
|
|
127
|
+
name: z.ZodString;
|
|
128
|
+
path: z.ZodOptional<z.ZodString>;
|
|
129
|
+
url: z.ZodOptional<z.ZodString>;
|
|
130
|
+
mimeType: z.ZodString;
|
|
131
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
},
|
|
133
|
+
z.core.$strip
|
|
134
|
+
>,
|
|
135
|
+
z.ZodObject<
|
|
136
|
+
{
|
|
137
|
+
type: z.ZodLiteral<"tool_call">;
|
|
138
|
+
id: z.ZodString;
|
|
139
|
+
name: z.ZodString;
|
|
140
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
141
|
+
},
|
|
142
|
+
z.core.$strip
|
|
143
|
+
>,
|
|
144
|
+
z.ZodObject<
|
|
145
|
+
{
|
|
146
|
+
type: z.ZodLiteral<"tool_result">;
|
|
147
|
+
callId: z.ZodString;
|
|
148
|
+
result: z.ZodUnknown;
|
|
149
|
+
error: z.ZodOptional<z.ZodString>;
|
|
150
|
+
},
|
|
151
|
+
z.core.$strip
|
|
152
|
+
>,
|
|
153
|
+
],
|
|
154
|
+
"type"
|
|
155
|
+
>;
|
|
114
156
|
export type Content = z.infer<typeof Content>;
|
|
115
157
|
/**
|
|
116
158
|
* Message schema
|
|
117
159
|
*/
|
|
118
|
-
export declare const Message: z.ZodObject<
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
},
|
|
160
|
+
export declare const Message: z.ZodObject<
|
|
161
|
+
{
|
|
162
|
+
id: z.ZodString;
|
|
163
|
+
role: z.ZodEnum<{
|
|
164
|
+
user: "user";
|
|
165
|
+
assistant: "assistant";
|
|
166
|
+
system: "system";
|
|
167
|
+
tool: "tool";
|
|
168
|
+
}>;
|
|
169
|
+
content: z.ZodArray<
|
|
170
|
+
z.ZodDiscriminatedUnion<
|
|
171
|
+
[
|
|
172
|
+
z.ZodObject<
|
|
173
|
+
{
|
|
174
|
+
type: z.ZodLiteral<"text">;
|
|
175
|
+
text: z.ZodString;
|
|
176
|
+
},
|
|
177
|
+
z.core.$strip
|
|
178
|
+
>,
|
|
179
|
+
z.ZodObject<
|
|
180
|
+
{
|
|
181
|
+
type: z.ZodLiteral<"image">;
|
|
182
|
+
url: z.ZodOptional<z.ZodString>;
|
|
183
|
+
data: z.ZodOptional<z.ZodString>;
|
|
184
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
185
|
+
},
|
|
186
|
+
z.core.$strip
|
|
187
|
+
>,
|
|
188
|
+
z.ZodObject<
|
|
189
|
+
{
|
|
190
|
+
type: z.ZodLiteral<"file">;
|
|
191
|
+
name: z.ZodString;
|
|
192
|
+
path: z.ZodOptional<z.ZodString>;
|
|
193
|
+
url: z.ZodOptional<z.ZodString>;
|
|
194
|
+
mimeType: z.ZodString;
|
|
195
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
196
|
+
},
|
|
197
|
+
z.core.$strip
|
|
198
|
+
>,
|
|
199
|
+
z.ZodObject<
|
|
200
|
+
{
|
|
201
|
+
type: z.ZodLiteral<"tool_call">;
|
|
202
|
+
id: z.ZodString;
|
|
203
|
+
name: z.ZodString;
|
|
204
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
205
|
+
},
|
|
206
|
+
z.core.$strip
|
|
207
|
+
>,
|
|
208
|
+
z.ZodObject<
|
|
209
|
+
{
|
|
210
|
+
type: z.ZodLiteral<"tool_result">;
|
|
211
|
+
callId: z.ZodString;
|
|
212
|
+
result: z.ZodUnknown;
|
|
213
|
+
error: z.ZodOptional<z.ZodString>;
|
|
214
|
+
},
|
|
215
|
+
z.core.$strip
|
|
216
|
+
>,
|
|
217
|
+
],
|
|
218
|
+
"type"
|
|
219
|
+
>
|
|
220
|
+
>;
|
|
221
|
+
timestamp: z.ZodISODateTime;
|
|
222
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
223
|
+
},
|
|
224
|
+
z.core.$strip
|
|
225
|
+
>;
|
|
155
226
|
export type Message = z.infer<typeof Message>;
|
|
156
227
|
/**
|
|
157
228
|
* Streaming message chunk
|
|
158
229
|
*/
|
|
159
|
-
export declare const MessageChunk: z.ZodObject<
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
},
|
|
230
|
+
export declare const MessageChunk: z.ZodObject<
|
|
231
|
+
{
|
|
232
|
+
id: z.ZodString;
|
|
233
|
+
role: z.ZodEnum<{
|
|
234
|
+
user: "user";
|
|
235
|
+
assistant: "assistant";
|
|
236
|
+
system: "system";
|
|
237
|
+
tool: "tool";
|
|
238
|
+
}>;
|
|
239
|
+
contentDelta: z.ZodDiscriminatedUnion<
|
|
240
|
+
[
|
|
241
|
+
z.ZodObject<
|
|
242
|
+
{
|
|
243
|
+
type: z.ZodLiteral<"text">;
|
|
244
|
+
text: z.ZodString;
|
|
245
|
+
},
|
|
246
|
+
z.core.$strip
|
|
247
|
+
>,
|
|
248
|
+
z.ZodObject<
|
|
249
|
+
{
|
|
250
|
+
type: z.ZodLiteral<"image">;
|
|
251
|
+
url: z.ZodOptional<z.ZodString>;
|
|
252
|
+
data: z.ZodOptional<z.ZodString>;
|
|
253
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
254
|
+
},
|
|
255
|
+
z.core.$strip
|
|
256
|
+
>,
|
|
257
|
+
z.ZodObject<
|
|
258
|
+
{
|
|
259
|
+
type: z.ZodLiteral<"file">;
|
|
260
|
+
name: z.ZodString;
|
|
261
|
+
path: z.ZodOptional<z.ZodString>;
|
|
262
|
+
url: z.ZodOptional<z.ZodString>;
|
|
263
|
+
mimeType: z.ZodString;
|
|
264
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
265
|
+
},
|
|
266
|
+
z.core.$strip
|
|
267
|
+
>,
|
|
268
|
+
z.ZodObject<
|
|
269
|
+
{
|
|
270
|
+
type: z.ZodLiteral<"tool_call">;
|
|
271
|
+
id: z.ZodString;
|
|
272
|
+
name: z.ZodString;
|
|
273
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
274
|
+
},
|
|
275
|
+
z.core.$strip
|
|
276
|
+
>,
|
|
277
|
+
z.ZodObject<
|
|
278
|
+
{
|
|
279
|
+
type: z.ZodLiteral<"tool_result">;
|
|
280
|
+
callId: z.ZodString;
|
|
281
|
+
result: z.ZodUnknown;
|
|
282
|
+
error: z.ZodOptional<z.ZodString>;
|
|
283
|
+
},
|
|
284
|
+
z.core.$strip
|
|
285
|
+
>,
|
|
286
|
+
],
|
|
287
|
+
"type"
|
|
288
|
+
>;
|
|
289
|
+
isComplete: z.ZodBoolean;
|
|
290
|
+
},
|
|
291
|
+
z.core.$strip
|
|
292
|
+
>;
|
|
195
293
|
export type MessageChunk = z.infer<typeof MessageChunk>;
|
|
@@ -7,89 +7,89 @@ export const MessageRole = z.enum(["user", "assistant", "system", "tool"]);
|
|
|
7
7
|
* Content type for messages
|
|
8
8
|
*/
|
|
9
9
|
export const ContentType = z.enum([
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
"text",
|
|
11
|
+
"image",
|
|
12
|
+
"file",
|
|
13
|
+
"tool_call",
|
|
14
|
+
"tool_result",
|
|
15
15
|
]);
|
|
16
16
|
/**
|
|
17
17
|
* Base content schema
|
|
18
18
|
*/
|
|
19
19
|
export const BaseContent = z.object({
|
|
20
|
-
|
|
20
|
+
type: ContentType,
|
|
21
21
|
});
|
|
22
22
|
/**
|
|
23
23
|
* Text content
|
|
24
24
|
*/
|
|
25
25
|
export const TextContent = BaseContent.extend({
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
type: z.literal("text"),
|
|
27
|
+
text: z.string(),
|
|
28
28
|
});
|
|
29
29
|
/**
|
|
30
30
|
* Image content
|
|
31
31
|
*/
|
|
32
32
|
export const ImageContent = BaseContent.extend({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
type: z.literal("image"),
|
|
34
|
+
url: z.string().url().optional(),
|
|
35
|
+
data: z.string().optional(), // Base64 encoded
|
|
36
|
+
mimeType: z.string().optional(),
|
|
37
37
|
});
|
|
38
38
|
/**
|
|
39
39
|
* File attachment content
|
|
40
40
|
*/
|
|
41
41
|
export const FileContent = BaseContent.extend({
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
type: z.literal("file"),
|
|
43
|
+
name: z.string(),
|
|
44
|
+
path: z.string().optional(),
|
|
45
|
+
url: z.string().url().optional(),
|
|
46
|
+
mimeType: z.string(),
|
|
47
|
+
size: z.number().optional(),
|
|
48
48
|
});
|
|
49
49
|
/**
|
|
50
50
|
* Tool call content
|
|
51
51
|
*/
|
|
52
52
|
export const ToolCallContent = BaseContent.extend({
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
type: z.literal("tool_call"),
|
|
54
|
+
id: z.string(),
|
|
55
|
+
name: z.string(),
|
|
56
|
+
arguments: z.record(z.string(), z.unknown()),
|
|
57
57
|
});
|
|
58
58
|
/**
|
|
59
59
|
* Tool result content
|
|
60
60
|
*/
|
|
61
61
|
export const ToolResultContent = BaseContent.extend({
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
type: z.literal("tool_result"),
|
|
63
|
+
callId: z.string(),
|
|
64
|
+
result: z.unknown(),
|
|
65
|
+
error: z.string().optional(),
|
|
66
66
|
});
|
|
67
67
|
/**
|
|
68
68
|
* Union of all content types
|
|
69
69
|
*/
|
|
70
70
|
export const Content = z.discriminatedUnion("type", [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
TextContent,
|
|
72
|
+
ImageContent,
|
|
73
|
+
FileContent,
|
|
74
|
+
ToolCallContent,
|
|
75
|
+
ToolResultContent,
|
|
76
76
|
]);
|
|
77
77
|
/**
|
|
78
78
|
* Message schema
|
|
79
79
|
*/
|
|
80
80
|
export const Message = z.object({
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
id: z.string(),
|
|
82
|
+
role: MessageRole,
|
|
83
|
+
content: z.array(Content),
|
|
84
|
+
timestamp: z.iso.datetime(),
|
|
85
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
86
86
|
});
|
|
87
87
|
/**
|
|
88
88
|
* Streaming message chunk
|
|
89
89
|
*/
|
|
90
90
|
export const MessageChunk = z.object({
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
id: z.string(),
|
|
92
|
+
role: MessageRole,
|
|
93
|
+
contentDelta: Content,
|
|
94
|
+
isComplete: z.boolean(),
|
|
95
95
|
});
|