@onlive.ai/common-121 0.2.32

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.
Files changed (111) hide show
  1. package/README.md +151 -0
  2. package/package.json +39 -0
  3. package/services/audio.service.cjs +75 -0
  4. package/services/audio.service.d.cts +14 -0
  5. package/services/audio.service.d.ts +14 -0
  6. package/services/audio.service.js +52 -0
  7. package/services/firebase/firebase-api.cjs +108 -0
  8. package/services/firebase/firebase-api.d.cts +54 -0
  9. package/services/firebase/firebase-api.d.ts +54 -0
  10. package/services/firebase/firebase-api.js +105 -0
  11. package/services/firebase/firebase.service.cjs +193 -0
  12. package/services/firebase/firebase.service.d.cts +40 -0
  13. package/services/firebase/firebase.service.d.ts +40 -0
  14. package/services/firebase/firebase.service.js +190 -0
  15. package/services/livekit.service.cjs +353 -0
  16. package/services/livekit.service.d.cts +131 -0
  17. package/services/livekit.service.d.ts +131 -0
  18. package/services/livekit.service.js +329 -0
  19. package/services/request.provider.cjs +48 -0
  20. package/services/request.provider.d.cts +27 -0
  21. package/services/request.provider.d.ts +27 -0
  22. package/services/request.provider.js +22 -0
  23. package/themes/dark.cjs +433 -0
  24. package/themes/dark.d.cts +5 -0
  25. package/themes/dark.d.ts +5 -0
  26. package/themes/dark.js +408 -0
  27. package/themes/light.cjs +433 -0
  28. package/themes/light.d.cts +5 -0
  29. package/themes/light.d.ts +5 -0
  30. package/themes/light.js +408 -0
  31. package/types/tracking-options.cjs +18 -0
  32. package/types/tracking-options.d.cts +27 -0
  33. package/types/tracking-options.d.ts +27 -0
  34. package/types/tracking-options.js +0 -0
  35. package/types/window-context.cjs +18 -0
  36. package/types/window-context.d.cts +8 -0
  37. package/types/window-context.d.ts +8 -0
  38. package/types/window-context.js +0 -0
  39. package/utils/adopt-styles.cjs +66 -0
  40. package/utils/adopt-styles.d.cts +5 -0
  41. package/utils/adopt-styles.d.ts +5 -0
  42. package/utils/adopt-styles.js +41 -0
  43. package/utils/browser-preferences.cjs +67 -0
  44. package/utils/browser-preferences.d.cts +18 -0
  45. package/utils/browser-preferences.d.ts +18 -0
  46. package/utils/browser-preferences.js +42 -0
  47. package/utils/classify-media.cjs +38 -0
  48. package/utils/classify-media.d.cts +9 -0
  49. package/utils/classify-media.d.ts +9 -0
  50. package/utils/classify-media.js +13 -0
  51. package/utils/decorators.cjs +53 -0
  52. package/utils/decorators.d.cts +34 -0
  53. package/utils/decorators.d.ts +34 -0
  54. package/utils/decorators.js +28 -0
  55. package/utils/detected-lang.cjs +47 -0
  56. package/utils/detected-lang.d.cts +10 -0
  57. package/utils/detected-lang.d.ts +10 -0
  58. package/utils/detected-lang.js +22 -0
  59. package/utils/fullscreen.cjs +52 -0
  60. package/utils/fullscreen.d.cts +16 -0
  61. package/utils/fullscreen.d.ts +16 -0
  62. package/utils/fullscreen.js +26 -0
  63. package/utils/insert-script.cjs +55 -0
  64. package/utils/insert-script.d.cts +29 -0
  65. package/utils/insert-script.d.ts +29 -0
  66. package/utils/insert-script.js +30 -0
  67. package/utils/markdown.cjs +103 -0
  68. package/utils/markdown.d.cts +12 -0
  69. package/utils/markdown.d.ts +12 -0
  70. package/utils/markdown.js +68 -0
  71. package/utils/merge.cjs +47 -0
  72. package/utils/merge.d.cts +23 -0
  73. package/utils/merge.d.ts +23 -0
  74. package/utils/merge.js +22 -0
  75. package/utils/multiband-track-volume.cjs +90 -0
  76. package/utils/multiband-track-volume.d.cts +27 -0
  77. package/utils/multiband-track-volume.d.ts +27 -0
  78. package/utils/multiband-track-volume.js +65 -0
  79. package/utils/onlive-url-params.cjs +38 -0
  80. package/utils/onlive-url-params.d.cts +14 -0
  81. package/utils/onlive-url-params.d.ts +14 -0
  82. package/utils/onlive-url-params.js +13 -0
  83. package/utils/pretty-distance.cjs +45 -0
  84. package/utils/pretty-distance.d.cts +46 -0
  85. package/utils/pretty-distance.d.ts +46 -0
  86. package/utils/pretty-distance.js +20 -0
  87. package/utils/random-string.cjs +37 -0
  88. package/utils/random-string.d.cts +9 -0
  89. package/utils/random-string.d.ts +9 -0
  90. package/utils/random-string.js +12 -0
  91. package/utils/resource-type.cjs +50 -0
  92. package/utils/resource-type.d.cts +16 -0
  93. package/utils/resource-type.d.ts +16 -0
  94. package/utils/resource-type.js +24 -0
  95. package/utils/safe-html.cjs +112 -0
  96. package/utils/safe-html.d.cts +12 -0
  97. package/utils/safe-html.d.ts +12 -0
  98. package/utils/safe-html.js +77 -0
  99. package/utils/sanitize.cjs +94 -0
  100. package/utils/sanitize.d.cts +11 -0
  101. package/utils/sanitize.d.ts +11 -0
  102. package/utils/sanitize.js +59 -0
  103. package/utils/spread.cjs +70 -0
  104. package/utils/spread.d.cts +14 -0
  105. package/utils/spread.d.ts +14 -0
  106. package/utils/spread.js +47 -0
  107. package/utils/watch.cjs +54 -0
  108. package/utils/watch.d.cts +28 -0
  109. package/utils/watch.d.ts +28 -0
  110. package/utils/watch.js +29 -0
  111. package/vite-env.d.ts +22 -0
@@ -0,0 +1,353 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
+
22
+ // services/livekit.service.ts
23
+ var livekit_service_exports = {};
24
+ __export(livekit_service_exports, {
25
+ CHAT_TOPIC: () => CHAT_TOPIC,
26
+ LivekitService: () => LivekitService,
27
+ Room: () => Room,
28
+ TRANSCRIPTION_TOPIC: () => TRANSCRIPTION_TOPIC
29
+ });
30
+ module.exports = __toCommonJS(livekit_service_exports);
31
+ var import_components_core = require("@livekit/components-core");
32
+ var import_livekit_client = require("livekit-client");
33
+
34
+ // services/request.provider.ts
35
+ var request = async (input, init) => {
36
+ const response = await fetch(input, init);
37
+ if (!response.ok) {
38
+ const errorData = await response.json().catch(() => ({}));
39
+ throw new Error(
40
+ JSON.stringify({
41
+ status: response.status,
42
+ statusText: response.statusText,
43
+ ...errorData
44
+ })
45
+ );
46
+ }
47
+ return response && response.json();
48
+ };
49
+
50
+ // services/livekit.service.ts
51
+ var Room = class extends import_livekit_client.Room {
52
+ constructor(options) {
53
+ super(options);
54
+ __publicField(this, "id");
55
+ __publicField(this, "groupId");
56
+ __publicField(this, "createdAt");
57
+ __publicField(this, "connectedAt");
58
+ }
59
+ };
60
+ var CHAT_TOPIC = "lk.chat";
61
+ var TRANSCRIPTION_TOPIC = "lk.transcription";
62
+ var LivekitService = class {
63
+ constructor(options) {
64
+ __publicField(this, "listeners", /* @__PURE__ */ new Set());
65
+ __publicField(this, "apiUrl");
66
+ __publicField(this, "version");
67
+ __publicField(this, "organizationId");
68
+ __publicField(this, "channelTopic");
69
+ __publicField(this, "transcriptionTopic");
70
+ __publicField(this, "setupChat");
71
+ __publicField(this, "abortControllers");
72
+ __publicField(this, "authToken", null);
73
+ __publicField(this, "messagePersistence");
74
+ __publicField(this, "room");
75
+ __publicField(this, "processMessage", async (reader, participantInfo) => {
76
+ const id = reader?.info?.id;
77
+ const participant = participantInfo?.identity ? this.room.getParticipantByIdentity(participantInfo.identity) : void 0;
78
+ let message = "";
79
+ for await (const chunk of reader) {
80
+ message += chunk;
81
+ this.emitMessage({
82
+ id,
83
+ timestamp: Date.now(),
84
+ message,
85
+ from: participant
86
+ });
87
+ }
88
+ if (this.messagePersistence === "client") {
89
+ this.persistMessage({
90
+ roomId: this.room.id,
91
+ content: message,
92
+ externalId: reader?.info?.id,
93
+ identity: participant?.identity,
94
+ kind: participant?.kind
95
+ });
96
+ }
97
+ });
98
+ __publicField(this, "emitMessage", (message) => {
99
+ for (const cb of this.listeners) {
100
+ cb([message]);
101
+ }
102
+ });
103
+ if ("room" in options) {
104
+ this.room = options.room;
105
+ } else {
106
+ this.apiUrl = options.apiUrl;
107
+ this.room = this.instanceRoom();
108
+ }
109
+ this.organizationId = options.organizationId;
110
+ this.version = options.version;
111
+ this.channelTopic = options.channelTopic || CHAT_TOPIC;
112
+ this.transcriptionTopic = options.transcriptionTopic || TRANSCRIPTION_TOPIC;
113
+ this.messagePersistence = options.messagePersistence || "disabled";
114
+ this.abortControllers = {
115
+ register: new AbortController(),
116
+ createRoom: new AbortController(),
117
+ closeRoom: new AbortController(),
118
+ evaluateRoom: new AbortController(),
119
+ persistMessage: new AbortController(),
120
+ sendMessageReport: new AbortController(),
121
+ deleteMessageReport: new AbortController(),
122
+ updateMessageReactions: new AbortController()
123
+ };
124
+ }
125
+ initialize() {
126
+ if (this.version === "v1") {
127
+ this.room.registerTextStreamHandler(this.channelTopic, this.processMessage);
128
+ this.room.registerTextStreamHandler(this.transcriptionTopic, this.processMessage);
129
+ } else {
130
+ this.setupChat = (0, import_components_core.setupChat)(this.room);
131
+ }
132
+ }
133
+ async register(externalId, secret, name) {
134
+ const response = await request(`${this.apiUrl}/users/register`, {
135
+ method: "POST",
136
+ body: JSON.stringify({
137
+ externalId,
138
+ secret,
139
+ name
140
+ }),
141
+ headers: {
142
+ "X-Onlive-Organization-Id": this.organizationId,
143
+ "Content-Type": "application/json"
144
+ },
145
+ signal: this.abortControllers.register.signal
146
+ });
147
+ this.authToken = response.token;
148
+ return response;
149
+ }
150
+ async joinRoom(roomId, timezone, language) {
151
+ const response = await request(`${this.apiUrl}/rooms/${roomId}/join`, {
152
+ method: "POST",
153
+ body: JSON.stringify({ timezone, language }),
154
+ headers: {
155
+ Authorization: `Bearer ${this.authToken}`,
156
+ "X-Onlive-Organization-Id": this.organizationId,
157
+ "Content-Type": "application/json"
158
+ },
159
+ signal: this.abortControllers.createRoom.signal
160
+ });
161
+ this.room.connect(response.wsURL, response.token);
162
+ this.initialize();
163
+ return this.room;
164
+ }
165
+ instanceRoom() {
166
+ if (!this.room) {
167
+ this.room = new Room({
168
+ adaptiveStream: true,
169
+ dynacast: true
170
+ });
171
+ }
172
+ return this.room;
173
+ }
174
+ async createRoom(options) {
175
+ this.room = this.instanceRoom();
176
+ const response = await request(`${this.apiUrl}/rooms`, {
177
+ method: "POST",
178
+ body: JSON.stringify(options),
179
+ headers: {
180
+ Authorization: `Bearer ${this.authToken}`,
181
+ "X-Onlive-Organization-Id": this.organizationId,
182
+ "Content-Type": "application/json"
183
+ },
184
+ signal: this.abortControllers.createRoom.signal
185
+ });
186
+ this.room.id = response.id;
187
+ this.room.groupId = response.groupId;
188
+ this.room.createdAt = response.createdAt;
189
+ this.room.connectedAt = (/* @__PURE__ */ new Date()).toISOString();
190
+ this.room.connect(response.wsURL, response.token);
191
+ this.initialize();
192
+ return this.room;
193
+ }
194
+ async evaluateRoom(options) {
195
+ return request(`${this.apiUrl}/rooms/${this.room.id}/evaluate`, {
196
+ method: "POST",
197
+ body: JSON.stringify({
198
+ rating: options.rating,
199
+ comment: options.comment
200
+ }),
201
+ headers: {
202
+ Authorization: `Bearer ${this.authToken}`,
203
+ "X-Onlive-Organization-Id": this.organizationId,
204
+ "Content-Type": "application/json"
205
+ },
206
+ signal: this.abortControllers.evaluateRoom.signal
207
+ });
208
+ }
209
+ async closeRoom() {
210
+ return request(`${this.apiUrl}/rooms/${this.room.id}/close`, {
211
+ method: "POST",
212
+ headers: {
213
+ Authorization: `Bearer ${this.authToken}`,
214
+ "X-Onlive-Organization-Id": this.organizationId,
215
+ "Content-Type": "application/json"
216
+ },
217
+ signal: this.abortControllers.closeRoom.signal
218
+ });
219
+ }
220
+ async disconnect() {
221
+ if (this.room) {
222
+ this.room.removeAllListeners();
223
+ await this.room.disconnect();
224
+ this.closeRoom();
225
+ this.room = null;
226
+ }
227
+ }
228
+ async sendMessage(message) {
229
+ if (this.version === "v1") {
230
+ const textStream = await this.room.localParticipant.sendText(message, {
231
+ topic: this.channelTopic
232
+ });
233
+ this.emitMessage({
234
+ id: textStream.id,
235
+ timestamp: Date.now(),
236
+ message,
237
+ from: this.room.localParticipant
238
+ });
239
+ if (this.messagePersistence === "client") {
240
+ this.persistMessage({
241
+ roomId: this.room.id,
242
+ content: message,
243
+ externalId: textStream.id,
244
+ identity: this.room.localParticipant?.identity,
245
+ kind: this.room.localParticipant?.kind
246
+ });
247
+ }
248
+ } else {
249
+ await this.setupChat.send(message);
250
+ }
251
+ }
252
+ async persistMessage(options) {
253
+ return request(`${this.apiUrl}/messages/create`, {
254
+ method: "POST",
255
+ body: JSON.stringify(options),
256
+ headers: {
257
+ Authorization: `Bearer ${this.authToken}`,
258
+ "X-Onlive-Organization-Id": this.organizationId,
259
+ "Content-Type": "application/json"
260
+ },
261
+ signal: this.abortControllers.persistMessage.signal
262
+ });
263
+ }
264
+ async getMessages(options) {
265
+ const query = new URLSearchParams();
266
+ if (options.with) {
267
+ query.append("with", options.with.join(","));
268
+ }
269
+ const response = await request(
270
+ `${this.apiUrl}/messages/search${query.size ? `?${query.toString()}` : ""}`,
271
+ {
272
+ method: "POST",
273
+ body: JSON.stringify(options),
274
+ headers: {
275
+ Authorization: `Bearer ${this.authToken}`,
276
+ "X-Onlive-Organization-Id": this.organizationId,
277
+ "Content-Type": "application/json"
278
+ },
279
+ signal: this.abortControllers.createRoom.signal
280
+ }
281
+ );
282
+ return response.items;
283
+ }
284
+ async sendMessageReport(options) {
285
+ try {
286
+ return request(`${this.apiUrl}/messages/${options.messageId}/report`, {
287
+ method: "POST",
288
+ headers: {
289
+ Authorization: `Bearer ${this.authToken}`,
290
+ "X-Onlive-Organization-Id": this.organizationId,
291
+ "Content-Type": "application/json"
292
+ },
293
+ signal: this.abortControllers.sendMessageReport.signal
294
+ });
295
+ } catch (error) {
296
+ console.error("Error sending message report:", error);
297
+ }
298
+ }
299
+ async deleteMessageReport(options) {
300
+ try {
301
+ return request(`${this.apiUrl}/messages/${options.messageId}/report`, {
302
+ method: "DELETE",
303
+ headers: {
304
+ Authorization: `Bearer ${this.authToken}`,
305
+ "X-Onlive-Organization-Id": this.organizationId,
306
+ "Content-Type": "application/json"
307
+ },
308
+ signal: this.abortControllers.deleteMessageReport.signal
309
+ });
310
+ } catch (error) {
311
+ console.error("Error deleting message report:", error);
312
+ }
313
+ }
314
+ async updateMessageReactions(options) {
315
+ try {
316
+ return request(`${this.apiUrl}/messages/${options.messageId}/reactions`, {
317
+ method: "PATCH",
318
+ body: JSON.stringify({
319
+ add: options.add || [],
320
+ remove: options.remove || []
321
+ }),
322
+ headers: {
323
+ Authorization: `Bearer ${this.authToken}`,
324
+ "X-Onlive-Organization-Id": this.organizationId,
325
+ "Content-Type": "application/json"
326
+ },
327
+ signal: this.abortControllers.updateMessageReactions.signal
328
+ });
329
+ } catch (error) {
330
+ console.error("Error updating message reactions:", error);
331
+ }
332
+ }
333
+ subscribeMessages(callback) {
334
+ if (this.version === "v1") {
335
+ this.listeners.add(callback);
336
+ return () => {
337
+ this.listeners.delete(callback);
338
+ };
339
+ } else {
340
+ const subscription = this.setupChat.messageObservable.subscribe(
341
+ callback
342
+ );
343
+ return () => subscription.unsubscribe();
344
+ }
345
+ }
346
+ };
347
+ // Annotate the CommonJS export names for ESM import in node:
348
+ 0 && (module.exports = {
349
+ CHAT_TOPIC,
350
+ LivekitService,
351
+ Room,
352
+ TRANSCRIPTION_TOPIC
353
+ });
@@ -0,0 +1,131 @@
1
+ import { ReceivedChatMessage } from '@livekit/components-core';
2
+ import { Participant, Room as Room$1, RoomOptions as RoomOptions$1 } from 'livekit-client';
3
+
4
+ interface RoomOptions extends Partial<RoomOptions$1> {
5
+ }
6
+ declare class Room extends Room$1 {
7
+ id: string;
8
+ groupId: string;
9
+ createdAt: string;
10
+ connectedAt: string;
11
+ constructor(options: RoomOptions);
12
+ }
13
+ interface UserFrom extends Participant {
14
+ id: string;
15
+ role: "user" | "agent" | "assistant";
16
+ }
17
+ interface ApiMessage extends ReceivedChatMessage {
18
+ content: string;
19
+ createdAt: string;
20
+ from?: UserFrom;
21
+ media?: Array<{
22
+ name?: string;
23
+ url: string;
24
+ ext: string;
25
+ type?: string;
26
+ }>;
27
+ reports?: Array<{
28
+ id: string;
29
+ createdAt: string;
30
+ }>;
31
+ }
32
+ type CreateRoomOptions = {
33
+ language: string;
34
+ timezone: string;
35
+ affinity?: Record<string, unknown>;
36
+ disablePersistence?: boolean;
37
+ };
38
+ type GetMessagesOptions = {
39
+ roomId?: string;
40
+ affinity?: {
41
+ agentId?: string;
42
+ agentType?: string;
43
+ };
44
+ with?: string[];
45
+ };
46
+ type PersistMessageOptions = {
47
+ externalId?: string;
48
+ roomId: string;
49
+ content: string;
50
+ identity?: string;
51
+ kind?: number;
52
+ };
53
+ type EvaluateRoomOptions = {
54
+ rating: number;
55
+ comment?: string;
56
+ };
57
+ type MessageReportOptions = {
58
+ messageId: string;
59
+ };
60
+ type MessageReactionOptions = {
61
+ messageId: string;
62
+ add?: string[];
63
+ remove?: string[];
64
+ };
65
+ type RoomApiResponse = {
66
+ id: string;
67
+ groupId: string;
68
+ token: string;
69
+ wsURL: string;
70
+ createdAt: string;
71
+ };
72
+ type UserApiResponse = {
73
+ id: string;
74
+ externalId: string;
75
+ organizationId: string;
76
+ role: string;
77
+ token: string;
78
+ };
79
+ type MessagesApiResponse = {
80
+ items: ApiMessage[];
81
+ count: number;
82
+ limit: number;
83
+ offset: number;
84
+ };
85
+ declare const CHAT_TOPIC: "lk.chat";
86
+ declare const TRANSCRIPTION_TOPIC: "lk.transcription";
87
+ type MessageListener<M = ApiMessage> = (messages: M[]) => void;
88
+ type ChatServiceOptions = {
89
+ version: "v0" | "v1";
90
+ organizationId: string;
91
+ channelTopic?: string;
92
+ transcriptionTopic?: string;
93
+ messagePersistence?: "disabled" | "server" | "client";
94
+ } & ({
95
+ apiUrl: string;
96
+ } | {
97
+ room: Room;
98
+ });
99
+ declare class LivekitService {
100
+ private listeners;
101
+ private apiUrl;
102
+ private version;
103
+ private organizationId;
104
+ private channelTopic;
105
+ private transcriptionTopic;
106
+ private setupChat;
107
+ private abortControllers;
108
+ private authToken;
109
+ private messagePersistence?;
110
+ room: Room;
111
+ constructor(options: ChatServiceOptions);
112
+ private initialize;
113
+ private processMessage;
114
+ private emitMessage;
115
+ register(externalId: string, secret: string, name?: string): Promise<UserApiResponse>;
116
+ joinRoom(roomId: string, timezone: string, language: string): Promise<Room>;
117
+ instanceRoom(): Room;
118
+ createRoom(options: CreateRoomOptions): Promise<Room>;
119
+ evaluateRoom(options: EvaluateRoomOptions): Promise<void>;
120
+ closeRoom(): Promise<void>;
121
+ disconnect(): Promise<void>;
122
+ sendMessage(message: string): Promise<void>;
123
+ persistMessage(options: PersistMessageOptions): Promise<MessagesApiResponse>;
124
+ getMessages(options: GetMessagesOptions): Promise<ApiMessage[]>;
125
+ sendMessageReport(options: MessageReportOptions): Promise<void>;
126
+ deleteMessageReport(options: MessageReportOptions): Promise<void>;
127
+ updateMessageReactions(options: MessageReactionOptions): Promise<void>;
128
+ subscribeMessages<M extends ApiMessage = ApiMessage>(callback: MessageListener<M>): () => void;
129
+ }
130
+
131
+ export { type ApiMessage, CHAT_TOPIC, type CreateRoomOptions, type EvaluateRoomOptions, type GetMessagesOptions, LivekitService, type MessageReactionOptions, type MessageReportOptions, type MessagesApiResponse, type PersistMessageOptions, Room, type RoomApiResponse, type RoomOptions, TRANSCRIPTION_TOPIC, type UserApiResponse, type UserFrom };
@@ -0,0 +1,131 @@
1
+ import { ReceivedChatMessage } from '@livekit/components-core';
2
+ import { Participant, Room as Room$1, RoomOptions as RoomOptions$1 } from 'livekit-client';
3
+
4
+ interface RoomOptions extends Partial<RoomOptions$1> {
5
+ }
6
+ declare class Room extends Room$1 {
7
+ id: string;
8
+ groupId: string;
9
+ createdAt: string;
10
+ connectedAt: string;
11
+ constructor(options: RoomOptions);
12
+ }
13
+ interface UserFrom extends Participant {
14
+ id: string;
15
+ role: "user" | "agent" | "assistant";
16
+ }
17
+ interface ApiMessage extends ReceivedChatMessage {
18
+ content: string;
19
+ createdAt: string;
20
+ from?: UserFrom;
21
+ media?: Array<{
22
+ name?: string;
23
+ url: string;
24
+ ext: string;
25
+ type?: string;
26
+ }>;
27
+ reports?: Array<{
28
+ id: string;
29
+ createdAt: string;
30
+ }>;
31
+ }
32
+ type CreateRoomOptions = {
33
+ language: string;
34
+ timezone: string;
35
+ affinity?: Record<string, unknown>;
36
+ disablePersistence?: boolean;
37
+ };
38
+ type GetMessagesOptions = {
39
+ roomId?: string;
40
+ affinity?: {
41
+ agentId?: string;
42
+ agentType?: string;
43
+ };
44
+ with?: string[];
45
+ };
46
+ type PersistMessageOptions = {
47
+ externalId?: string;
48
+ roomId: string;
49
+ content: string;
50
+ identity?: string;
51
+ kind?: number;
52
+ };
53
+ type EvaluateRoomOptions = {
54
+ rating: number;
55
+ comment?: string;
56
+ };
57
+ type MessageReportOptions = {
58
+ messageId: string;
59
+ };
60
+ type MessageReactionOptions = {
61
+ messageId: string;
62
+ add?: string[];
63
+ remove?: string[];
64
+ };
65
+ type RoomApiResponse = {
66
+ id: string;
67
+ groupId: string;
68
+ token: string;
69
+ wsURL: string;
70
+ createdAt: string;
71
+ };
72
+ type UserApiResponse = {
73
+ id: string;
74
+ externalId: string;
75
+ organizationId: string;
76
+ role: string;
77
+ token: string;
78
+ };
79
+ type MessagesApiResponse = {
80
+ items: ApiMessage[];
81
+ count: number;
82
+ limit: number;
83
+ offset: number;
84
+ };
85
+ declare const CHAT_TOPIC: "lk.chat";
86
+ declare const TRANSCRIPTION_TOPIC: "lk.transcription";
87
+ type MessageListener<M = ApiMessage> = (messages: M[]) => void;
88
+ type ChatServiceOptions = {
89
+ version: "v0" | "v1";
90
+ organizationId: string;
91
+ channelTopic?: string;
92
+ transcriptionTopic?: string;
93
+ messagePersistence?: "disabled" | "server" | "client";
94
+ } & ({
95
+ apiUrl: string;
96
+ } | {
97
+ room: Room;
98
+ });
99
+ declare class LivekitService {
100
+ private listeners;
101
+ private apiUrl;
102
+ private version;
103
+ private organizationId;
104
+ private channelTopic;
105
+ private transcriptionTopic;
106
+ private setupChat;
107
+ private abortControllers;
108
+ private authToken;
109
+ private messagePersistence?;
110
+ room: Room;
111
+ constructor(options: ChatServiceOptions);
112
+ private initialize;
113
+ private processMessage;
114
+ private emitMessage;
115
+ register(externalId: string, secret: string, name?: string): Promise<UserApiResponse>;
116
+ joinRoom(roomId: string, timezone: string, language: string): Promise<Room>;
117
+ instanceRoom(): Room;
118
+ createRoom(options: CreateRoomOptions): Promise<Room>;
119
+ evaluateRoom(options: EvaluateRoomOptions): Promise<void>;
120
+ closeRoom(): Promise<void>;
121
+ disconnect(): Promise<void>;
122
+ sendMessage(message: string): Promise<void>;
123
+ persistMessage(options: PersistMessageOptions): Promise<MessagesApiResponse>;
124
+ getMessages(options: GetMessagesOptions): Promise<ApiMessage[]>;
125
+ sendMessageReport(options: MessageReportOptions): Promise<void>;
126
+ deleteMessageReport(options: MessageReportOptions): Promise<void>;
127
+ updateMessageReactions(options: MessageReactionOptions): Promise<void>;
128
+ subscribeMessages<M extends ApiMessage = ApiMessage>(callback: MessageListener<M>): () => void;
129
+ }
130
+
131
+ export { type ApiMessage, CHAT_TOPIC, type CreateRoomOptions, type EvaluateRoomOptions, type GetMessagesOptions, LivekitService, type MessageReactionOptions, type MessageReportOptions, type MessagesApiResponse, type PersistMessageOptions, Room, type RoomApiResponse, type RoomOptions, TRANSCRIPTION_TOPIC, type UserApiResponse, type UserFrom };