@tavus/widget 0.12.0 → 0.14.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.
@@ -1,3 +1,5 @@
1
+ import { StartConversationOptions } from './host-types.ts';
2
+ export type { StartConversationOptions } from './host-types.ts';
1
3
  export type TavusInteraction = {
2
4
  event_type: "conversation.echo";
3
5
  properties: {
@@ -23,13 +25,17 @@ export type TavusInteraction = {
23
25
  context: string;
24
26
  };
25
27
  };
26
- export type TavusEventName = "tavus:ready" | "tavus:conversation-started" | "tavus:conversation-ended" | "tavus:error" | "tavus:state-change" | "tavus:chat-message"
28
+ export type TavusEventName = "tavus:ready" | "tavus:conversation-created" | "tavus:conversation-started" | "tavus:conversation-ended" | "tavus:error" | "tavus:state-change" | "tavus:chat-message"
27
29
  /** Retained for type-back-compat; never emitted at runtime. */
28
30
  | "tavus:message" | "tavus:protocol-message" | "tavus:tool-call" | "tavus:mode-change";
29
31
  export interface TavusEventMap {
30
32
  "tavus:ready": {
31
33
  deploymentId: string;
32
34
  };
35
+ /** The room exists and the replica is warming up; nobody has joined yet. */
36
+ "tavus:conversation-created": {
37
+ conversationId: string;
38
+ };
33
39
  "tavus:conversation-started": {
34
40
  conversationId: string;
35
41
  };
@@ -59,6 +65,28 @@ export interface TavusEventMap {
59
65
  };
60
66
  }
61
67
  export declare const TAVUS_EVENT_NAMES: TavusEventName[];
68
+ interface TavusElementTavusApi {
69
+ start?: () => Promise<void>;
70
+ end?: () => Promise<void>;
71
+ sendChat?: (text: string) => void;
72
+ sendMessage?: (interaction: TavusInteraction) => void;
73
+ }
74
+ export interface TavusElement extends HTMLElement {
75
+ open?: () => void;
76
+ close?: () => void;
77
+ /** Creates the room without joining it; the next start joins it. Rejects on failure. */
78
+ createConversation?: () => Promise<{
79
+ conversationId: string;
80
+ }>;
81
+ /** Resolves even when the start fails — failures arrive as `tavus:error`. */
82
+ startConversation?: (options?: StartConversationOptions) => Promise<void>;
83
+ endConversation?: () => Promise<void>;
84
+ /** Legacy string-based send; prefer el.tavus.sendMessage for typed interactions. */
85
+ sendMessage?: (input: TavusInteraction | string) => void;
86
+ updateConfig?: (config: Record<string, unknown>) => void;
87
+ destroy?: () => void;
88
+ tavus?: TavusElementTavusApi;
89
+ }
62
90
  export declare class TavusIntegration {
63
91
  private element;
64
92
  private tagName;
@@ -66,7 +94,16 @@ export declare class TavusIntegration {
66
94
  private getElement;
67
95
  open(): void;
68
96
  close(): void;
69
- startConversation(): void;
97
+ /**
98
+ * Create the conversation now and join it on the next `startConversation()`.
99
+ * Lets the replica warm up while the visitor is still on the preview or the
100
+ * host's own haircheck. Rejects when the room could not be created; a later
101
+ * start then creates one as usual.
102
+ */
103
+ createConversation(): Promise<{
104
+ conversationId: string;
105
+ }>;
106
+ startConversation(options?: StartConversationOptions): void;
70
107
  endConversation(): void;
71
108
  /**
72
109
  * Send a typed interaction or a plain text string (back-compat shim).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tavus/widget",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "Tavus conversational video AI <tavus-widget> launcher custom element for the web.",
5
5
  "keywords": [
6
6
  "ai",