@tellyouai/plugin 0.1.8 → 0.1.10

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 CHANGED
@@ -106,9 +106,9 @@ await initialize({
106
106
  });
107
107
  ```
108
108
 
109
- The modal-style `overlay` and `bar` popups retain their preset layout; placement
110
- offsets apply to their launcher. `style.zIndex` takes precedence over
111
- `position.z`.
109
+ The `bar` popup follows configured launcher placement; without an override it
110
+ keeps its centered layout. The modal-style `overlay` popup retains its preset
111
+ layout. `style.zIndex` takes precedence over `position.z`.
112
112
 
113
113
  ## User identity
114
114
 
@@ -41017,7 +41017,7 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
41017
41017
  let r = await navigator.mediaDevices.enumerateDevices(), i = r.find((e) => e.kind === "audioinput" && e.deviceId === n), a = r.find((e) => e.kind === "audiooutput" && i?.groupId && e.groupId === i.groupId);
41018
41018
  a && await e.setSinkId(a.deviceId);
41019
41019
  }, lce = (e) => {
41020
- let { config: { entityId: t } } = Kl(), { entityId: n } = xu(), { locale: r } = cA(), i = ql(), a = gu(i.config.consent), [o, s] = (0, lA.useState)([]), [c, l] = (0, lA.useState)(!1), [u, d] = (0, lA.useState)(!1), f = (0, lA.useRef)(null), p = (0, lA.useRef)(null), m = (0, lA.useRef)(null), h = (0, lA.useRef)(null), g = (0, lA.useRef)(null), _ = (0, lA.useRef)(0), v = (0, lA.useRef)(/* @__PURE__ */ new Set()), y = (0, lA.useRef)(null), b = (0, lA.useRef)(null), x = (0, lA.useCallback)((e) => {
41020
+ let { config: { entityId: t } } = Kl(), { entityId: n } = xu(), { locale: r } = cA(), i = ql(), a = gu(i.config.consent), [o, s] = (0, lA.useState)([]), [c, l] = (0, lA.useState)(!1), [u, d] = (0, lA.useState)(!1), f = (0, lA.useRef)(null), p = (0, lA.useRef)(null), m = (0, lA.useRef)(null), h = (0, lA.useRef)(null), g = (0, lA.useRef)(null), _ = (0, lA.useRef)(0), v = (0, lA.useRef)(/* @__PURE__ */ new Set()), y = (0, lA.useRef)(null), b = (0, lA.useRef)(null), x = (0, lA.useRef)(null), S = (0, lA.useRef)(null), C = (0, lA.useCallback)((e) => {
41021
41021
  s((t) => {
41022
41022
  let n = e.filter((e) => t.some((t) => t.id === e.id)), r = e.filter((e) => !t.some((t) => t.id === e.id));
41023
41023
  return [...t.map((e) => {
@@ -41032,13 +41032,13 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
41032
41032
  createdAt: e.createdAt || /* @__PURE__ */ new Date()
41033
41033
  }))];
41034
41034
  });
41035
- }, []), S = (0, lA.useCallback)((r, i, a) => {
41035
+ }, []), w = (0, lA.useCallback)((r, i, a) => {
41036
41036
  let o = r === "agent" ? b : y, s = o.current || {
41037
41037
  id: Tt(),
41038
41038
  content: "",
41039
41039
  createdAt: /* @__PURE__ */ new Date()
41040
41040
  }, c = a ? i : s.content + i;
41041
- c.trim() && x([{
41041
+ c.trim() && C([{
41042
41042
  id: s.id,
41043
41043
  content: c.trim(),
41044
41044
  createdAt: s.createdAt,
@@ -41051,16 +41051,16 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
41051
41051
  }, [
41052
41052
  n,
41053
41053
  e,
41054
- x,
41054
+ C,
41055
41055
  t
41056
- ]), C = (0, lA.useCallback)(() => {
41056
+ ]), T = (0, lA.useCallback)(() => {
41057
41057
  let e = f.current;
41058
41058
  f.current = null, e && e.readyState < WebSocket.CLOSING && e.close(), g.current?.disconnect(), g.current = null, m.current?.getTracks().forEach((e) => e.stop()), m.current = null, h.current &&= (navigator.mediaDevices.removeEventListener("devicechange", h.current), null), v.current.forEach((e) => {
41059
41059
  try {
41060
41060
  e.stop();
41061
41061
  } catch {}
41062
- }), v.current.clear(), y.current = null, b.current = null, _.current = 0, p.current?.close(), p.current = null, l(!1), d(!1);
41063
- }, []), w = (0, lA.useCallback)((e) => {
41062
+ }), v.current.clear(), y.current = null, b.current = null, x.current = null, S.current = null, _.current = 0, p.current?.close(), p.current = null, l(!1), d(!1);
41063
+ }, []), E = (0, lA.useCallback)((e) => {
41064
41064
  let t = p.current;
41065
41065
  if (!t) return;
41066
41066
  let n = cce(e), r = Math.floor(n.byteLength / 2), i = t.createBuffer(1, r, 24e3), a = i.getChannelData(0), o = new DataView(n.buffer, n.byteOffset, n.byteLength);
@@ -41069,13 +41069,13 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
41069
41069
  s.buffer = i, s.connect(t.destination);
41070
41070
  let c = Math.max(t.currentTime, _.current);
41071
41071
  s.start(c), _.current = c + i.duration, v.current.add(s), s.onended = () => v.current.delete(s);
41072
- }, []), T = (0, lA.useCallback)(() => {
41072
+ }, []), D = (0, lA.useCallback)(() => {
41073
41073
  v.current.forEach((e) => {
41074
41074
  try {
41075
41075
  e.stop();
41076
41076
  } catch {}
41077
41077
  }), v.current.clear(), _.current = p.current?.currentTime || 0;
41078
- }, []), E = (0, lA.useCallback)(async () => {
41078
+ }, []), O = (0, lA.useCallback)(async () => {
41079
41079
  if (t && n) {
41080
41080
  l(!0);
41081
41081
  try {
@@ -41089,9 +41089,9 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
41089
41089
  uA(_, u).catch((e) => console.warn("Unable to route voice playback to headset:", e));
41090
41090
  };
41091
41091
  navigator.mediaDevices.addEventListener("devicechange", v);
41092
- let x = new WebSocket(c.mediaUrl);
41093
- m.current = u, p.current = _, h.current = v, f.current = x, x.onopen = () => {
41094
- x.send(JSON.stringify({
41092
+ let C = new WebSocket(c.mediaUrl);
41093
+ m.current = u, p.current = _, h.current = v, f.current = C, C.onopen = () => {
41094
+ C.send(JSON.stringify({
41095
41095
  type: "proxy.configure",
41096
41096
  token: c.token,
41097
41097
  context: {
@@ -41113,7 +41113,7 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
41113
41113
  parameters: t.inputSchema
41114
41114
  }))
41115
41115
  }));
41116
- }, x.onmessage = async (e) => {
41116
+ }, C.onmessage = async (e) => {
41117
41117
  let t = JSON.parse(e.data);
41118
41118
  if (t.type === "proxy.tool_call") {
41119
41119
  let e = t.name ? s[t.name] : void 0, n;
@@ -41122,7 +41122,7 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
41122
41122
  } catch (e) {
41123
41123
  n = `Client tool "${t.name}" failed: ${e instanceof Error ? e.message : String(e)}`;
41124
41124
  }
41125
- x.readyState === WebSocket.OPEN && x.send(JSON.stringify({
41125
+ C.readyState === WebSocket.OPEN && C.send(JSON.stringify({
41126
41126
  type: "proxy.tool_result",
41127
41127
  callId: t.callId,
41128
41128
  output: n
@@ -41130,49 +41130,53 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
41130
41130
  } else if (t.type === "proxy.ready") {
41131
41131
  let e = _.createMediaStreamSource(u), t = _.createScriptProcessor(4096, 1, 1), n = _.createGain();
41132
41132
  n.gain.value = 0, t.onaudioprocess = (e) => {
41133
- if (x.readyState !== WebSocket.OPEN) return;
41133
+ if (C.readyState !== WebSocket.OPEN) return;
41134
41134
  let t = e.inputBuffer.getChannelData(0), n = new Int16Array(t.length);
41135
41135
  for (let e = 0; e < t.length; e += 1) {
41136
41136
  let r = Math.max(-1, Math.min(1, t[e]));
41137
41137
  n[e] = r < 0 ? r * 32768 : r * 32767;
41138
41138
  }
41139
- x.send(n.buffer);
41139
+ C.send(n.buffer);
41140
41140
  }, e.connect(t), t.connect(n), n.connect(_.destination), g.current = t, _.resume(), l(!1), d(!0);
41141
41141
  } else if (t.type === "proxy.takeover_announcement" && t.announcement) {
41142
- T(), speechSynthesis.cancel();
41142
+ D(), speechSynthesis.cancel();
41143
41143
  let e = new SpeechSynthesisUtterance(t.announcement);
41144
41144
  e.lang = r;
41145
41145
  let n = () => {
41146
- x.readyState === WebSocket.OPEN && x.send(JSON.stringify({ type: "proxy.takeover_announcement_done" }));
41146
+ C.readyState === WebSocket.OPEN && C.send(JSON.stringify({ type: "proxy.takeover_announcement_done" }));
41147
41147
  };
41148
41148
  e.onend = n, e.onerror = n, speechSynthesis.speak(e);
41149
- } else t.type === "response.output_audio.delta" ? t.delta && w(t.delta) : t.type === "input_audio_buffer.speech_started" ? (T(), y.current = null, b.current = null) : t.type === "conversation.item.input_audio_transcription.delta" ? S("user", t.delta || "", !1) : t.type === "conversation.item.input_audio_transcription.completed" ? S("user", t.transcript || "", !0) : t.type === "response.output_audio_transcript.delta" ? S("agent", t.delta || "", !1) : t.type === "response.output_audio_transcript.done" ? S("agent", t.transcript || "", !0) : t.type === "error" && console.error("OpenAI Realtime error:", t.message || t);
41150
- }, x.onerror = (e) => {
41151
- console.error("OpenAI Realtime connection failed:", e), C();
41152
- }, x.onclose = () => C();
41149
+ } else if (t.type === "session.output_audio.delta") t.delta && E(t.delta);
41150
+ else if (t.type === "session.input_transcript.delta" || t.type === "session.output_transcript.delta") {
41151
+ let e = t.type === "session.input_transcript.delta", n = e ? x : S, r = e ? y : b;
41152
+ n.current !== null && t.start_ms !== void 0 && t.start_ms > n.current + 1200 && (r.current = null, e && D()), e && n.current === null && D(), n.current = t.end_ms ?? n.current, w(e ? "user" : "agent", t.delta || "", !1);
41153
+ } else t.type === "error" && console.error("OpenAI Live error:", t.message || t);
41154
+ }, C.onerror = (e) => {
41155
+ console.error("OpenAI Realtime connection failed:", e), T();
41156
+ }, C.onclose = () => T();
41153
41157
  } catch (e) {
41154
- C(), console.error("Failed to start OpenAI Realtime conversation:", e);
41158
+ T(), console.error("Failed to start OpenAI Realtime conversation:", e);
41155
41159
  }
41156
41160
  }
41157
41161
  }, [
41158
- T,
41162
+ D,
41159
41163
  n,
41160
41164
  e,
41161
41165
  i,
41162
41166
  r,
41163
- w,
41167
+ E,
41164
41168
  a.analytics,
41165
- C,
41169
+ T,
41166
41170
  t,
41167
- S
41171
+ w
41168
41172
  ]);
41169
41173
  return (0, lA.useEffect)(() => () => {
41170
- f.current && C();
41171
- }, [C]), {
41172
- startCall: E,
41173
- endCall: C,
41174
+ f.current && T();
41175
+ }, [T]), {
41176
+ startCall: O,
41177
+ endCall: T,
41174
41178
  messages: o,
41175
- onMessages: x,
41179
+ onMessages: C,
41176
41180
  isConnected: u,
41177
41181
  isConnecting: c
41178
41182
  };
@@ -68558,7 +68562,13 @@ var rV, iV, Bpe = o((() => {
68558
68562
  };
68559
68563
  })), Pq, Fq, Iq, eye = o((() => {
68560
68564
  Pq = /* @__PURE__ */ u(m(), 1), yA(), Gpe(), fH(), hH(), Nq(), Fq = nn(), Iq = ({ canStore: e, displayMode: t, displaySize: n, onClickQuickAction: r, onClickDisplaySize: i, onMessages: a, sendMessage: o, children: s, onOpenChange: c, hasChatUserMessages: l, userMessages: u, mode: d, onClickNewChat: f, onClickCall: p, callIsConnected: m, callIsConnecting: h }) => {
68561
- let { formatMessage: g } = cA(), { isMobile: _ } = Tu(), { config: { entityId: v, withQuickActions: y, quickActions: b, withLocale: x, withConsent: S, privacyUrl: C, position: w, style: T }, isLoading: E } = Kl(), { entityId: D } = xu(), O = y === "visible" || y === "visible-desktop" && !_, { background: ee, styles: { color: k, borderColor: te, backgroundColor70: A, spacingXS: j, spacingMD: M, marginRight: N, marginBottom: P, openerDimensions: F, transitionSpeed: ne, borderRadiusLg: re, shadowOuter: ie, themeColors: ae } } = gA(), { config: oe, target: I, isCustomTarget: se } = ql(), { session: ce, setSession: le } = Yl(v, D, I, oe.widgetId, e), [ue, de] = (0, Pq.useState)(), fe = ue ?? oe.isOpen ?? ce.isOpen ?? !1, pe = ce.isMaximized ?? oe.isMaximized ?? !1, L = oe.position === void 0 ? w : oe.position, me = oe.style === void 0 ? T : oe.style, he = me?.zIndex ?? L?.z ?? 8, ge = (0, Pq.useRef)(null), _e = (0, Pq.useRef)(null), R = (0, Pq.useRef)(!1), ve = (0, Pq.useCallback)((e) => {
68565
+ let { formatMessage: g } = cA(), { isMobile: _ } = Tu(), { config: { entityId: v, withQuickActions: y, quickActions: b, withLocale: x, withConsent: S, privacyUrl: C, position: w, style: T }, isLoading: E } = Kl(), { entityId: D } = xu(), O = y === "visible" || y === "visible-desktop" && !_, { background: ee, styles: { color: k, borderColor: te, backgroundColor70: A, spacingXS: j, spacingMD: M, marginRight: N, marginBottom: P, openerDimensions: F, transitionSpeed: ne, borderRadiusLg: re, shadowOuter: ie, themeColors: ae } } = gA(), { config: oe, target: I, isCustomTarget: se } = ql(), { session: ce, setSession: le } = Yl(v, D, I, oe.widgetId, e), [ue, de] = (0, Pq.useState)(), fe = ue ?? oe.isOpen ?? ce.isOpen ?? !1, pe = ce.isMaximized ?? oe.isMaximized ?? !1, L = oe.position === void 0 ? w : oe.position === null ? void 0 : {
68566
+ ...w,
68567
+ ...oe.position
68568
+ }, me = oe.style === void 0 ? T : oe.style === null ? void 0 : {
68569
+ ...T,
68570
+ ...oe.style
68571
+ }, he = me?.zIndex ?? L?.z ?? 8, ge = (0, Pq.useRef)(null), _e = (0, Pq.useRef)(null), R = (0, Pq.useRef)(!1), ve = (0, Pq.useCallback)((e) => {
68562
68572
  de(e), le({ isOpen: e }), c?.(e);
68563
68573
  }, [le, c]), ye = (0, Pq.useCallback)((e) => {
68564
68574
  le({ isMaximized: e });
@@ -68593,13 +68603,13 @@ var rV, iV, Bpe = o((() => {
68593
68603
  top: Ne ? ke?.top : je === "top" ? P : je === "center" ? "50%" : void 0,
68594
68604
  bottom: Ne ? ke?.bottom : je === "bottom" ? P : void 0,
68595
68605
  transform: `translate(${!Me && Ae === "center" ? "-50%" : "0"}, ${!Ne && je === "center" ? "-50%" : "0"})`
68596
- }, Fe = Pe.top !== void 0 && Pe.top !== "auto", Ie = Fe ? `calc(${Pe.top} + ${F} + ${M})` : void 0, Le = Fe ? void 0 : Pe.bottom !== void 0 && Pe.bottom !== "auto" ? `calc(${Pe.bottom} + ${F} + ${M})` : Ee, Re = {
68597
- top: Ie,
68598
- bottom: Le,
68606
+ }, Fe = Pe.top !== void 0 && Pe.top !== "auto", Ie = Oe === "input" ? "64px" : `calc(${F} + ${M})`, Le = Fe ? `calc(${Pe.top} + ${Ie})` : void 0, Re = Fe ? void 0 : Pe.bottom !== void 0 && Pe.bottom !== "auto" ? `calc(${Pe.bottom} + ${Ie})` : Ee, ze = {
68607
+ top: Le,
68608
+ bottom: Re,
68599
68609
  left: Pe.left,
68600
68610
  right: Pe.right,
68601
68611
  transform: `translate(${!Me && Ae === "center" ? "-50%" : "0"}, 0)`
68602
- }, ze = !xe && !Se, Be = ze ? Ie ?? Le ?? Ee : Ee, Ve = dH(ee, ae, "bottom"), He = uH(t, d, ee), Ue = d === "text" && S !== !0;
68612
+ }, Be = !xe && !Se || Oe === "input" && (L?.x !== void 0 || L?.y !== void 0 || Me || Ne), Ve = Be ? Le ?? Re ?? Ee : Ee, He = dH(ee, ae, "bottom"), Ue = uH(t, d, ee), We = d === "text" && S !== !0;
68603
68613
  return /* @__PURE__ */ (0, Fq.jsxs)(Fq.Fragment, { children: [/* @__PURE__ */ (0, Fq.jsxs)("div", {
68604
68614
  ref: ge,
68605
68615
  role: "dialog",
@@ -68614,14 +68624,14 @@ var rV, iV, Bpe = o((() => {
68614
68624
  transform: `translate(${xe ? "50%" : "0"}, ${Se ? "50%" : "0"})`,
68615
68625
  bottom: Ee,
68616
68626
  right: Te,
68617
- ...ze ? Re : {},
68627
+ ...Be ? ze : {},
68618
68628
  backgroundColor: A,
68619
68629
  backdropFilter: "blur(48px)",
68620
68630
  boxSizing: "border-box",
68621
68631
  width: `min(calc(100% - ${N} - ${N}), ${Ce})`,
68622
- height: Se ? "80dvh" : `min(calc(100dvh - ${P} - ${Be}), ${we})`,
68632
+ height: Se ? "80dvh" : `min(calc(100dvh - ${P} - ${Ve}), ${we})`,
68623
68633
  maxWidth: xe ? "1000px" : void 0,
68624
- maxHeight: Se ? "1000px" : `calc(100dvh - ${Be} - ${M})`,
68634
+ maxHeight: Se ? "1000px" : `calc(100dvh - ${Ve} - ${M})`,
68625
68635
  display: "flex",
68626
68636
  visibility: fe ? "visible" : "hidden",
68627
68637
  opacity: fe ? "1" : "0",
@@ -68650,7 +68660,7 @@ var rV, iV, Bpe = o((() => {
68650
68660
  style: {
68651
68661
  opacity: "0.5",
68652
68662
  flexShrink: 0,
68653
- color: He ? Ve : void 0,
68663
+ color: Ue ? He : void 0,
68654
68664
  paddingBottom: j,
68655
68665
  width: "100%",
68656
68666
  textAlign: "center",
@@ -68659,7 +68669,7 @@ var rV, iV, Bpe = o((() => {
68659
68669
  },
68660
68670
  children: /* @__PURE__ */ (0, Fq.jsx)("span", {
68661
68671
  style: { fontSize: "0.7em" },
68662
- children: Ue ? g({ id: "chat-privacy-notice" }, { 0: C ? /* @__PURE__ */ (0, Fq.jsx)(mH, {
68672
+ children: We ? g({ id: "chat-privacy-notice" }, { 0: C ? /* @__PURE__ */ (0, Fq.jsx)(mH, {
68663
68673
  href: C,
68664
68674
  target: "_blank",
68665
68675
  rel: "noopener noreferrer",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellyouai/plugin",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Framework-agnostic browser SDK for the Tellyou AI plugin",
5
5
  "repository": {
6
6
  "type": "git",