@skippr/live-agent-sdk 0.35.0 → 0.37.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/README.md +26 -7
- package/dist/esm/lib-exports.js +314 -230
- package/dist/skippr-sdk.js +147 -147
- package/dist/types/components/LiveAgent.d.ts +1 -0
- package/dist/types/context/LiveAgentContext.d.ts +14 -3
- package/dist/types/hooks/useAuth.d.ts +1 -1
- package/dist/types/hooks/useAvailableModules.d.ts +3 -1
- package/dist/types/hooks/useSession.d.ts +8 -13
- package/dist/types/lib/session.d.ts +4 -0
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ interface LiveAgentBaseProps {
|
|
|
4
4
|
agentId?: string | undefined;
|
|
5
5
|
authToken?: string | undefined;
|
|
6
6
|
appKey?: string | undefined;
|
|
7
|
+
getUserToken?: (() => Promise<string>) | undefined;
|
|
7
8
|
userToken?: string | undefined;
|
|
8
9
|
position?: 'left' | 'right' | undefined;
|
|
9
10
|
variant?: 'floating' | 'sidebar' | undefined;
|
|
@@ -4,13 +4,21 @@ export type CaptureMode = 'screenshare' | 'auto';
|
|
|
4
4
|
export interface AgentControls {
|
|
5
5
|
highlight?: boolean;
|
|
6
6
|
}
|
|
7
|
+
export type SessionStatus = 'pending' | 'active' | 'paused' | 'completed' | 'expired';
|
|
8
|
+
export type AgentMode = 'standard' | 'always_on';
|
|
9
|
+
export interface ModuleCurrentSession {
|
|
10
|
+
id: string;
|
|
11
|
+
status: SessionStatus;
|
|
12
|
+
}
|
|
7
13
|
export interface Module {
|
|
8
14
|
id: string;
|
|
9
15
|
name: string;
|
|
10
16
|
description: string | null;
|
|
11
17
|
type: string;
|
|
18
|
+
mode: AgentMode;
|
|
12
19
|
priority: number;
|
|
13
20
|
controls: AgentControls;
|
|
21
|
+
currentSession: ModuleCurrentSession | null;
|
|
14
22
|
}
|
|
15
23
|
export interface ResumableSession {
|
|
16
24
|
id: string;
|
|
@@ -24,16 +32,17 @@ export interface LiveAgentPublicValue {
|
|
|
24
32
|
error: string;
|
|
25
33
|
errorCode: number | null;
|
|
26
34
|
agentId: string | null;
|
|
35
|
+
agentMode: AgentMode | null;
|
|
27
36
|
startSession: (opts: {
|
|
28
37
|
agentId: string;
|
|
29
|
-
agentControls?: AgentControls;
|
|
38
|
+
agentControls?: AgentControls | undefined;
|
|
39
|
+
existingSessionId?: string | undefined;
|
|
30
40
|
}) => Promise<void>;
|
|
31
41
|
pauseSession: () => Promise<void>;
|
|
32
42
|
resumeSession: () => Promise<void>;
|
|
33
43
|
disconnect: () => Promise<void>;
|
|
34
44
|
isPaused: boolean;
|
|
35
45
|
resumableSession: ResumableSession | null;
|
|
36
|
-
resumableSessions: ResumableSession[];
|
|
37
46
|
isPanelOpen: boolean;
|
|
38
47
|
openPanel: () => void;
|
|
39
48
|
closePanel: () => void;
|
|
@@ -50,7 +59,7 @@ export interface LiveAgentPublicValue {
|
|
|
50
59
|
authError: string;
|
|
51
60
|
requestOtp: (email: string) => Promise<boolean>;
|
|
52
61
|
verifyOtp: (email: string, code: string) => Promise<void>;
|
|
53
|
-
logoutAuth: () => void
|
|
62
|
+
logoutAuth: () => Promise<void>;
|
|
54
63
|
isAuthSubmitting: boolean;
|
|
55
64
|
sidebarTab: SidebarTab;
|
|
56
65
|
setSidebarTab: (tab: SidebarTab) => void;
|
|
@@ -66,6 +75,8 @@ export interface LiveAgentPublicValue {
|
|
|
66
75
|
selectModule: (id: string) => void;
|
|
67
76
|
}
|
|
68
77
|
export interface LiveAgentContextValue extends LiveAgentPublicValue {
|
|
78
|
+
usesHostAuth: boolean;
|
|
79
|
+
authFailed: boolean;
|
|
69
80
|
connection: {
|
|
70
81
|
livekitUrl: string;
|
|
71
82
|
token: string;
|
|
@@ -7,7 +7,7 @@ export declare function useAuth({ appKey }: UseAuthParams): {
|
|
|
7
7
|
authToken: string | null;
|
|
8
8
|
requestOtp: (email: string) => Promise<boolean>;
|
|
9
9
|
verifyOtp: (email: string, code: string) => Promise<void>;
|
|
10
|
-
logout: () => void
|
|
10
|
+
logout: () => Promise<void>;
|
|
11
11
|
error: string;
|
|
12
12
|
isSubmitting: boolean;
|
|
13
13
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Module } from '../context/LiveAgentContext';
|
|
2
|
+
import type { AuthedFetch } from './useSession';
|
|
2
3
|
interface UseAvailableModulesParams {
|
|
3
4
|
enabled: boolean;
|
|
4
5
|
bearerToken: string | null;
|
|
6
|
+
authedFetch: AuthedFetch;
|
|
5
7
|
}
|
|
6
8
|
interface UseAvailableModulesResult {
|
|
7
9
|
modules: Module[];
|
|
@@ -9,5 +11,5 @@ interface UseAvailableModulesResult {
|
|
|
9
11
|
error: string | null;
|
|
10
12
|
refetch: () => Promise<void>;
|
|
11
13
|
}
|
|
12
|
-
export declare function useAvailableModules({ enabled, bearerToken, }: UseAvailableModulesParams): UseAvailableModulesResult;
|
|
14
|
+
export declare function useAvailableModules({ enabled, bearerToken, authedFetch, }: UseAvailableModulesParams): UseAvailableModulesResult;
|
|
13
15
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AgentControls, CaptureMode } from '../context/LiveAgentContext';
|
|
2
2
|
import type { Message } from '../types';
|
|
3
|
+
export type AuthedFetch = (input: string, init?: RequestInit) => Promise<Response>;
|
|
3
4
|
interface LiveKitConnection {
|
|
4
5
|
livekitUrl: string;
|
|
5
6
|
token: string;
|
|
@@ -8,6 +9,7 @@ interface UseSessionParams {
|
|
|
8
9
|
captureMode?: CaptureMode | undefined;
|
|
9
10
|
authToken?: string | undefined;
|
|
10
11
|
appKey?: string | undefined;
|
|
12
|
+
getUserToken?: (() => Promise<string>) | undefined;
|
|
11
13
|
userToken?: string | undefined;
|
|
12
14
|
onStart?: () => void;
|
|
13
15
|
onStartError?: () => void;
|
|
@@ -15,32 +17,25 @@ interface UseSessionParams {
|
|
|
15
17
|
}
|
|
16
18
|
export interface StartSessionOptions {
|
|
17
19
|
agentId: string;
|
|
18
|
-
agentControls?: AgentControls;
|
|
20
|
+
agentControls?: AgentControls | undefined;
|
|
21
|
+
existingSessionId?: string | undefined;
|
|
19
22
|
}
|
|
20
|
-
export
|
|
21
|
-
id: string;
|
|
22
|
-
agentId: string;
|
|
23
|
-
}
|
|
24
|
-
export declare function useSession({ captureMode, authToken, appKey, userToken, onStart, onStartError, onDisconnect, }: UseSessionParams): {
|
|
23
|
+
export declare function useSession({ captureMode, authToken, appKey, getUserToken, userToken, onStart, onStartError, onDisconnect, }: UseSessionParams): {
|
|
25
24
|
connection: LiveKitConnection | null;
|
|
26
25
|
shouldConnect: boolean;
|
|
27
26
|
isStarting: boolean;
|
|
28
27
|
isDisconnecting: boolean;
|
|
29
28
|
error: string;
|
|
30
29
|
errorCode: number | null;
|
|
31
|
-
startSession: ({ agentId, agentControls }: StartSessionOptions) => Promise<void>;
|
|
30
|
+
startSession: ({ agentId, agentControls, existingSessionId }: StartSessionOptions) => Promise<void>;
|
|
32
31
|
pauseSession: () => Promise<void>;
|
|
33
|
-
resumeSession: ({ sessionId: resumeId, agentControls, }: {
|
|
34
|
-
sessionId: string;
|
|
35
|
-
agentControls?: AgentControls | undefined;
|
|
36
|
-
}) => Promise<void>;
|
|
37
32
|
disconnect: () => Promise<void>;
|
|
38
33
|
isPaused: boolean;
|
|
39
34
|
isPausing: boolean;
|
|
40
|
-
resumableSessions: ResumableSession[];
|
|
41
35
|
historyMessages: Message[];
|
|
42
|
-
refetchResumable: () => Promise<void>;
|
|
43
36
|
pendingScreenStream: MediaStream | null;
|
|
44
37
|
bearerToken: string | null;
|
|
38
|
+
authedFetch: AuthedFetch;
|
|
39
|
+
authFailed: boolean;
|
|
45
40
|
};
|
|
46
41
|
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AgentMode, Module, ModuleCurrentSession, ResumableSession } from '../context/LiveAgentContext';
|
|
2
|
+
export declare function getResumableSessionId(currentSession: ModuleCurrentSession | null | undefined, mode: AgentMode | null): string | undefined;
|
|
3
|
+
export declare function canResumeSession(currentSession: ModuleCurrentSession | null | undefined, mode: AgentMode | null): boolean;
|
|
4
|
+
export declare function getResumableSession(module: Module | null | undefined): ResumableSession | null;
|