@skippr/live-agent-sdk 0.113.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.
package/dist/esm/lib-exports.js
CHANGED
|
@@ -7177,9 +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 =
|
|
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;
|
|
7183
7189
|
var textDecoder = new TextDecoder;
|
|
7184
7190
|
function parseHighlightMessage(payload) {
|
|
7185
7191
|
try {
|
|
@@ -7201,16 +7207,28 @@ function parseHighlightMessage(payload) {
|
|
|
7201
7207
|
}
|
|
7202
7208
|
}
|
|
7203
7209
|
function HighlightOverlay() {
|
|
7210
|
+
const { localParticipant } = useLocalParticipant6();
|
|
7204
7211
|
const targetRef = useRef19(null);
|
|
7212
|
+
const shownRef = useRef19(null);
|
|
7213
|
+
const shownUrlRef = useRef19(null);
|
|
7205
7214
|
const autoClearRef = useRef19(null);
|
|
7206
7215
|
const clear = useCallback18(() => {
|
|
7207
7216
|
if (autoClearRef.current)
|
|
7208
7217
|
clearTimeout(autoClearRef.current);
|
|
7209
7218
|
autoClearRef.current = null;
|
|
7210
7219
|
targetRef.current = null;
|
|
7220
|
+
shownRef.current = null;
|
|
7221
|
+
shownUrlRef.current = null;
|
|
7211
7222
|
clearCursorTarget("guide");
|
|
7212
7223
|
setHighlightActive(false);
|
|
7213
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]);
|
|
7214
7232
|
const onHighlightMessage = useCallback18((msg) => {
|
|
7215
7233
|
const parsed = parseHighlightMessage(msg.payload);
|
|
7216
7234
|
if (!parsed)
|
|
@@ -7221,32 +7239,67 @@ function HighlightOverlay() {
|
|
|
7221
7239
|
}
|
|
7222
7240
|
const element = findElementByRef(parsed.ref);
|
|
7223
7241
|
if (!element) {
|
|
7224
|
-
|
|
7242
|
+
clearAndReport(ELEMENT_GONE_REASON);
|
|
7225
7243
|
return;
|
|
7226
7244
|
}
|
|
7227
7245
|
if (autoClearRef.current)
|
|
7228
7246
|
clearTimeout(autoClearRef.current);
|
|
7229
7247
|
targetRef.current = element;
|
|
7248
|
+
shownRef.current = parsed;
|
|
7249
|
+
shownUrlRef.current = window.location.href;
|
|
7230
7250
|
setCursorTarget("guide", {
|
|
7231
7251
|
element,
|
|
7232
7252
|
label: parsed.message || "Click here",
|
|
7233
7253
|
mode: "guide"
|
|
7234
7254
|
});
|
|
7235
7255
|
setHighlightActive(true);
|
|
7236
|
-
autoClearRef.current = setTimeout(
|
|
7237
|
-
}, [clear]);
|
|
7256
|
+
autoClearRef.current = setTimeout(() => clearAndReport(EXPIRED_REASON), HIGHLIGHT_AUTO_CLEAR_MS);
|
|
7257
|
+
}, [clear, clearAndReport]);
|
|
7238
7258
|
useDataChannel(HIGHLIGHT_TOPIC, onHighlightMessage);
|
|
7239
7259
|
useEffect25(() => onHighlightCleared(clear), [clear]);
|
|
7240
7260
|
useEffect25(() => {
|
|
7241
7261
|
const onClick = (event) => {
|
|
7242
7262
|
const target = targetRef.current;
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
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);
|
|
7246
7273
|
};
|
|
7247
7274
|
document.addEventListener("click", onClick, { capture: true });
|
|
7248
7275
|
return () => document.removeEventListener("click", onClick, { capture: true });
|
|
7249
|
-
}, [
|
|
7276
|
+
}, [clearAndReport]);
|
|
7277
|
+
useEffect25(() => {
|
|
7278
|
+
const interval = setInterval(() => {
|
|
7279
|
+
const shown = shownRef.current;
|
|
7280
|
+
const target = targetRef.current;
|
|
7281
|
+
if (!shown || !target)
|
|
7282
|
+
return;
|
|
7283
|
+
if (shownUrlRef.current !== window.location.href) {
|
|
7284
|
+
clearAndReport(NAVIGATED_REASON);
|
|
7285
|
+
return;
|
|
7286
|
+
}
|
|
7287
|
+
if (target.isConnected)
|
|
7288
|
+
return;
|
|
7289
|
+
const replacement = findElementByRef(shown.ref);
|
|
7290
|
+
if (!replacement) {
|
|
7291
|
+
clearAndReport(ELEMENT_GONE_REASON);
|
|
7292
|
+
return;
|
|
7293
|
+
}
|
|
7294
|
+
targetRef.current = replacement;
|
|
7295
|
+
setCursorTarget("guide", {
|
|
7296
|
+
element: replacement,
|
|
7297
|
+
label: shown.message || "Click here",
|
|
7298
|
+
mode: "guide"
|
|
7299
|
+
});
|
|
7300
|
+
}, PAGE_CHECK_MS);
|
|
7301
|
+
return () => clearInterval(interval);
|
|
7302
|
+
}, [clearAndReport]);
|
|
7250
7303
|
useEffect25(() => clear, [clear]);
|
|
7251
7304
|
return null;
|
|
7252
7305
|
}
|
|
@@ -8183,11 +8236,11 @@ function PageActionHandler() {
|
|
|
8183
8236
|
import { useCallback as useCallback22, useContext as useContext11, useEffect as useEffect32, useState as useState24 } from "react";
|
|
8184
8237
|
|
|
8185
8238
|
// src/hooks/useActionControl.ts
|
|
8186
|
-
import { useLocalParticipant as
|
|
8239
|
+
import { useLocalParticipant as useLocalParticipant7 } from "@livekit/components-react/hooks";
|
|
8187
8240
|
import { useCallback as useCallback20, useEffect as useEffect29, useState as useState22 } from "react";
|
|
8188
|
-
var
|
|
8241
|
+
var textEncoder6 = new TextEncoder;
|
|
8189
8242
|
function useActionControl() {
|
|
8190
|
-
const { localParticipant } =
|
|
8243
|
+
const { localParticipant } = useLocalParticipant7();
|
|
8191
8244
|
const plan = usePlanUpdates();
|
|
8192
8245
|
const [busy, setBusy] = useState22(isActionsBusy);
|
|
8193
8246
|
useEffect29(() => subscribeActionsBusy(setBusy), []);
|
|
@@ -8195,7 +8248,7 @@ function useActionControl() {
|
|
|
8195
8248
|
const requestStop = useCallback20(async () => {
|
|
8196
8249
|
stopActions();
|
|
8197
8250
|
try {
|
|
8198
|
-
await localParticipant.publishData(
|
|
8251
|
+
await localParticipant.publishData(textEncoder6.encode(JSON.stringify({ type: "abort" })), {
|
|
8199
8252
|
reliable: true,
|
|
8200
8253
|
topic: ACTION_CONTROL_TOPIC
|
|
8201
8254
|
});
|
|
@@ -8300,11 +8353,11 @@ function useIdleAutoPause({
|
|
|
8300
8353
|
}
|
|
8301
8354
|
|
|
8302
8355
|
// src/hooks/useLiveUserTranscript.ts
|
|
8303
|
-
import { useLocalParticipant as
|
|
8356
|
+
import { useLocalParticipant as useLocalParticipant8 } from "@livekit/components-react/hooks";
|
|
8304
8357
|
import { useRef as useRef25 } from "react";
|
|
8305
8358
|
function useLiveUserTranscript(active) {
|
|
8306
8359
|
const transcriptions = useSharedTranscriptions();
|
|
8307
|
-
const { localParticipant } =
|
|
8360
|
+
const { localParticipant } = useLocalParticipant8();
|
|
8308
8361
|
const localIdentity = localParticipant.identity;
|
|
8309
8362
|
const priorStreamIdsRef = useRef25(new Set);
|
|
8310
8363
|
const wasActiveRef = useRef25(false);
|
|
@@ -8319,13 +8372,13 @@ function useLiveUserTranscript(active) {
|
|
|
8319
8372
|
}
|
|
8320
8373
|
|
|
8321
8374
|
// src/hooks/useMicLevel.ts
|
|
8322
|
-
import { useLocalParticipant as
|
|
8375
|
+
import { useLocalParticipant as useLocalParticipant9 } from "@livekit/components-react/hooks";
|
|
8323
8376
|
var MIC_BARS = 5;
|
|
8324
8377
|
var IDLE_BAR_HEIGHT_PX = 5;
|
|
8325
8378
|
var MAX_BAR_GROWTH_PX = 17;
|
|
8326
8379
|
var MIC_NOISE_GATE = 0.15;
|
|
8327
8380
|
function useMicLevel(enabled) {
|
|
8328
|
-
const { microphoneTrack } =
|
|
8381
|
+
const { microphoneTrack } = useLocalParticipant9();
|
|
8329
8382
|
const mediaStreamTrack = microphoneTrack?.track?.mediaStreamTrack;
|
|
8330
8383
|
return useAudioLevelBars(enabled ? mediaStreamTrack : undefined, {
|
|
8331
8384
|
barCount: MIC_BARS,
|
|
@@ -8989,7 +9042,7 @@ import { useCallback as useCallback28, useContext as useContext18, useEffect as
|
|
|
8989
9042
|
import { useContext as useContext12, useMemo as useMemo8 } from "react";
|
|
8990
9043
|
|
|
8991
9044
|
// src/hooks/useChatMessages.ts
|
|
8992
|
-
import { useChat, useLocalParticipant as
|
|
9045
|
+
import { useChat, useLocalParticipant as useLocalParticipant10 } from "@livekit/components-react/hooks";
|
|
8993
9046
|
import { useMemo as useMemo6 } from "react";
|
|
8994
9047
|
|
|
8995
9048
|
// src/lib/filterSystemMessages.ts
|
|
@@ -9001,7 +9054,7 @@ function filterSystemMessages(messages) {
|
|
|
9001
9054
|
// src/hooks/useChatMessages.ts
|
|
9002
9055
|
function useChatMessages() {
|
|
9003
9056
|
const { chatMessages: rawMessages, send, isSending } = useChat();
|
|
9004
|
-
const { localParticipant } =
|
|
9057
|
+
const { localParticipant } = useLocalParticipant10();
|
|
9005
9058
|
const localIdentity = localParticipant.identity;
|
|
9006
9059
|
const chatMessages = useMemo6(() => {
|
|
9007
9060
|
const sortedMessages = rawMessages.map((msg) => ({
|
|
@@ -9017,11 +9070,11 @@ function useChatMessages() {
|
|
|
9017
9070
|
}
|
|
9018
9071
|
|
|
9019
9072
|
// src/hooks/useStreamingTranscript.ts
|
|
9020
|
-
import { useLocalParticipant as
|
|
9073
|
+
import { useLocalParticipant as useLocalParticipant11 } from "@livekit/components-react/hooks";
|
|
9021
9074
|
import { useMemo as useMemo7, useRef as useRef27 } from "react";
|
|
9022
9075
|
function useStreamingTranscript() {
|
|
9023
9076
|
const transcriptions = useSharedTranscriptions();
|
|
9024
|
-
const { localParticipant } =
|
|
9077
|
+
const { localParticipant } = useLocalParticipant11();
|
|
9025
9078
|
const { isCapturingSpeech } = useVoiceTurnContext();
|
|
9026
9079
|
const localIdentity = localParticipant.identity;
|
|
9027
9080
|
const priorUserStreamIdsRef = useRef27(new Set);
|
|
@@ -9246,16 +9299,16 @@ function panelTransformOrigin(popsDown, isLeftAligned) {
|
|
|
9246
9299
|
import { useContext as useContext15 } from "react";
|
|
9247
9300
|
|
|
9248
9301
|
// src/hooks/useTextMode.ts
|
|
9249
|
-
import { useLocalParticipant as
|
|
9302
|
+
import { useLocalParticipant as useLocalParticipant12 } from "@livekit/components-react/hooks";
|
|
9250
9303
|
import { useCallback as useCallback25, useContext as useContext14, useRef as useRef29 } from "react";
|
|
9251
|
-
var
|
|
9304
|
+
var textEncoder7 = new TextEncoder;
|
|
9252
9305
|
function useTextMode() {
|
|
9253
9306
|
const ctx = useContext14(LiveAgentContext);
|
|
9254
9307
|
if (!ctx) {
|
|
9255
9308
|
throw new Error("useTextMode must be used within a <LiveAgent> provider");
|
|
9256
9309
|
}
|
|
9257
9310
|
const { textMode, setTextModeState, sidebarTab, setSidebarTab } = ctx;
|
|
9258
|
-
const { localParticipant } =
|
|
9311
|
+
const { localParticipant } = useLocalParticipant12();
|
|
9259
9312
|
const confirmedTextModeRef = useRef29(false);
|
|
9260
9313
|
const toggleTextMode = useCallback25(async () => {
|
|
9261
9314
|
const next = !textMode;
|
|
@@ -9264,7 +9317,7 @@ function useTextMode() {
|
|
|
9264
9317
|
setSidebarTab("chat");
|
|
9265
9318
|
}
|
|
9266
9319
|
try {
|
|
9267
|
-
await localParticipant.publishData(
|
|
9320
|
+
await localParticipant.publishData(textEncoder7.encode(JSON.stringify({ textMode: next })), {
|
|
9268
9321
|
reliable: true,
|
|
9269
9322
|
topic: TEXT_MODE_TOPIC
|
|
9270
9323
|
});
|
|
@@ -11446,7 +11499,7 @@ function useBarNotifications() {
|
|
|
11446
11499
|
}
|
|
11447
11500
|
|
|
11448
11501
|
// src/components/VoiceBarFrame.tsx
|
|
11449
|
-
import { useIsSpeaking, useLocalParticipant as
|
|
11502
|
+
import { useIsSpeaking, useLocalParticipant as useLocalParticipant13 } from "@livekit/components-react/hooks";
|
|
11450
11503
|
import { useCallback as useCallback34, useContext as useContext26, useEffect as useEffect47, useRef as useRef42, useState as useState38 } from "react";
|
|
11451
11504
|
|
|
11452
11505
|
// src/hooks/useKeyboardStop.ts
|
|
@@ -12197,7 +12250,7 @@ var MIC_LEVEL_IDLE_PX = 3;
|
|
|
12197
12250
|
var MIC_LEVEL_GROWTH_PX = 8;
|
|
12198
12251
|
var MIC_LEVEL_NOISE_GATE = 0.15;
|
|
12199
12252
|
function MicLevelGlyph({ muted }) {
|
|
12200
|
-
const { microphoneTrack } =
|
|
12253
|
+
const { microphoneTrack } = useLocalParticipant13();
|
|
12201
12254
|
const { barRefs, isTalking } = useAudioLevelBars(muted ? undefined : microphoneTrack?.track?.mediaStreamTrack, {
|
|
12202
12255
|
barCount: MIC_LEVEL_BARS,
|
|
12203
12256
|
idleHeightPx: MIC_LEVEL_IDLE_PX,
|
|
@@ -12383,7 +12436,7 @@ function VoiceBarFrame({
|
|
|
12383
12436
|
const dropAtBarWidth = useCallback34((next) => onDrop(next, barWidthRef.current), [onDrop]);
|
|
12384
12437
|
const { wasDraggedRef } = useVoiceBarDrag(containerRef, dropAtBarWidth, dragFollowers, setDragging);
|
|
12385
12438
|
const { isMuted, toggleMute } = useMediaControls();
|
|
12386
|
-
const { localParticipant } =
|
|
12439
|
+
const { localParticipant } = useLocalParticipant13();
|
|
12387
12440
|
const isUserSpeaking = useIsSpeaking(localParticipant);
|
|
12388
12441
|
const { state } = useAgentVoiceState();
|
|
12389
12442
|
const { isCapturingSpeech, toggle: toggleTapToTalk, start, commit } = useVoiceTurnContext();
|
|
@@ -14263,9 +14316,9 @@ function SplashScreenCard({
|
|
|
14263
14316
|
});
|
|
14264
14317
|
}
|
|
14265
14318
|
// src/hooks/useIsLocalSpeaking.ts
|
|
14266
|
-
import { useIsSpeaking as useIsSpeaking2, useLocalParticipant as
|
|
14319
|
+
import { useIsSpeaking as useIsSpeaking2, useLocalParticipant as useLocalParticipant14 } from "@livekit/components-react/hooks";
|
|
14267
14320
|
function useIsLocalSpeaking() {
|
|
14268
|
-
const { localParticipant } =
|
|
14321
|
+
const { localParticipant } = useLocalParticipant14();
|
|
14269
14322
|
return useIsSpeaking2(localParticipant);
|
|
14270
14323
|
}
|
|
14271
14324
|
// src/hooks/useIsSessionHeld.ts
|