vanilla-agent 1.1.0 → 1.3.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 +104 -2
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.global.js +19 -19
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/runtime/init.ts +24 -1
- package/src/session.ts +3 -2
- package/src/types.ts +18 -0
- package/src/ui.ts +55 -2
package/dist/index.d.cts
CHANGED
|
@@ -256,6 +256,22 @@ type AgentWidgetToolCall = {
|
|
|
256
256
|
durationMs?: number;
|
|
257
257
|
};
|
|
258
258
|
type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool";
|
|
259
|
+
/**
|
|
260
|
+
* Represents a message in the chat conversation.
|
|
261
|
+
*
|
|
262
|
+
* @property id - Unique message identifier
|
|
263
|
+
* @property role - Message role: "user", "assistant", or "system"
|
|
264
|
+
* @property content - Message text content
|
|
265
|
+
* @property createdAt - ISO timestamp when message was created
|
|
266
|
+
* @property streaming - Whether message is still streaming (for assistant messages)
|
|
267
|
+
* @property variant - Message variant for assistant messages: "assistant", "reasoning", or "tool"
|
|
268
|
+
* @property sequence - Message ordering number
|
|
269
|
+
* @property reasoning - Reasoning data for assistant reasoning messages
|
|
270
|
+
* @property toolCall - Tool call data for assistant tool messages
|
|
271
|
+
* @property tools - Array of tool calls
|
|
272
|
+
* @property viaVoice - Set to `true` when a user message is sent via voice recognition.
|
|
273
|
+
* Useful for implementing voice-specific behaviors like auto-reactivation.
|
|
274
|
+
*/
|
|
259
275
|
type AgentWidgetMessage = {
|
|
260
276
|
id: string;
|
|
261
277
|
role: AgentWidgetMessageRole;
|
|
@@ -267,6 +283,7 @@ type AgentWidgetMessage = {
|
|
|
267
283
|
reasoning?: AgentWidgetReasoning;
|
|
268
284
|
toolCall?: AgentWidgetToolCall;
|
|
269
285
|
tools?: AgentWidgetToolCall[];
|
|
286
|
+
viaVoice?: boolean;
|
|
270
287
|
};
|
|
271
288
|
type AgentWidgetEvent = {
|
|
272
289
|
type: "message";
|
|
@@ -283,6 +300,7 @@ type AgentWidgetInitOptions = {
|
|
|
283
300
|
config?: AgentWidgetConfig;
|
|
284
301
|
useShadowDom?: boolean;
|
|
285
302
|
onReady?: () => void;
|
|
303
|
+
windowKey?: string;
|
|
286
304
|
};
|
|
287
305
|
|
|
288
306
|
type Controller = {
|
|
@@ -292,6 +310,10 @@ type Controller = {
|
|
|
292
310
|
close: () => void;
|
|
293
311
|
toggle: () => void;
|
|
294
312
|
clearChat: () => void;
|
|
313
|
+
setMessage: (message: string) => boolean;
|
|
314
|
+
submitMessage: (message?: string) => boolean;
|
|
315
|
+
startVoiceRecognition: () => boolean;
|
|
316
|
+
stopVoiceRecognition: () => boolean;
|
|
295
317
|
};
|
|
296
318
|
declare const createAgentExperience: (mount: HTMLElement, initialConfig?: AgentWidgetConfig) => Controller;
|
|
297
319
|
type AgentWidgetController = Controller;
|
|
@@ -322,7 +344,9 @@ declare class AgentWidgetSession {
|
|
|
322
344
|
getMessages(): AgentWidgetMessage[];
|
|
323
345
|
getStatus(): AgentWidgetSessionStatus;
|
|
324
346
|
isStreaming(): boolean;
|
|
325
|
-
sendMessage(rawInput: string
|
|
347
|
+
sendMessage(rawInput: string, options?: {
|
|
348
|
+
viaVoice?: boolean;
|
|
349
|
+
}): Promise<void>;
|
|
326
350
|
cancel(): void;
|
|
327
351
|
clearMessages(): void;
|
|
328
352
|
private handleEvent;
|
package/dist/index.d.ts
CHANGED
|
@@ -256,6 +256,22 @@ type AgentWidgetToolCall = {
|
|
|
256
256
|
durationMs?: number;
|
|
257
257
|
};
|
|
258
258
|
type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool";
|
|
259
|
+
/**
|
|
260
|
+
* Represents a message in the chat conversation.
|
|
261
|
+
*
|
|
262
|
+
* @property id - Unique message identifier
|
|
263
|
+
* @property role - Message role: "user", "assistant", or "system"
|
|
264
|
+
* @property content - Message text content
|
|
265
|
+
* @property createdAt - ISO timestamp when message was created
|
|
266
|
+
* @property streaming - Whether message is still streaming (for assistant messages)
|
|
267
|
+
* @property variant - Message variant for assistant messages: "assistant", "reasoning", or "tool"
|
|
268
|
+
* @property sequence - Message ordering number
|
|
269
|
+
* @property reasoning - Reasoning data for assistant reasoning messages
|
|
270
|
+
* @property toolCall - Tool call data for assistant tool messages
|
|
271
|
+
* @property tools - Array of tool calls
|
|
272
|
+
* @property viaVoice - Set to `true` when a user message is sent via voice recognition.
|
|
273
|
+
* Useful for implementing voice-specific behaviors like auto-reactivation.
|
|
274
|
+
*/
|
|
259
275
|
type AgentWidgetMessage = {
|
|
260
276
|
id: string;
|
|
261
277
|
role: AgentWidgetMessageRole;
|
|
@@ -267,6 +283,7 @@ type AgentWidgetMessage = {
|
|
|
267
283
|
reasoning?: AgentWidgetReasoning;
|
|
268
284
|
toolCall?: AgentWidgetToolCall;
|
|
269
285
|
tools?: AgentWidgetToolCall[];
|
|
286
|
+
viaVoice?: boolean;
|
|
270
287
|
};
|
|
271
288
|
type AgentWidgetEvent = {
|
|
272
289
|
type: "message";
|
|
@@ -283,6 +300,7 @@ type AgentWidgetInitOptions = {
|
|
|
283
300
|
config?: AgentWidgetConfig;
|
|
284
301
|
useShadowDom?: boolean;
|
|
285
302
|
onReady?: () => void;
|
|
303
|
+
windowKey?: string;
|
|
286
304
|
};
|
|
287
305
|
|
|
288
306
|
type Controller = {
|
|
@@ -292,6 +310,10 @@ type Controller = {
|
|
|
292
310
|
close: () => void;
|
|
293
311
|
toggle: () => void;
|
|
294
312
|
clearChat: () => void;
|
|
313
|
+
setMessage: (message: string) => boolean;
|
|
314
|
+
submitMessage: (message?: string) => boolean;
|
|
315
|
+
startVoiceRecognition: () => boolean;
|
|
316
|
+
stopVoiceRecognition: () => boolean;
|
|
295
317
|
};
|
|
296
318
|
declare const createAgentExperience: (mount: HTMLElement, initialConfig?: AgentWidgetConfig) => Controller;
|
|
297
319
|
type AgentWidgetController = Controller;
|
|
@@ -322,7 +344,9 @@ declare class AgentWidgetSession {
|
|
|
322
344
|
getMessages(): AgentWidgetMessage[];
|
|
323
345
|
getStatus(): AgentWidgetSessionStatus;
|
|
324
346
|
isStreaming(): boolean;
|
|
325
|
-
sendMessage(rawInput: string
|
|
347
|
+
sendMessage(rawInput: string, options?: {
|
|
348
|
+
viaVoice?: boolean;
|
|
349
|
+
}): Promise<void>;
|
|
326
350
|
cancel(): void;
|
|
327
351
|
clearMessages(): void;
|
|
328
352
|
private handleEvent;
|