vanilla-agent 0.1.0

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/src/types.ts ADDED
@@ -0,0 +1,194 @@
1
+ import type { ChatWidgetPlugin } from "./plugins/types";
2
+
3
+ export type ChatWidgetFeatureFlags = {
4
+ showReasoning?: boolean;
5
+ showToolCalls?: boolean;
6
+ };
7
+
8
+ export type ChatWidgetTheme = {
9
+ primary?: string;
10
+ secondary?: string;
11
+ surface?: string;
12
+ muted?: string;
13
+ accent?: string;
14
+ container?: string;
15
+ border?: string;
16
+ divider?: string;
17
+ messageBorder?: string;
18
+ inputBackground?: string;
19
+ callToAction?: string;
20
+ callToActionBackground?: string;
21
+ sendButtonBackgroundColor?: string;
22
+ sendButtonTextColor?: string;
23
+ sendButtonBorderColor?: string;
24
+ closeButtonColor?: string;
25
+ closeButtonBackgroundColor?: string;
26
+ closeButtonBorderColor?: string;
27
+ micIconColor?: string;
28
+ micBackgroundColor?: string;
29
+ micBorderColor?: string;
30
+ recordingIconColor?: string;
31
+ recordingBackgroundColor?: string;
32
+ recordingBorderColor?: string;
33
+ inputFontFamily?: "sans-serif" | "serif" | "mono";
34
+ inputFontWeight?: string;
35
+ radiusSm?: string;
36
+ radiusMd?: string;
37
+ radiusLg?: string;
38
+ launcherRadius?: string;
39
+ buttonRadius?: string;
40
+ };
41
+
42
+ export type ChatWidgetLauncherConfig = {
43
+ enabled?: boolean;
44
+ title?: string;
45
+ subtitle?: string;
46
+ textHidden?: boolean;
47
+ iconUrl?: string;
48
+ agentIconText?: string;
49
+ agentIconName?: string;
50
+ agentIconHidden?: boolean;
51
+ position?: "bottom-right" | "bottom-left" | "top-right" | "top-left";
52
+ autoExpand?: boolean;
53
+ width?: string;
54
+ callToActionIconText?: string;
55
+ callToActionIconName?: string;
56
+ callToActionIconColor?: string;
57
+ callToActionIconBackgroundColor?: string;
58
+ callToActionIconHidden?: boolean;
59
+ callToActionIconPadding?: string;
60
+ agentIconSize?: string;
61
+ callToActionIconSize?: string;
62
+ headerIconSize?: string;
63
+ headerIconName?: string;
64
+ headerIconHidden?: boolean;
65
+ closeButtonSize?: string;
66
+ closeButtonColor?: string;
67
+ closeButtonBackgroundColor?: string;
68
+ closeButtonBorderWidth?: string;
69
+ closeButtonBorderColor?: string;
70
+ closeButtonBorderRadius?: string;
71
+ closeButtonPlacement?: "inline" | "top-right";
72
+ };
73
+
74
+ export type ChatWidgetSendButtonConfig = {
75
+ borderWidth?: string;
76
+ borderColor?: string;
77
+ paddingX?: string;
78
+ paddingY?: string;
79
+ iconText?: string;
80
+ iconName?: string;
81
+ useIcon?: boolean;
82
+ tooltipText?: string;
83
+ showTooltip?: boolean;
84
+ backgroundColor?: string;
85
+ textColor?: string;
86
+ size?: string;
87
+ };
88
+
89
+ export type ChatWidgetStatusIndicatorConfig = {
90
+ visible?: boolean;
91
+ idleText?: string;
92
+ connectingText?: string;
93
+ connectedText?: string;
94
+ errorText?: string;
95
+ };
96
+
97
+ export type ChatWidgetVoiceRecognitionConfig = {
98
+ enabled?: boolean;
99
+ pauseDuration?: number;
100
+ iconName?: string;
101
+ iconSize?: string;
102
+ iconColor?: string;
103
+ backgroundColor?: string;
104
+ borderColor?: string;
105
+ borderWidth?: string;
106
+ paddingX?: string;
107
+ paddingY?: string;
108
+ tooltipText?: string;
109
+ showTooltip?: boolean;
110
+ recordingIconColor?: string;
111
+ recordingBackgroundColor?: string;
112
+ recordingBorderColor?: string;
113
+ showRecordingIndicator?: boolean;
114
+ };
115
+
116
+ export type ChatWidgetConfig = {
117
+ apiUrl?: string;
118
+ flowId?: string;
119
+ headers?: Record<string, string>;
120
+ copy?: {
121
+ welcomeTitle?: string;
122
+ welcomeSubtitle?: string;
123
+ inputPlaceholder?: string;
124
+ sendButtonLabel?: string;
125
+ };
126
+ theme?: ChatWidgetTheme;
127
+ features?: ChatWidgetFeatureFlags;
128
+ launcher?: ChatWidgetLauncherConfig;
129
+ initialMessages?: ChatWidgetMessage[];
130
+ suggestionChips?: string[];
131
+ debug?: boolean;
132
+ formEndpoint?: string;
133
+ launcherWidth?: string;
134
+ sendButton?: ChatWidgetSendButtonConfig;
135
+ statusIndicator?: ChatWidgetStatusIndicatorConfig;
136
+ voiceRecognition?: ChatWidgetVoiceRecognitionConfig;
137
+ postprocessMessage?: (context: {
138
+ text: string;
139
+ message: ChatWidgetMessage;
140
+ streaming: boolean;
141
+ }) => string;
142
+ plugins?: ChatWidgetPlugin[];
143
+ };
144
+
145
+ export type ChatWidgetMessageRole = "user" | "assistant" | "system";
146
+
147
+ export type ChatWidgetReasoning = {
148
+ id: string;
149
+ status: "pending" | "streaming" | "complete";
150
+ chunks: string[];
151
+ startedAt?: number;
152
+ completedAt?: number;
153
+ durationMs?: number;
154
+ };
155
+
156
+ export type ChatWidgetToolCall = {
157
+ id: string;
158
+ name?: string;
159
+ status: "pending" | "running" | "complete";
160
+ args?: unknown;
161
+ chunks?: string[];
162
+ result?: unknown;
163
+ duration?: number;
164
+ startedAt?: number;
165
+ completedAt?: number;
166
+ durationMs?: number;
167
+ };
168
+
169
+ export type ChatWidgetMessageVariant = "assistant" | "reasoning" | "tool";
170
+
171
+ export type ChatWidgetMessage = {
172
+ id: string;
173
+ role: ChatWidgetMessageRole;
174
+ content: string;
175
+ createdAt: string;
176
+ streaming?: boolean;
177
+ variant?: ChatWidgetMessageVariant;
178
+ sequence?: number;
179
+ reasoning?: ChatWidgetReasoning;
180
+ toolCall?: ChatWidgetToolCall;
181
+ tools?: ChatWidgetToolCall[];
182
+ };
183
+
184
+ export type ChatWidgetEvent =
185
+ | { type: "message"; message: ChatWidgetMessage }
186
+ | { type: "status"; status: "connecting" | "connected" | "error" | "idle" }
187
+ | { type: "error"; error: Error };
188
+
189
+ export type ChatWidgetInitOptions = {
190
+ target: string | HTMLElement;
191
+ config?: ChatWidgetConfig;
192
+ useShadowDom?: boolean;
193
+ onReady?: () => void;
194
+ };