@skippr/live-agent-sdk 0.58.0 → 0.59.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.
@@ -732,6 +732,7 @@ var NAME_MAX_CHARS = 80;
732
732
  // src/lib/launcher.ts
733
733
  var DEFAULT_LAUNCHER_BOTTOM_PX = 48;
734
734
  var LAUNCHER_HEIGHT_PX = 50;
735
+ var WIDGET_EDGE_MARGIN_PX = 12;
735
736
  var SESSION_BAR_CLEARANCE_PX = 76;
736
737
  var TRIGGER_HEIGHT_PX = 48;
737
738
  var IDLE_TRIGGER_CLEARANCE_PX = TRIGGER_HEIGHT_PX + 16;
@@ -1060,7 +1061,7 @@ var __iconNode21 = [
1060
1061
  ];
1061
1062
  var X = createLucideIcon("x", __iconNode21);
1062
1063
  // src/components/AgentCursor.tsx
1063
- import { useEffect as useEffect6, useLayoutEffect, useRef as useRef2, useState as useState6 } from "react";
1064
+ import { useContext as useContext2, useEffect as useEffect6, useLayoutEffect, useRef as useRef2, useState as useState6 } from "react";
1064
1065
 
1065
1066
  // src/capture/elementRef.ts
1066
1067
  function safeGetIframeDocument(iframe) {
@@ -1212,9 +1213,6 @@ var BASIC_ACT_DELAY_MS = 150;
1212
1213
  var TRACK_GLIDE_MS = 90;
1213
1214
  var GESTURE_GLIDE_MS = 500;
1214
1215
  var GESTURE_ACT_DELAY_MS = 200;
1215
- function cursorEntryPoint() {
1216
- return { x: window.innerWidth - 72, y: window.innerHeight - 80 };
1217
- }
1218
1216
  function gesturePoint(direction) {
1219
1217
  return {
1220
1218
  x: window.innerWidth / 2,
@@ -1224,6 +1222,13 @@ function gesturePoint(direction) {
1224
1222
  function centerOf(rect) {
1225
1223
  return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };
1226
1224
  }
1225
+ function launcherCenter(position, launcherBottomPx) {
1226
+ const edge = WIDGET_EDGE_MARGIN_PX + LAUNCHER_HEIGHT_PX / 2;
1227
+ return {
1228
+ x: position === "left" ? edge : window.innerWidth - edge,
1229
+ y: window.innerHeight - launcherBottomPx - LAUNCHER_HEIGHT_PX / 2
1230
+ };
1231
+ }
1227
1232
  function ringTopLeft(rect) {
1228
1233
  return { x: rect.left - RING_PAD + 1 + ringRadius(rect), y: rect.top - RING_PAD + 1 };
1229
1234
  }
@@ -1238,6 +1243,7 @@ function AgentCursor({
1238
1243
  target,
1239
1244
  animated = false
1240
1245
  }) {
1246
+ const ctx = useContext2(LiveAgentContext);
1241
1247
  const [cursor, setCursor] = useState6(null);
1242
1248
  const [glideMs, setGlideMs] = useState6(0);
1243
1249
  const [phase, setPhase] = useState6("idle");
@@ -1307,7 +1313,8 @@ function AgentCursor({
1307
1313
  setPhase("done");
1308
1314
  setRingBox(null);
1309
1315
  const destination = gesturePoint(target.gesture.direction);
1310
- startGlide(prevCursorRef.current ?? cursorEntryPoint(), destination, GESTURE_GLIDE_MS, () => {
1316
+ const from2 = prevCursorRef.current ?? launcherCenter(ctx?.position ?? "right", ctx?.launcherBottomPx ?? 0);
1317
+ startGlide(from2, destination, GESTURE_GLIDE_MS, () => {
1311
1318
  if (target.mode === "act") {
1312
1319
  after(GESTURE_ACT_DELAY_MS, () => target.onAct?.());
1313
1320
  }
@@ -1345,7 +1352,7 @@ function AgentCursor({
1345
1352
  return cancelAnimation;
1346
1353
  }
1347
1354
  setPhase("travel");
1348
- const from = prevCursorRef.current ?? cursorEntryPoint();
1355
+ const from = prevCursorRef.current ?? launcherCenter(ctx?.position ?? "right", ctx?.launcherBottomPx ?? 0);
1349
1356
  const start = ringTopLeft(rect);
1350
1357
  startGlide(from, start, glideDuration(from, start), () => {
1351
1358
  after(DRAW_START_DELAY_MS, () => {
@@ -2547,7 +2554,7 @@ function HighlightOverlay() {
2547
2554
  }
2548
2555
 
2549
2556
  // src/components/MinimizedBubble.tsx
2550
- import { useContext as useContext2, useEffect as useEffect11, useRef as useRef7, useState as useState7 } from "react";
2557
+ import { useContext as useContext3, useEffect as useEffect11, useRef as useRef7, useState as useState7 } from "react";
2551
2558
 
2552
2559
  // src/hooks/useLauncherDrag.ts
2553
2560
  import { useEffect as useEffect10, useRef as useRef6 } from "react";
@@ -2834,7 +2841,7 @@ function MinimizedBubble({
2834
2841
  welcomeDismissed,
2835
2842
  onDismissWelcome
2836
2843
  }) {
2837
- const ctx = useContext2(LiveAgentContext);
2844
+ const ctx = useContext3(LiveAgentContext);
2838
2845
  if (!ctx) {
2839
2846
  throw new Error("MinimizedBubble must be used within a <LiveAgent> provider");
2840
2847
  }
@@ -3327,7 +3334,7 @@ function PageActionHandler() {
3327
3334
  }
3328
3335
 
3329
3336
  // src/components/SessionControlBar.tsx
3330
- import { useContext as useContext5, useRef as useRef10 } from "react";
3337
+ import { useContext as useContext6, useRef as useRef10 } from "react";
3331
3338
 
3332
3339
  // src/hooks/useAgentVoiceState.ts
3333
3340
  import { useVoiceAssistant } from "@livekit/components-react/hooks";
@@ -3399,9 +3406,9 @@ function useAudioLevelBars(mediaStreamTrack, { barCount, idleHeightPx, maxGrowth
3399
3406
  }
3400
3407
 
3401
3408
  // src/hooks/useLiveAgent.ts
3402
- import { useContext as useContext3 } from "react";
3409
+ import { useContext as useContext4 } from "react";
3403
3410
  function useLiveAgent() {
3404
- const ctx = useContext3(LiveAgentContext);
3411
+ const ctx = useContext4(LiveAgentContext);
3405
3412
  if (!ctx) {
3406
3413
  throw new Error("useLiveAgent must be used within a <LiveAgent> provider");
3407
3414
  }
@@ -3474,7 +3481,7 @@ function useMicLevel(enabled) {
3474
3481
  }
3475
3482
 
3476
3483
  // src/hooks/usePhaseUpdates.ts
3477
- import { useCallback as useCallback8, useContext as useContext4, useEffect as useEffect15 } from "react";
3484
+ import { useCallback as useCallback8, useContext as useContext5, useEffect as useEffect15 } from "react";
3478
3485
 
3479
3486
  // src/hooks/useAgentState.ts
3480
3487
  import { useRemoteParticipants } from "@livekit/components-react/hooks";
@@ -3530,7 +3537,7 @@ function parsePhases(json) {
3530
3537
  function usePhaseUpdates() {
3531
3538
  const parse = useCallback8(parsePhases, []);
3532
3539
  const livePhases = useAgentState("phases", parse, []);
3533
- const ctx = useContext4(LiveAgentContext);
3540
+ const ctx = useContext5(LiveAgentContext);
3534
3541
  useEffect15(() => {
3535
3542
  if (livePhases.length > 0)
3536
3543
  ctx?.setPhasesSnapshot(livePhases);
@@ -3630,7 +3637,7 @@ function SessionControlBar() {
3630
3637
  position,
3631
3638
  variant
3632
3639
  } = useLiveAgent();
3633
- const internalCtx = useContext5(LiveAgentContext);
3640
+ const internalCtx = useContext6(LiveAgentContext);
3634
3641
  const textMode = internalCtx?.textMode ?? false;
3635
3642
  const launcherBottomPx = internalCtx?.launcherBottomPx ?? DEFAULT_LAUNCHER_BOTTOM_PX;
3636
3643
  const popsDown = internalCtx?.popsDown ?? false;
@@ -3873,10 +3880,10 @@ function ShadowHost({ children }) {
3873
3880
  }
3874
3881
 
3875
3882
  // src/components/Sidebar.tsx
3876
- import { useContext as useContext9, useEffect as useEffect20 } from "react";
3883
+ import { useContext as useContext10, useEffect as useEffect20 } from "react";
3877
3884
 
3878
3885
  // src/hooks/useCombinedMessages.ts
3879
- import { useContext as useContext6, useMemo as useMemo5 } from "react";
3886
+ import { useContext as useContext7, useMemo as useMemo5 } from "react";
3880
3887
 
3881
3888
  // src/hooks/useChatMessages.ts
3882
3889
  import { useChat, useLocalParticipant as useLocalParticipant5 } from "@livekit/components-react/hooks";
@@ -3944,7 +3951,7 @@ function useCombinedMessages() {
3944
3951
  const { transcriptMessages } = useStreamingTranscript();
3945
3952
  const { chatMessages, sendChatMessage, isSendingChat } = useChatMessages();
3946
3953
  const { state: agentState } = useAgentVoiceState();
3947
- const historyMessages = useContext6(LiveAgentContext)?.historyMessages ?? [];
3954
+ const historyMessages = useContext7(LiveAgentContext)?.historyMessages ?? [];
3948
3955
  const liveMessages = useMemo5(() => {
3949
3956
  if (chatMessages.length === 0)
3950
3957
  return transcriptMessages;
@@ -3998,10 +4005,10 @@ function useSessionRemaining() {
3998
4005
 
3999
4006
  // src/hooks/useTextMode.ts
4000
4007
  import { useLocalParticipant as useLocalParticipant7 } from "@livekit/components-react/hooks";
4001
- import { useCallback as useCallback9, useContext as useContext7, useRef as useRef13 } from "react";
4008
+ import { useCallback as useCallback9, useContext as useContext8, useRef as useRef13 } from "react";
4002
4009
  var textEncoder3 = new TextEncoder;
4003
4010
  function useTextMode() {
4004
- const ctx = useContext7(LiveAgentContext);
4011
+ const ctx = useContext8(LiveAgentContext);
4005
4012
  if (!ctx) {
4006
4013
  throw new Error("useTextMode must be used within a <LiveAgent> provider");
4007
4014
  }
@@ -4030,7 +4037,7 @@ function useTextMode() {
4030
4037
  }
4031
4038
 
4032
4039
  // src/components/ChatHeader.tsx
4033
- import { useContext as useContext8 } from "react";
4040
+ import { useContext as useContext9 } from "react";
4034
4041
 
4035
4042
  // src/hooks/useElapsedSeconds.ts
4036
4043
  import { useEffect as useEffect17, useState as useState12 } from "react";
@@ -4055,7 +4062,7 @@ function useElapsedSeconds(isRunning) {
4055
4062
  import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
4056
4063
  function ChatHeader() {
4057
4064
  const { isConnected, variant } = useLiveAgent();
4058
- const internalCtx = useContext8(LiveAgentContext);
4065
+ const internalCtx = useContext9(LiveAgentContext);
4059
4066
  const panelExpanded = internalCtx?.panelExpanded ?? false;
4060
4067
  const togglePanelExpanded = internalCtx?.togglePanelExpanded ?? (() => {});
4061
4068
  const elapsed = useElapsedSeconds(isConnected);
@@ -4769,7 +4776,7 @@ function Sidebar({
4769
4776
  agentMode,
4770
4777
  agentControls
4771
4778
  } = useLiveAgent();
4772
- const internalCtx = useContext9(LiveAgentContext);
4779
+ const internalCtx = useContext10(LiveAgentContext);
4773
4780
  const usesHostAuth = internalCtx?.usesHostAuth ?? false;
4774
4781
  const authFailed = internalCtx?.authFailed ?? false;
4775
4782
  const launcherBottomPx = internalCtx?.launcherBottomPx ?? DEFAULT_LAUNCHER_BOTTOM_PX;
@@ -5029,7 +5036,7 @@ function ConnectedBody({
5029
5036
  }
5030
5037
 
5031
5038
  // src/components/SidebarTrigger.tsx
5032
- import { useContext as useContext10 } from "react";
5039
+ import { useContext as useContext11 } from "react";
5033
5040
 
5034
5041
  // src/components/Logo.tsx
5035
5042
  import { jsx as jsx19, jsxs as jsxs16 } from "react/jsx-runtime";
@@ -5081,7 +5088,7 @@ function SidebarTrigger() {
5081
5088
  isStarting,
5082
5089
  isPausing
5083
5090
  } = useLiveAgent();
5084
- const internalCtx = useContext10(LiveAgentContext);
5091
+ const internalCtx = useContext11(LiveAgentContext);
5085
5092
  const launcherBottomPx = internalCtx?.launcherBottomPx ?? DEFAULT_LAUNCHER_BOTTOM_PX;
5086
5093
  const popsDown = internalCtx?.popsDown ?? false;
5087
5094
  if (isMinimized || isConnected || isStarting || isPausing)