vanilla-agent 0.1.0 → 1.0.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/README.md +53 -21
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +98 -61
- package/dist/index.d.ts +98 -61
- package/dist/index.global.js +36 -30
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/install.global.js +1 -1
- package/dist/install.global.js.map +1 -1
- package/dist/widget.css +33 -0
- package/package.json +2 -2
- package/src/client.ts +14 -14
- package/src/components/forms.ts +7 -5
- package/src/components/launcher.ts +4 -4
- package/src/components/message-bubble.ts +3 -3
- package/src/components/messages.ts +4 -2
- package/src/components/panel.ts +254 -13
- package/src/components/reasoning-bubble.ts +2 -2
- package/src/components/suggestions.ts +4 -4
- package/src/components/tool-bubble.ts +2 -2
- package/src/defaults.ts +180 -0
- package/src/index.ts +21 -18
- package/src/install.ts +8 -8
- package/src/plugins/registry.ts +7 -5
- package/src/plugins/types.ts +13 -11
- package/src/runtime/init.ts +33 -8
- package/src/session.ts +32 -23
- package/src/styles/widget.css +33 -0
- package/src/types.ts +56 -31
- package/src/ui.ts +330 -22
- package/src/utils/constants.ts +4 -2
- package/src/utils/dom.ts +2 -0
- package/src/utils/formatting.ts +8 -6
- package/src/utils/icons.ts +1 -1
- package/src/utils/positioning.ts +2 -0
- package/src/utils/theme.ts +4 -2
package/src/styles/widget.css
CHANGED
|
@@ -572,6 +572,10 @@
|
|
|
572
572
|
width: 360px;
|
|
573
573
|
}
|
|
574
574
|
|
|
575
|
+
.tvw-w-\[400px\] {
|
|
576
|
+
width: 400px;
|
|
577
|
+
}
|
|
578
|
+
|
|
575
579
|
.tvw-h-\[640px\] {
|
|
576
580
|
height: 640px;
|
|
577
581
|
}
|
|
@@ -687,6 +691,35 @@ form:focus-within textarea {
|
|
|
687
691
|
opacity: 1;
|
|
688
692
|
}
|
|
689
693
|
|
|
694
|
+
/* Clear chat button tooltip */
|
|
695
|
+
.tvw-clear-chat-button-wrapper {
|
|
696
|
+
position: relative;
|
|
697
|
+
display: inline-flex;
|
|
698
|
+
align-items: center;
|
|
699
|
+
justify-content: center;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
.tvw-clear-chat-tooltip {
|
|
703
|
+
background-color: #111827;
|
|
704
|
+
color: #ffffff;
|
|
705
|
+
padding: 6px 12px;
|
|
706
|
+
border-radius: 0.5rem;
|
|
707
|
+
font-size: 12px;
|
|
708
|
+
white-space: nowrap;
|
|
709
|
+
pointer-events: none;
|
|
710
|
+
z-index: 10000;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
.tvw-clear-chat-tooltip-arrow {
|
|
714
|
+
content: "";
|
|
715
|
+
position: absolute;
|
|
716
|
+
top: 100%;
|
|
717
|
+
left: 50%;
|
|
718
|
+
transform: translateX(-50%);
|
|
719
|
+
border: 4px solid transparent;
|
|
720
|
+
border-top-color: #111827;
|
|
721
|
+
}
|
|
722
|
+
|
|
690
723
|
/* Typing indicator animation */
|
|
691
724
|
@keyframes typing {
|
|
692
725
|
0%, 100% {
|
package/src/types.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AgentWidgetPlugin } from "./plugins/types";
|
|
2
2
|
|
|
3
|
-
export type
|
|
3
|
+
export type AgentWidgetFeatureFlags = {
|
|
4
4
|
showReasoning?: boolean;
|
|
5
5
|
showToolCalls?: boolean;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
-
export type
|
|
8
|
+
export type AgentWidgetTheme = {
|
|
9
9
|
primary?: string;
|
|
10
10
|
secondary?: string;
|
|
11
11
|
surface?: string;
|
|
@@ -24,6 +24,9 @@ export type ChatWidgetTheme = {
|
|
|
24
24
|
closeButtonColor?: string;
|
|
25
25
|
closeButtonBackgroundColor?: string;
|
|
26
26
|
closeButtonBorderColor?: string;
|
|
27
|
+
clearChatIconColor?: string;
|
|
28
|
+
clearChatBackgroundColor?: string;
|
|
29
|
+
clearChatBorderColor?: string;
|
|
27
30
|
micIconColor?: string;
|
|
28
31
|
micBackgroundColor?: string;
|
|
29
32
|
micBorderColor?: string;
|
|
@@ -39,7 +42,7 @@ export type ChatWidgetTheme = {
|
|
|
39
42
|
buttonRadius?: string;
|
|
40
43
|
};
|
|
41
44
|
|
|
42
|
-
export type
|
|
45
|
+
export type AgentWidgetLauncherConfig = {
|
|
43
46
|
enabled?: boolean;
|
|
44
47
|
title?: string;
|
|
45
48
|
subtitle?: string;
|
|
@@ -68,10 +71,17 @@ export type ChatWidgetLauncherConfig = {
|
|
|
68
71
|
closeButtonBorderWidth?: string;
|
|
69
72
|
closeButtonBorderColor?: string;
|
|
70
73
|
closeButtonBorderRadius?: string;
|
|
74
|
+
closeButtonPaddingX?: string;
|
|
75
|
+
closeButtonPaddingY?: string;
|
|
71
76
|
closeButtonPlacement?: "inline" | "top-right";
|
|
77
|
+
closeButtonIconName?: string;
|
|
78
|
+
closeButtonIconText?: string;
|
|
79
|
+
closeButtonTooltipText?: string;
|
|
80
|
+
closeButtonShowTooltip?: boolean;
|
|
81
|
+
clearChat?: AgentWidgetClearChatConfig;
|
|
72
82
|
};
|
|
73
83
|
|
|
74
|
-
export type
|
|
84
|
+
export type AgentWidgetSendButtonConfig = {
|
|
75
85
|
borderWidth?: string;
|
|
76
86
|
borderColor?: string;
|
|
77
87
|
paddingX?: string;
|
|
@@ -86,7 +96,22 @@ export type ChatWidgetSendButtonConfig = {
|
|
|
86
96
|
size?: string;
|
|
87
97
|
};
|
|
88
98
|
|
|
89
|
-
export type
|
|
99
|
+
export type AgentWidgetClearChatConfig = {
|
|
100
|
+
enabled?: boolean;
|
|
101
|
+
iconName?: string;
|
|
102
|
+
iconColor?: string;
|
|
103
|
+
backgroundColor?: string;
|
|
104
|
+
borderWidth?: string;
|
|
105
|
+
borderColor?: string;
|
|
106
|
+
borderRadius?: string;
|
|
107
|
+
size?: string;
|
|
108
|
+
paddingX?: string;
|
|
109
|
+
paddingY?: string;
|
|
110
|
+
tooltipText?: string;
|
|
111
|
+
showTooltip?: boolean;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export type AgentWidgetStatusIndicatorConfig = {
|
|
90
115
|
visible?: boolean;
|
|
91
116
|
idleText?: string;
|
|
92
117
|
connectingText?: string;
|
|
@@ -94,7 +119,7 @@ export type ChatWidgetStatusIndicatorConfig = {
|
|
|
94
119
|
errorText?: string;
|
|
95
120
|
};
|
|
96
121
|
|
|
97
|
-
export type
|
|
122
|
+
export type AgentWidgetVoiceRecognitionConfig = {
|
|
98
123
|
enabled?: boolean;
|
|
99
124
|
pauseDuration?: number;
|
|
100
125
|
iconName?: string;
|
|
@@ -113,7 +138,7 @@ export type ChatWidgetVoiceRecognitionConfig = {
|
|
|
113
138
|
showRecordingIndicator?: boolean;
|
|
114
139
|
};
|
|
115
140
|
|
|
116
|
-
export type
|
|
141
|
+
export type AgentWidgetConfig = {
|
|
117
142
|
apiUrl?: string;
|
|
118
143
|
flowId?: string;
|
|
119
144
|
headers?: Record<string, string>;
|
|
@@ -123,28 +148,28 @@ export type ChatWidgetConfig = {
|
|
|
123
148
|
inputPlaceholder?: string;
|
|
124
149
|
sendButtonLabel?: string;
|
|
125
150
|
};
|
|
126
|
-
theme?:
|
|
127
|
-
features?:
|
|
128
|
-
launcher?:
|
|
129
|
-
initialMessages?:
|
|
151
|
+
theme?: AgentWidgetTheme;
|
|
152
|
+
features?: AgentWidgetFeatureFlags;
|
|
153
|
+
launcher?: AgentWidgetLauncherConfig;
|
|
154
|
+
initialMessages?: AgentWidgetMessage[];
|
|
130
155
|
suggestionChips?: string[];
|
|
131
156
|
debug?: boolean;
|
|
132
157
|
formEndpoint?: string;
|
|
133
158
|
launcherWidth?: string;
|
|
134
|
-
sendButton?:
|
|
135
|
-
statusIndicator?:
|
|
136
|
-
voiceRecognition?:
|
|
159
|
+
sendButton?: AgentWidgetSendButtonConfig;
|
|
160
|
+
statusIndicator?: AgentWidgetStatusIndicatorConfig;
|
|
161
|
+
voiceRecognition?: AgentWidgetVoiceRecognitionConfig;
|
|
137
162
|
postprocessMessage?: (context: {
|
|
138
163
|
text: string;
|
|
139
|
-
message:
|
|
164
|
+
message: AgentWidgetMessage;
|
|
140
165
|
streaming: boolean;
|
|
141
166
|
}) => string;
|
|
142
|
-
plugins?:
|
|
167
|
+
plugins?: AgentWidgetPlugin[];
|
|
143
168
|
};
|
|
144
169
|
|
|
145
|
-
export type
|
|
170
|
+
export type AgentWidgetMessageRole = "user" | "assistant" | "system";
|
|
146
171
|
|
|
147
|
-
export type
|
|
172
|
+
export type AgentWidgetReasoning = {
|
|
148
173
|
id: string;
|
|
149
174
|
status: "pending" | "streaming" | "complete";
|
|
150
175
|
chunks: string[];
|
|
@@ -153,7 +178,7 @@ export type ChatWidgetReasoning = {
|
|
|
153
178
|
durationMs?: number;
|
|
154
179
|
};
|
|
155
180
|
|
|
156
|
-
export type
|
|
181
|
+
export type AgentWidgetToolCall = {
|
|
157
182
|
id: string;
|
|
158
183
|
name?: string;
|
|
159
184
|
status: "pending" | "running" | "complete";
|
|
@@ -166,29 +191,29 @@ export type ChatWidgetToolCall = {
|
|
|
166
191
|
durationMs?: number;
|
|
167
192
|
};
|
|
168
193
|
|
|
169
|
-
export type
|
|
194
|
+
export type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool";
|
|
170
195
|
|
|
171
|
-
export type
|
|
196
|
+
export type AgentWidgetMessage = {
|
|
172
197
|
id: string;
|
|
173
|
-
role:
|
|
198
|
+
role: AgentWidgetMessageRole;
|
|
174
199
|
content: string;
|
|
175
200
|
createdAt: string;
|
|
176
201
|
streaming?: boolean;
|
|
177
|
-
variant?:
|
|
202
|
+
variant?: AgentWidgetMessageVariant;
|
|
178
203
|
sequence?: number;
|
|
179
|
-
reasoning?:
|
|
180
|
-
toolCall?:
|
|
181
|
-
tools?:
|
|
204
|
+
reasoning?: AgentWidgetReasoning;
|
|
205
|
+
toolCall?: AgentWidgetToolCall;
|
|
206
|
+
tools?: AgentWidgetToolCall[];
|
|
182
207
|
};
|
|
183
208
|
|
|
184
|
-
export type
|
|
185
|
-
| { type: "message"; message:
|
|
209
|
+
export type AgentWidgetEvent =
|
|
210
|
+
| { type: "message"; message: AgentWidgetMessage }
|
|
186
211
|
| { type: "status"; status: "connecting" | "connected" | "error" | "idle" }
|
|
187
212
|
| { type: "error"; error: Error };
|
|
188
213
|
|
|
189
|
-
export type
|
|
214
|
+
export type AgentWidgetInitOptions = {
|
|
190
215
|
target: string | HTMLElement;
|
|
191
|
-
config?:
|
|
216
|
+
config?: AgentWidgetConfig;
|
|
192
217
|
useShadowDom?: boolean;
|
|
193
218
|
onReady?: () => void;
|
|
194
219
|
};
|