@vanira/sdk 0.0.87 → 0.0.88

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.
@@ -552,6 +552,7 @@ const fn = class fn {
552
552
  L(this, "backendUrl");
553
553
  L(this, "token");
554
554
  L(this, "prospectName");
555
+ L(this, "welcomeMessage");
555
556
  L(this, "extraDetails");
556
557
  L(this, "onConnected");
557
558
  L(this, "onDisconnected");
@@ -586,6 +587,7 @@ const fn = class fn {
586
587
  L(this, "liveVision");
587
588
  L(this, "liveVisionAutoStarted", !1);
588
589
  L(this, "connectStallTimeoutMs");
590
+ var A;
589
591
  if (!e.agentId) throw new Error("agentId is required");
590
592
  const t = !!(e.apiKey || e.token), r = !!(e.serverUrl && e.callId), i = fn.normalizeIceServers(
591
593
  e.iceServers
@@ -594,58 +596,58 @@ const fn = class fn {
594
596
  throw new Error(
595
597
  "apiKey or token is required — or pass serverUrl and callId from a prior POST /calls/create"
596
598
  );
597
- this.agentId = e.agentId, this.sessionBehavior = e.sessionBehavior, this.serverUrl = (e.serverUrl || "").replace(/\/$/, ""), this.apiKey = e.apiKey, this.token = e.token, this.prospectName = e.prospectName, this.extraDetails = e.extraDetails, this.backendUrl = (e.backendUrl || gw).replace(/\/$/, ""), i.length && (this.iceServers = i), r && (this.callSessionLoaded = !0);
599
+ this.agentId = e.agentId, this.sessionBehavior = e.sessionBehavior, this.serverUrl = (e.serverUrl || "").replace(/\/$/, ""), this.apiKey = e.apiKey, this.token = e.token, this.prospectName = e.prospectName, this.welcomeMessage = ((A = e.welcomeMessage) == null ? void 0 : A.trim()) || void 0, this.extraDetails = e.extraDetails, this.backendUrl = (e.backendUrl || gw).replace(/\/$/, ""), i.length && (this.iceServers = i), r && (this.callSessionLoaded = !0);
598
600
  const s = typeof window < "u";
599
601
  this.prospectId = e.prospectId;
600
602
  const a = e.sessionBehavior === "continue";
601
603
  if (a && s && !e.callId) {
602
- const A = Gl(this.agentId);
603
- A && (e.callId || (this.callId = A.callId), !this.prospectId && A.prospectId && (this.prospectId = A.prospectId));
604
+ const c = Gl(this.agentId);
605
+ c && (e.callId || (this.callId = c.callId), !this.prospectId && c.prospectId && (this.prospectId = c.prospectId));
604
606
  }
605
607
  if (!this.prospectId && s)
606
608
  try {
607
- const A = Gl(this.agentId);
608
- this.prospectId = (A == null ? void 0 : A.prospectId) || window.sessionStorage && window.sessionStorage.getItem("vanira_prospect_id") || window.localStorage && window.localStorage.getItem("vanira_prospect_id") || void 0;
609
+ const c = Gl(this.agentId);
610
+ this.prospectId = (c == null ? void 0 : c.prospectId) || window.sessionStorage && window.sessionStorage.getItem("vanira_prospect_id") || window.localStorage && window.localStorage.getItem("vanira_prospect_id") || void 0;
609
611
  } catch {
610
612
  }
611
613
  e.callId ? this.callId = e.callId : a || (this.callId = void 0);
612
614
  const o = e.onSessionStarted;
613
- this.onSessionStarted = (A) => {
614
- o == null || o(A), this.emit("session_started", A);
615
+ this.onSessionStarted = (c) => {
616
+ o == null || o(c), this.emit("session_started", c);
615
617
  }, this.liveVision = e.liveVision, this.connectStallTimeoutMs = e.connectStallTimeoutMs ?? 15e3, this.onConnected = () => {
616
- var A;
617
- Ds(), this._status = "connected", (A = e.onConnected) == null || A.call(e), this.emit("connected"), this.maybeAutoStartLiveCamera();
618
+ var c;
619
+ Ds(), this._status = "connected", (c = e.onConnected) == null || c.call(e), this.emit("connected"), this.maybeAutoStartLiveCamera();
618
620
  }, this.onDisconnected = () => {
619
- var A;
620
- Ds(), this._status = "disconnected", (A = e.onDisconnected) == null || A.call(e), this.emit("disconnected");
621
- }, this.onError = (A) => {
622
- var l;
623
- Ds(), this._status = "error";
624
- const c = typeof A == "string" ? A : (A == null ? void 0 : A.message) || "Connection error";
625
- (l = e.onError) == null || l.call(e, A), this.emit("error", c);
626
- }, this.onTranscription = (A, c, l) => {
621
+ var c;
622
+ Ds(), this._status = "disconnected", (c = e.onDisconnected) == null || c.call(e), this.emit("disconnected");
623
+ }, this.onError = (c) => {
627
624
  var d;
628
- (d = e.onTranscription) == null || d.call(e, A, c), this.emit("transcription", { text: A, isFinal: c, role: l });
625
+ Ds(), this._status = "error";
626
+ const l = typeof c == "string" ? c : (c == null ? void 0 : c.message) || "Connection error";
627
+ (d = e.onError) == null || d.call(e, c), this.emit("error", l);
628
+ }, this.onTranscription = (c, l, d) => {
629
+ var u;
630
+ (u = e.onTranscription) == null || u.call(e, c, l), this.emit("transcription", { text: c, isFinal: l, role: d });
629
631
  }, this.onLocalStream = e.onLocalStream || (() => {
630
- }), this.onRemoteTrack = (A, c) => {
631
- var l;
632
- (l = e.onRemoteTrack) == null || l.call(e, A, c), this.emit("track", { track: A, stream: c });
633
- }, this.onClientToolCall = (A) => {
632
+ }), this.onRemoteTrack = (c, l) => {
634
633
  var d;
635
- (d = e.onClientToolCall) == null || d.call(e, A);
636
- const c = (A == null ? void 0 : A.data) || A, l = {
637
- name: String(c.name || c.tool_name || ""),
638
- arguments: c.arguments || c.args || {},
639
- tool_call_id: String(c.tool_call_id || c.call_id || ""),
640
- execution_mode: c.execution_mode === "blocking" ? "blocking" : "fire_and_forget",
641
- client_fields: c.client_fields || {}
634
+ (d = e.onRemoteTrack) == null || d.call(e, c, l), this.emit("track", { track: c, stream: l });
635
+ }, this.onClientToolCall = (c) => {
636
+ var u;
637
+ (u = e.onClientToolCall) == null || u.call(e, c);
638
+ const l = (c == null ? void 0 : c.data) || c, d = {
639
+ name: String(l.name || l.tool_name || ""),
640
+ arguments: l.arguments || l.args || {},
641
+ tool_call_id: String(l.tool_call_id || l.call_id || ""),
642
+ execution_mode: l.execution_mode === "blocking" ? "blocking" : "fire_and_forget",
643
+ client_fields: l.client_fields || {}
642
644
  };
643
- l.name && l.tool_call_id && this.emit("tool_call", l);
645
+ d.name && d.tool_call_id && this.emit("tool_call", d);
644
646
  }, this.runtime = e.runtime, typeof window < "u" && e.trackRouteContext !== !1 && (this.routeTracker = new zw({
645
- sendContext: (A) => this.sendContextUpdate(A),
647
+ sendContext: (c) => this.sendContextUpdate(c),
646
648
  isReady: () => {
647
- var A;
648
- return ((A = this.dataChannel) == null ? void 0 : A.readyState) === "open";
649
+ var c;
650
+ return ((c = this.dataChannel) == null ? void 0 : c.readyState) === "open";
649
651
  }
650
652
  }));
651
653
  }
@@ -813,6 +815,7 @@ const fn = class fn {
813
815
  ...(A = this.runtime) != null && A.runtimeName ? { runtime: this.runtime.runtimeName } : {},
814
816
  prospect_id: this.prospectId,
815
817
  ...this.prospectName ? { prospect_name: this.prospectName } : {},
818
+ ...this.welcomeMessage ? { welcome_message: this.welcomeMessage } : {},
816
819
  ...this.extraDetails && Object.keys(this.extraDetails).length ? { extra_details: this.extraDetails } : {},
817
820
  ...r ? { call_id: r } : {}
818
821
  })
package/dist/index.d.ts CHANGED
@@ -18,6 +18,9 @@ export interface VaniraClientConfig {
18
18
  callId?: string;
19
19
  iceServers?: RTCIceServer[];
20
20
  prospectId?: string;
21
+ prospectName?: string;
22
+ welcomeMessage?: string;
23
+ extraDetails?: Record<string, unknown>;
21
24
  sessionBehavior?: 'continue' | 'new';
22
25
  runtime?: unknown;
23
26
  liveVision?: Record<string, unknown>;
@@ -217,6 +220,7 @@ export interface VaniraCallBoxProps {
217
220
  callId?: string;
218
221
  serverUrl?: string;
219
222
  prospectName?: string;
223
+ welcomeMessage?: string;
220
224
  extraDetails?: Record<string, unknown>;
221
225
  iceServers?: RTCIceServer[];
222
226
  autoStart?: boolean;