bridgeapp-ai-chat-widget 0.1.2 → 0.1.3
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/App.d.ts +12 -0
- package/dist/api/api.types.d.ts +54 -0
- package/dist/api/messages.api.d.ts +7 -0
- package/dist/api/notifySessionConflictOn409.d.ts +2 -0
- package/dist/api/voice.api.d.ts +90 -0
- package/dist/avatar/AnimationManager.d.ts +43 -0
- package/dist/avatar/Avatar.d.ts +60 -0
- package/dist/avatar/BlendShapeScenario.d.ts +19 -0
- package/dist/bridge-ai-chat-widget.es.js +277 -274
- package/dist/bridge-ai-chat-widget.umd.js +19 -19
- package/dist/domain/audio-devices/audio-devices.types.d.ts +30 -0
- package/dist/domain/audio-devices/audio-devices.utils.d.ts +5 -0
- package/dist/domain/audio-devices/index.d.ts +2 -0
- package/dist/domain/message/cable/AnyCable.service.d.ts +33 -0
- package/dist/domain/message/cable/CableContext.d.ts +15 -0
- package/dist/domain/message/cable/CableContext.types.d.ts +19 -0
- package/dist/domain/message/cable/WidgetChat.channel.d.ts +4 -0
- package/dist/domain/message/message.store.d.ts +33 -0
- package/dist/domain/ui/ui.service.d.ts +7 -0
- package/dist/domain/voice/voice.store.d.ts +36 -0
- package/dist/hooks/useDeviceManager.d.ts +28 -0
- package/dist/hooks/useSessionExpiryChecks.d.ts +3 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.types.d.ts +3 -0
- package/dist/lib/agentContentRenderer.d.ts +6 -0
- package/dist/lib/isSessionExpired.d.ts +2 -0
- package/dist/lib/logger.d.ts +12 -0
- package/dist/lib/retrieveContent.d.ts +6 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/react/mount.d.ts +5 -0
- package/dist/ui/chat-routes.d.ts +11 -0
- package/dist/ui/components/ChatFooter.d.ts +2 -0
- package/dist/ui/components/ChatListItem.d.ts +11 -0
- package/dist/ui/components/ChatListPage.d.ts +1 -0
- package/dist/ui/components/ChatMessage.d.ts +8 -0
- package/dist/ui/components/ChatTextMode.d.ts +1 -0
- package/dist/ui/components/ChatTopControls.d.ts +1 -0
- package/dist/ui/components/ChatTypingIndicator.d.ts +4 -0
- package/dist/ui/components/ChatUnreadIndicator.d.ts +1 -0
- package/dist/ui/components/ChatVoiceMode.d.ts +1 -0
- package/dist/ui/components/ChatWidget.d.ts +29 -0
- package/dist/ui/components/ErrorMessage.d.ts +7 -0
- package/dist/ui/components/VoiceMessage.d.ts +9 -0
- package/dist/ui/components/overlays/ChatBlurOverlayBottom.d.ts +1 -0
- package/dist/ui/components/overlays/ChatBlurOverlayTop.d.ts +1 -0
- package/dist/ui/components/overlays/ChatDarkOverlay.d.ts +1 -0
- package/dist/ui/error-messages.d.ts +6 -0
- package/package.json +1 -1
package/dist/App.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { WidgetConfig } from "./index.types";
|
|
2
|
+
import { type OnAvatarReadyCB } from "./react/mount";
|
|
3
|
+
export type AppApi = {
|
|
4
|
+
onAvatarReady: OnAvatarReadyCB;
|
|
5
|
+
onSessionExpired: () => void;
|
|
6
|
+
};
|
|
7
|
+
type AppProps = {
|
|
8
|
+
config: WidgetConfig;
|
|
9
|
+
api: AppApi;
|
|
10
|
+
};
|
|
11
|
+
export declare function App({ config, api }: AppProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default App;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type JSONContent } from "@tiptap/core";
|
|
2
|
+
export declare enum ParticipantType {
|
|
3
|
+
Customer = "PARTICIPANT_TYPE_CUSTOMER",
|
|
4
|
+
Agent = "PARTICIPANT_TYPE_AGENT"
|
|
5
|
+
}
|
|
6
|
+
export type ChatParticipant = {
|
|
7
|
+
id: string;
|
|
8
|
+
type: ParticipantType;
|
|
9
|
+
};
|
|
10
|
+
export declare enum MessageStatus {
|
|
11
|
+
Completed = "MESSAGE_STATUS_COMPLETED",
|
|
12
|
+
Writing = "MESSAGE_STATUS_WRITING",
|
|
13
|
+
Failed = "MESSAGE_STATUS_FAILED"
|
|
14
|
+
}
|
|
15
|
+
export type CustomerContent = {
|
|
16
|
+
text: string;
|
|
17
|
+
type: string;
|
|
18
|
+
};
|
|
19
|
+
export type AgentContent = JSONContent;
|
|
20
|
+
export type MessageContent = CustomerContent | AgentContent;
|
|
21
|
+
type AgenticStep = {
|
|
22
|
+
durationSeconds: number;
|
|
23
|
+
text: JSONContent;
|
|
24
|
+
};
|
|
25
|
+
export type MessageData = {
|
|
26
|
+
id: string;
|
|
27
|
+
companyId: string;
|
|
28
|
+
chatId: string;
|
|
29
|
+
author: ChatParticipant;
|
|
30
|
+
status: MessageStatus;
|
|
31
|
+
agenticSteps: AgenticStep[];
|
|
32
|
+
content: MessageContent;
|
|
33
|
+
data: {};
|
|
34
|
+
threadId?: string;
|
|
35
|
+
threadMessagesCount: number;
|
|
36
|
+
inReplyToMessageId: string | null;
|
|
37
|
+
lastThreadMessageAt: string;
|
|
38
|
+
createdAt: string;
|
|
39
|
+
updatedAt: string;
|
|
40
|
+
attachments: [];
|
|
41
|
+
threadParticipants: ChatParticipant[];
|
|
42
|
+
mentions: [];
|
|
43
|
+
reactions: [];
|
|
44
|
+
isPinned: boolean;
|
|
45
|
+
forwardCount: number;
|
|
46
|
+
};
|
|
47
|
+
export type AgenticStepsAppendedData = {
|
|
48
|
+
chatId: string;
|
|
49
|
+
messageId: string;
|
|
50
|
+
companyId: string;
|
|
51
|
+
threadId: string;
|
|
52
|
+
agenticSteps: AgenticStep[];
|
|
53
|
+
};
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MessageData } from "./api.types";
|
|
2
|
+
import type { WidgetConfig } from "@/index.types";
|
|
3
|
+
import type { AppApi } from "@/App";
|
|
4
|
+
export declare const MAX_FETCH_MESSAGES = 100;
|
|
5
|
+
export declare const listMessages: (config: WidgetConfig, api: AppApi, afterMessageId?: string) => Promise<MessageData[]>;
|
|
6
|
+
export declare function listMessagesForThreads(config: WidgetConfig, api: AppApi, threadIds: string[]): Promise<MessageData[]>;
|
|
7
|
+
export declare function sendMessage(config: WidgetConfig, api: AppApi, messageText: string, threadId?: string): Promise<MessageData>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { ChatParticipant } from "./api.types";
|
|
2
|
+
import type { WidgetConfig } from "@/index.types";
|
|
3
|
+
import type { AppApi } from "@/App";
|
|
4
|
+
type StartVoiceSessionResponse = {
|
|
5
|
+
status: number;
|
|
6
|
+
json: VoiceSessionData | ApiErrorResponse;
|
|
7
|
+
};
|
|
8
|
+
export type ApiErrorResponse = {
|
|
9
|
+
code: string;
|
|
10
|
+
message: string;
|
|
11
|
+
};
|
|
12
|
+
export type VoiceSessionData = {
|
|
13
|
+
session: {
|
|
14
|
+
id: string;
|
|
15
|
+
companyId: string;
|
|
16
|
+
agentId: string;
|
|
17
|
+
chatId: string;
|
|
18
|
+
participant: ChatParticipant;
|
|
19
|
+
};
|
|
20
|
+
sessionToken: string;
|
|
21
|
+
voiceProtocolVersion: number;
|
|
22
|
+
voiceBaseUrl: string;
|
|
23
|
+
voiceTurn: {
|
|
24
|
+
urls: string[];
|
|
25
|
+
username: string;
|
|
26
|
+
useSessionTokenCredential: boolean;
|
|
27
|
+
realm: string;
|
|
28
|
+
credentialExpiresAt: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare const startVoiceSession: (config: WidgetConfig, api: AppApi) => Promise<StartVoiceSessionResponse>;
|
|
32
|
+
export declare function getVoiceSession(config: WidgetConfig, api: AppApi, id: string): Promise<VoiceSessionData>;
|
|
33
|
+
type VoiceSessionStatus = "VOICE_SESSION_STATUS_ENDED" | "VOICE_SESSION_STATUS_ACTIVE";
|
|
34
|
+
type VoiceConfig = {
|
|
35
|
+
voice: string;
|
|
36
|
+
};
|
|
37
|
+
type EndVoiceSessionResponse = {
|
|
38
|
+
agentId: string;
|
|
39
|
+
chatId: string;
|
|
40
|
+
companyId: string;
|
|
41
|
+
createdAt: string;
|
|
42
|
+
endedAt: string;
|
|
43
|
+
id: string;
|
|
44
|
+
modelId: string;
|
|
45
|
+
participant: ChatParticipant;
|
|
46
|
+
signalingUrl: string;
|
|
47
|
+
status: VoiceSessionStatus;
|
|
48
|
+
tokenExpiresAt: string;
|
|
49
|
+
updatedAt: string;
|
|
50
|
+
voiceConfig: VoiceConfig;
|
|
51
|
+
};
|
|
52
|
+
export declare function endVoiceSession(config: WidgetConfig, api: AppApi, id: string, reason?: string): Promise<EndVoiceSessionResponse>;
|
|
53
|
+
type SendOfferPayload = {
|
|
54
|
+
voiceBaseUrl: string;
|
|
55
|
+
voiceSessionId: string;
|
|
56
|
+
sessionToken: string;
|
|
57
|
+
clientInstanceId: string;
|
|
58
|
+
protocolVersion: number;
|
|
59
|
+
expectedConnectionGeneration: number;
|
|
60
|
+
offerSdp: string;
|
|
61
|
+
};
|
|
62
|
+
type SendOfferResponse = {
|
|
63
|
+
answerSdp: string;
|
|
64
|
+
protocolVersion: number;
|
|
65
|
+
voiceSessionId: string;
|
|
66
|
+
connectionId: string;
|
|
67
|
+
connectionGeneration: number;
|
|
68
|
+
};
|
|
69
|
+
export declare function sendOffer({ voiceBaseUrl, voiceSessionId, sessionToken, clientInstanceId, protocolVersion, expectedConnectionGeneration, offerSdp, }: SendOfferPayload): Promise<SendOfferResponse>;
|
|
70
|
+
type SendCandidatesPayload = {
|
|
71
|
+
voiceBaseUrl: string;
|
|
72
|
+
voiceSessionId: string;
|
|
73
|
+
sessionToken: string;
|
|
74
|
+
clientInstanceId: string;
|
|
75
|
+
connectionId: string;
|
|
76
|
+
connectionGeneration: number;
|
|
77
|
+
candidates: RTCIceCandidateInit[];
|
|
78
|
+
};
|
|
79
|
+
export declare function sendCandidates({ voiceBaseUrl, voiceSessionId, sessionToken, clientInstanceId, connectionId, connectionGeneration, candidates, }: SendCandidatesPayload): Promise<void>;
|
|
80
|
+
type EndWebRtcSessionPayload = {
|
|
81
|
+
voiceBaseUrl: string;
|
|
82
|
+
voiceSessionId: string;
|
|
83
|
+
sessionToken: string;
|
|
84
|
+
clientInstanceId: string;
|
|
85
|
+
connectionId: string;
|
|
86
|
+
connectionGeneration: number;
|
|
87
|
+
reason?: string;
|
|
88
|
+
};
|
|
89
|
+
export declare function endWebRtcSession({ voiceBaseUrl, voiceSessionId, sessionToken, clientInstanceId, connectionId, connectionGeneration, reason, }: EndWebRtcSessionPayload): Promise<void>;
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Object3D, type Mesh } from "three";
|
|
2
|
+
import type { VisemeData } from "./Avatar";
|
|
3
|
+
import { FBXLoader } from "three/examples/jsm/Addons.js";
|
|
4
|
+
import { Avatar } from "./Avatar";
|
|
5
|
+
export declare const BLEND_SHAPE_KEYS: readonly ["blendShape1.AE", "blendShape1.ChJ", "blendShape1.FV", "blendShape1.Oh", "blendShape1.Ah", "blendShape1.Ih", "blendShape1.L", "blendShape1.SZ", "blendShape1.Woo", "blendShape1.MBP", "blendShape1.Smile_Closed", "blendShape1.Smile_Open", "blendShape1.Kiss"];
|
|
6
|
+
export type BlendShapeKey = (typeof BLEND_SHAPE_KEYS)[number];
|
|
7
|
+
export default class AnimationManager {
|
|
8
|
+
private model;
|
|
9
|
+
private head;
|
|
10
|
+
private initialAssetsfbxLoader;
|
|
11
|
+
private assetsUrl;
|
|
12
|
+
private avatar;
|
|
13
|
+
private animations;
|
|
14
|
+
private zeroMorphingInfluences;
|
|
15
|
+
private visemeDataIndex;
|
|
16
|
+
private visemeData;
|
|
17
|
+
private mixer;
|
|
18
|
+
private activeActionName;
|
|
19
|
+
private actions;
|
|
20
|
+
private loadingManager;
|
|
21
|
+
private fbxLoader;
|
|
22
|
+
private totalAnimations;
|
|
23
|
+
private loadedAnimations;
|
|
24
|
+
constructor(model: Object3D, head: Mesh, initialAssetsfbxLoader: FBXLoader, assetsUrl: string, avatar: Avatar);
|
|
25
|
+
init(): Promise<void>;
|
|
26
|
+
private resolveAsset;
|
|
27
|
+
private loadAnimationMandatoryInitial;
|
|
28
|
+
private loadAnimationLazy;
|
|
29
|
+
private onLoadAnimation;
|
|
30
|
+
private fadeDuration;
|
|
31
|
+
fadeToAction(name: string): void;
|
|
32
|
+
reset(): void;
|
|
33
|
+
setVisemeData(): void;
|
|
34
|
+
convertVisemeDataToAnimationScenario(): void;
|
|
35
|
+
update(delta: number, timePassed?: number): void;
|
|
36
|
+
resetMorphing(): void;
|
|
37
|
+
private blendShapeAnimationLength;
|
|
38
|
+
private blendShapeResetAnimationLength;
|
|
39
|
+
playVisemeAnimation(timePassed: number, visemeNext: VisemeData, visemeAfterNext: VisemeData): void;
|
|
40
|
+
private shapeFadeInDuration;
|
|
41
|
+
private shapeFadeOutDuration;
|
|
42
|
+
showcaseBlendShape(dictionaryKey: string): void;
|
|
43
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Vector3 } from "three";
|
|
2
|
+
import type { WidgetConfig } from "@/index.types";
|
|
3
|
+
import type { OnAvatarReadyCB } from "@/react/mount";
|
|
4
|
+
export interface VisemeData {
|
|
5
|
+
viseme: Viseme;
|
|
6
|
+
time: number;
|
|
7
|
+
}
|
|
8
|
+
export type Viseme = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "X";
|
|
9
|
+
type CameraParams = {
|
|
10
|
+
position: Vector3;
|
|
11
|
+
lookAt: Vector3;
|
|
12
|
+
fov: number;
|
|
13
|
+
};
|
|
14
|
+
export type ExternallyAvailableActions = 'excited' | 'fix_hair' | 'spin' | 'kiss';
|
|
15
|
+
export declare class Avatar extends EventTarget {
|
|
16
|
+
private canvas;
|
|
17
|
+
private videoContainer;
|
|
18
|
+
private config;
|
|
19
|
+
private onAvatarReady;
|
|
20
|
+
private renderer;
|
|
21
|
+
private sound;
|
|
22
|
+
private gui?;
|
|
23
|
+
private cubeTexture;
|
|
24
|
+
private initialAssetsfbxLoader;
|
|
25
|
+
private textureLoader;
|
|
26
|
+
private clock;
|
|
27
|
+
private scene;
|
|
28
|
+
private camera;
|
|
29
|
+
private hair;
|
|
30
|
+
private head;
|
|
31
|
+
private body;
|
|
32
|
+
private animationManager;
|
|
33
|
+
private cameraParams;
|
|
34
|
+
private controls?;
|
|
35
|
+
constructor(canvas: HTMLCanvasElement, videoContainer: HTMLDivElement, config: WidgetConfig, onAvatarReady: OnAvatarReadyCB);
|
|
36
|
+
private get baseUrl();
|
|
37
|
+
private resolveAsset;
|
|
38
|
+
private lightAmbient;
|
|
39
|
+
private lightDirectional;
|
|
40
|
+
private loadingManager;
|
|
41
|
+
init(): Promise<void>;
|
|
42
|
+
private tempLookAt;
|
|
43
|
+
setCamera(params: CameraParams, cb?: () => void): void;
|
|
44
|
+
private width;
|
|
45
|
+
private height;
|
|
46
|
+
onResize: (width?: number, height?: number) => void;
|
|
47
|
+
animate: () => void;
|
|
48
|
+
private speakingAnimationName;
|
|
49
|
+
private idleAnimationName;
|
|
50
|
+
setTalking(talking: boolean): void;
|
|
51
|
+
externalLaunchAnimationAction: (name: ExternallyAvailableActions) => void;
|
|
52
|
+
private playAction;
|
|
53
|
+
playVideo: (id: string, speak?: boolean) => Promise<unknown>;
|
|
54
|
+
shutDownVideo: () => void;
|
|
55
|
+
showcaseBlendShape(shapeName: string): void;
|
|
56
|
+
render(): void;
|
|
57
|
+
onAllAssetsLoaded: () => void;
|
|
58
|
+
private addGui;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Mesh } from "three";
|
|
2
|
+
type BlendShapeAnimationData = {
|
|
3
|
+
timeStart: number;
|
|
4
|
+
timeFinish: number;
|
|
5
|
+
target: number;
|
|
6
|
+
};
|
|
7
|
+
type BlendShapeScenarioData = {
|
|
8
|
+
[blendShapeName: string]: BlendShapeAnimationData[];
|
|
9
|
+
};
|
|
10
|
+
export declare class BlendShapeScenario {
|
|
11
|
+
private head;
|
|
12
|
+
private timeline;
|
|
13
|
+
private morphingInfluences;
|
|
14
|
+
constructor(data: BlendShapeScenarioData, head: Mesh, loop?: boolean);
|
|
15
|
+
play(): void;
|
|
16
|
+
pause(): void;
|
|
17
|
+
stop(): void;
|
|
18
|
+
}
|
|
19
|
+
export {};
|