@skippr/live-agent-sdk 0.114.0 → 0.115.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.
@@ -7177,10 +7177,15 @@ function DomCapture({ pushOrTapMicMode = false, startMuted = false }) {
7177
7177
  }
7178
7178
 
7179
7179
  // src/components/HighlightOverlay.tsx
7180
- import { useDataChannel } from "@livekit/components-react/hooks";
7180
+ import { useDataChannel, useLocalParticipant as useLocalParticipant6 } from "@livekit/components-react/hooks";
7181
7181
  import { useCallback as useCallback18, useEffect as useEffect25, useRef as useRef19 } from "react";
7182
- var HIGHLIGHT_AUTO_CLEAR_MS = 25000;
7183
- var HIGHLIGHT_RETARGET_INTERVAL_MS = 250;
7182
+ var HIGHLIGHT_AUTO_CLEAR_MS = 30000;
7183
+ var PAGE_CHECK_MS = 250;
7184
+ var ACTED_REASON = "acted";
7185
+ var NAVIGATED_REASON = "navigated";
7186
+ var EXPIRED_REASON = "expired";
7187
+ var ELEMENT_GONE_REASON = "element-gone";
7188
+ var textEncoder5 = new TextEncoder;
7184
7189
  var textDecoder = new TextDecoder;
7185
7190
  function parseHighlightMessage(payload) {
7186
7191
  try {
@@ -7202,8 +7207,10 @@ function parseHighlightMessage(payload) {
7202
7207
  }
7203
7208
  }
7204
7209
  function HighlightOverlay() {
7210
+ const { localParticipant } = useLocalParticipant6();
7205
7211
  const targetRef = useRef19(null);
7206
7212
  const shownRef = useRef19(null);
7213
+ const shownUrlRef = useRef19(null);
7207
7214
  const autoClearRef = useRef19(null);
7208
7215
  const clear = useCallback18(() => {
7209
7216
  if (autoClearRef.current)
@@ -7211,9 +7218,17 @@ function HighlightOverlay() {
7211
7218
  autoClearRef.current = null;
7212
7219
  targetRef.current = null;
7213
7220
  shownRef.current = null;
7221
+ shownUrlRef.current = null;
7214
7222
  clearCursorTarget("guide");
7215
7223
  setHighlightActive(false);
7216
7224
  }, []);
7225
+ const clearAndReport = useCallback18((reason) => {
7226
+ clear();
7227
+ localParticipant.publishData(textEncoder5.encode(JSON.stringify({ type: "cleared", reason })), {
7228
+ reliable: true,
7229
+ topic: HIGHLIGHT_TOPIC
7230
+ }).catch((error) => console.error("Failed to report highlight clear:", error));
7231
+ }, [clear, localParticipant]);
7217
7232
  const onHighlightMessage = useCallback18((msg) => {
7218
7233
  const parsed = parseHighlightMessage(msg.payload);
7219
7234
  if (!parsed)
@@ -7224,32 +7239,56 @@ function HighlightOverlay() {
7224
7239
  }
7225
7240
  const element = findElementByRef(parsed.ref);
7226
7241
  if (!element) {
7227
- clear();
7242
+ clearAndReport(ELEMENT_GONE_REASON);
7228
7243
  return;
7229
7244
  }
7230
7245
  if (autoClearRef.current)
7231
7246
  clearTimeout(autoClearRef.current);
7232
7247
  targetRef.current = element;
7233
7248
  shownRef.current = parsed;
7249
+ shownUrlRef.current = window.location.href;
7234
7250
  setCursorTarget("guide", {
7235
7251
  element,
7236
7252
  label: parsed.message || "Click here",
7237
7253
  mode: "guide"
7238
7254
  });
7239
7255
  setHighlightActive(true);
7240
- autoClearRef.current = setTimeout(clear, HIGHLIGHT_AUTO_CLEAR_MS);
7241
- }, [clear]);
7256
+ autoClearRef.current = setTimeout(() => clearAndReport(EXPIRED_REASON), HIGHLIGHT_AUTO_CLEAR_MS);
7257
+ }, [clear, clearAndReport]);
7242
7258
  useDataChannel(HIGHLIGHT_TOPIC, onHighlightMessage);
7243
7259
  useEffect25(() => onHighlightCleared(clear), [clear]);
7244
7260
  useEffect25(() => {
7245
- const timer = setInterval(() => {
7261
+ const onClick = (event) => {
7262
+ const target = targetRef.current;
7263
+ if (!target)
7264
+ return;
7265
+ const node = event.composedPath()[0];
7266
+ if (!(node instanceof Node))
7267
+ return;
7268
+ if (!target.contains(node))
7269
+ return;
7270
+ if (isAgentActionInProgress())
7271
+ return;
7272
+ clearAndReport(ACTED_REASON);
7273
+ };
7274
+ document.addEventListener("click", onClick, { capture: true });
7275
+ return () => document.removeEventListener("click", onClick, { capture: true });
7276
+ }, [clearAndReport]);
7277
+ useEffect25(() => {
7278
+ const interval = setInterval(() => {
7246
7279
  const shown = shownRef.current;
7247
7280
  const target = targetRef.current;
7248
- if (!shown || !target || target.isConnected)
7281
+ if (!shown || !target)
7282
+ return;
7283
+ if (shownUrlRef.current !== window.location.href) {
7284
+ clearAndReport(NAVIGATED_REASON);
7285
+ return;
7286
+ }
7287
+ if (target.isConnected)
7249
7288
  return;
7250
7289
  const replacement = findElementByRef(shown.ref);
7251
7290
  if (!replacement) {
7252
- clear();
7291
+ clearAndReport(ELEMENT_GONE_REASON);
7253
7292
  return;
7254
7293
  }
7255
7294
  targetRef.current = replacement;
@@ -7258,19 +7297,9 @@ function HighlightOverlay() {
7258
7297
  label: shown.message || "Click here",
7259
7298
  mode: "guide"
7260
7299
  });
7261
- }, HIGHLIGHT_RETARGET_INTERVAL_MS);
7262
- return () => clearInterval(timer);
7263
- }, [clear]);
7264
- useEffect25(() => {
7265
- const onClick = (event) => {
7266
- const target = targetRef.current;
7267
- const node = event.target;
7268
- if (target && node && target.contains(node))
7269
- clear();
7270
- };
7271
- document.addEventListener("click", onClick, { capture: true });
7272
- return () => document.removeEventListener("click", onClick, { capture: true });
7273
- }, [clear]);
7300
+ }, PAGE_CHECK_MS);
7301
+ return () => clearInterval(interval);
7302
+ }, [clearAndReport]);
7274
7303
  useEffect25(() => clear, [clear]);
7275
7304
  return null;
7276
7305
  }
@@ -8207,11 +8236,11 @@ function PageActionHandler() {
8207
8236
  import { useCallback as useCallback22, useContext as useContext11, useEffect as useEffect32, useState as useState24 } from "react";
8208
8237
 
8209
8238
  // src/hooks/useActionControl.ts
8210
- import { useLocalParticipant as useLocalParticipant6 } from "@livekit/components-react/hooks";
8239
+ import { useLocalParticipant as useLocalParticipant7 } from "@livekit/components-react/hooks";
8211
8240
  import { useCallback as useCallback20, useEffect as useEffect29, useState as useState22 } from "react";
8212
- var textEncoder5 = new TextEncoder;
8241
+ var textEncoder6 = new TextEncoder;
8213
8242
  function useActionControl() {
8214
- const { localParticipant } = useLocalParticipant6();
8243
+ const { localParticipant } = useLocalParticipant7();
8215
8244
  const plan = usePlanUpdates();
8216
8245
  const [busy, setBusy] = useState22(isActionsBusy);
8217
8246
  useEffect29(() => subscribeActionsBusy(setBusy), []);
@@ -8219,7 +8248,7 @@ function useActionControl() {
8219
8248
  const requestStop = useCallback20(async () => {
8220
8249
  stopActions();
8221
8250
  try {
8222
- await localParticipant.publishData(textEncoder5.encode(JSON.stringify({ type: "abort" })), {
8251
+ await localParticipant.publishData(textEncoder6.encode(JSON.stringify({ type: "abort" })), {
8223
8252
  reliable: true,
8224
8253
  topic: ACTION_CONTROL_TOPIC
8225
8254
  });
@@ -8324,11 +8353,11 @@ function useIdleAutoPause({
8324
8353
  }
8325
8354
 
8326
8355
  // src/hooks/useLiveUserTranscript.ts
8327
- import { useLocalParticipant as useLocalParticipant7 } from "@livekit/components-react/hooks";
8356
+ import { useLocalParticipant as useLocalParticipant8 } from "@livekit/components-react/hooks";
8328
8357
  import { useRef as useRef25 } from "react";
8329
8358
  function useLiveUserTranscript(active) {
8330
8359
  const transcriptions = useSharedTranscriptions();
8331
- const { localParticipant } = useLocalParticipant7();
8360
+ const { localParticipant } = useLocalParticipant8();
8332
8361
  const localIdentity = localParticipant.identity;
8333
8362
  const priorStreamIdsRef = useRef25(new Set);
8334
8363
  const wasActiveRef = useRef25(false);
@@ -8343,13 +8372,13 @@ function useLiveUserTranscript(active) {
8343
8372
  }
8344
8373
 
8345
8374
  // src/hooks/useMicLevel.ts
8346
- import { useLocalParticipant as useLocalParticipant8 } from "@livekit/components-react/hooks";
8375
+ import { useLocalParticipant as useLocalParticipant9 } from "@livekit/components-react/hooks";
8347
8376
  var MIC_BARS = 5;
8348
8377
  var IDLE_BAR_HEIGHT_PX = 5;
8349
8378
  var MAX_BAR_GROWTH_PX = 17;
8350
8379
  var MIC_NOISE_GATE = 0.15;
8351
8380
  function useMicLevel(enabled) {
8352
- const { microphoneTrack } = useLocalParticipant8();
8381
+ const { microphoneTrack } = useLocalParticipant9();
8353
8382
  const mediaStreamTrack = microphoneTrack?.track?.mediaStreamTrack;
8354
8383
  return useAudioLevelBars(enabled ? mediaStreamTrack : undefined, {
8355
8384
  barCount: MIC_BARS,
@@ -9013,7 +9042,7 @@ import { useCallback as useCallback28, useContext as useContext18, useEffect as
9013
9042
  import { useContext as useContext12, useMemo as useMemo8 } from "react";
9014
9043
 
9015
9044
  // src/hooks/useChatMessages.ts
9016
- import { useChat, useLocalParticipant as useLocalParticipant9 } from "@livekit/components-react/hooks";
9045
+ import { useChat, useLocalParticipant as useLocalParticipant10 } from "@livekit/components-react/hooks";
9017
9046
  import { useMemo as useMemo6 } from "react";
9018
9047
 
9019
9048
  // src/lib/filterSystemMessages.ts
@@ -9025,7 +9054,7 @@ function filterSystemMessages(messages) {
9025
9054
  // src/hooks/useChatMessages.ts
9026
9055
  function useChatMessages() {
9027
9056
  const { chatMessages: rawMessages, send, isSending } = useChat();
9028
- const { localParticipant } = useLocalParticipant9();
9057
+ const { localParticipant } = useLocalParticipant10();
9029
9058
  const localIdentity = localParticipant.identity;
9030
9059
  const chatMessages = useMemo6(() => {
9031
9060
  const sortedMessages = rawMessages.map((msg) => ({
@@ -9041,11 +9070,11 @@ function useChatMessages() {
9041
9070
  }
9042
9071
 
9043
9072
  // src/hooks/useStreamingTranscript.ts
9044
- import { useLocalParticipant as useLocalParticipant10 } from "@livekit/components-react/hooks";
9073
+ import { useLocalParticipant as useLocalParticipant11 } from "@livekit/components-react/hooks";
9045
9074
  import { useMemo as useMemo7, useRef as useRef27 } from "react";
9046
9075
  function useStreamingTranscript() {
9047
9076
  const transcriptions = useSharedTranscriptions();
9048
- const { localParticipant } = useLocalParticipant10();
9077
+ const { localParticipant } = useLocalParticipant11();
9049
9078
  const { isCapturingSpeech } = useVoiceTurnContext();
9050
9079
  const localIdentity = localParticipant.identity;
9051
9080
  const priorUserStreamIdsRef = useRef27(new Set);
@@ -9270,16 +9299,16 @@ function panelTransformOrigin(popsDown, isLeftAligned) {
9270
9299
  import { useContext as useContext15 } from "react";
9271
9300
 
9272
9301
  // src/hooks/useTextMode.ts
9273
- import { useLocalParticipant as useLocalParticipant11 } from "@livekit/components-react/hooks";
9302
+ import { useLocalParticipant as useLocalParticipant12 } from "@livekit/components-react/hooks";
9274
9303
  import { useCallback as useCallback25, useContext as useContext14, useRef as useRef29 } from "react";
9275
- var textEncoder6 = new TextEncoder;
9304
+ var textEncoder7 = new TextEncoder;
9276
9305
  function useTextMode() {
9277
9306
  const ctx = useContext14(LiveAgentContext);
9278
9307
  if (!ctx) {
9279
9308
  throw new Error("useTextMode must be used within a <LiveAgent> provider");
9280
9309
  }
9281
9310
  const { textMode, setTextModeState, sidebarTab, setSidebarTab } = ctx;
9282
- const { localParticipant } = useLocalParticipant11();
9311
+ const { localParticipant } = useLocalParticipant12();
9283
9312
  const confirmedTextModeRef = useRef29(false);
9284
9313
  const toggleTextMode = useCallback25(async () => {
9285
9314
  const next = !textMode;
@@ -9288,7 +9317,7 @@ function useTextMode() {
9288
9317
  setSidebarTab("chat");
9289
9318
  }
9290
9319
  try {
9291
- await localParticipant.publishData(textEncoder6.encode(JSON.stringify({ textMode: next })), {
9320
+ await localParticipant.publishData(textEncoder7.encode(JSON.stringify({ textMode: next })), {
9292
9321
  reliable: true,
9293
9322
  topic: TEXT_MODE_TOPIC
9294
9323
  });
@@ -11470,7 +11499,7 @@ function useBarNotifications() {
11470
11499
  }
11471
11500
 
11472
11501
  // src/components/VoiceBarFrame.tsx
11473
- import { useIsSpeaking, useLocalParticipant as useLocalParticipant12 } from "@livekit/components-react/hooks";
11502
+ import { useIsSpeaking, useLocalParticipant as useLocalParticipant13 } from "@livekit/components-react/hooks";
11474
11503
  import { useCallback as useCallback34, useContext as useContext26, useEffect as useEffect47, useRef as useRef42, useState as useState38 } from "react";
11475
11504
 
11476
11505
  // src/hooks/useKeyboardStop.ts
@@ -12221,7 +12250,7 @@ var MIC_LEVEL_IDLE_PX = 3;
12221
12250
  var MIC_LEVEL_GROWTH_PX = 8;
12222
12251
  var MIC_LEVEL_NOISE_GATE = 0.15;
12223
12252
  function MicLevelGlyph({ muted }) {
12224
- const { microphoneTrack } = useLocalParticipant12();
12253
+ const { microphoneTrack } = useLocalParticipant13();
12225
12254
  const { barRefs, isTalking } = useAudioLevelBars(muted ? undefined : microphoneTrack?.track?.mediaStreamTrack, {
12226
12255
  barCount: MIC_LEVEL_BARS,
12227
12256
  idleHeightPx: MIC_LEVEL_IDLE_PX,
@@ -12407,7 +12436,7 @@ function VoiceBarFrame({
12407
12436
  const dropAtBarWidth = useCallback34((next) => onDrop(next, barWidthRef.current), [onDrop]);
12408
12437
  const { wasDraggedRef } = useVoiceBarDrag(containerRef, dropAtBarWidth, dragFollowers, setDragging);
12409
12438
  const { isMuted, toggleMute } = useMediaControls();
12410
- const { localParticipant } = useLocalParticipant12();
12439
+ const { localParticipant } = useLocalParticipant13();
12411
12440
  const isUserSpeaking = useIsSpeaking(localParticipant);
12412
12441
  const { state } = useAgentVoiceState();
12413
12442
  const { isCapturingSpeech, toggle: toggleTapToTalk, start, commit } = useVoiceTurnContext();
@@ -14287,9 +14316,9 @@ function SplashScreenCard({
14287
14316
  });
14288
14317
  }
14289
14318
  // src/hooks/useIsLocalSpeaking.ts
14290
- import { useIsSpeaking as useIsSpeaking2, useLocalParticipant as useLocalParticipant13 } from "@livekit/components-react/hooks";
14319
+ import { useIsSpeaking as useIsSpeaking2, useLocalParticipant as useLocalParticipant14 } from "@livekit/components-react/hooks";
14291
14320
  function useIsLocalSpeaking() {
14292
- const { localParticipant } = useLocalParticipant13();
14321
+ const { localParticipant } = useLocalParticipant14();
14293
14322
  return useIsSpeaking2(localParticipant);
14294
14323
  }
14295
14324
  // src/hooks/useIsSessionHeld.ts