@kaltura-sdk/avatars 1.15.4 → 1.15.5

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/index.esm.js CHANGED
@@ -2,10 +2,10 @@ import { UnisphereLoggerFactory, TinyDataStore, TinyPubSub, performanceMonitor }
2
2
  import { getPartnerIdFromKs } from '@unisphere/runtime-js';
3
3
  import { DisconnectReasons, getAvatarDefaultCapabilities, resolveActiveContextType, AvatarConnectionStatus } from '@unisphere/genie-types';
4
4
  import { z as z$1 } from 'zod/mini';
5
+ import { AlertIconEnum } from '@unisphere/notifications-core';
5
6
  import { initializeLogsCollector, EselfSession, MediaTrackState, sendLogs } from '@kaltura-sdk/rtc-avatar';
6
7
  import { produce } from 'immer';
7
8
  import * as yaml from 'js-yaml';
8
- import { AlertIconEnum, NotificationTypes } from '@unisphere/notifications-core';
9
9
  import { ApplicationPageTypes, ApplicationEventTypes, AnalyticsBucket } from '@unisphere/runtime';
10
10
  import { executeClientToolCall, sendClientToolResponse } from '@local/genie-shared-utils';
11
11
 
@@ -6260,6 +6260,48 @@ const stvSpeechChunkSchema = z$1.object({
6260
6260
  durationMs: z$1.number(),
6261
6261
  speechId: z$1.string()
6262
6262
  });
6263
+ const unsupportedClientSchema = z$1.object({
6264
+ code: z$1.optional(z$1.string())
6265
+ });
6266
+
6267
+ // Codes for notifications that are not tied to a connection disconnect reason.
6268
+ // Keep these string-stable: consumers of `externalActions.showNotification`
6269
+ // match on `code` to look up their own localized copy.
6270
+ var AvatarNotificationCode;
6271
+ (function (AvatarNotificationCode) {
6272
+ AvatarNotificationCode["ScreenShareError"] = "ScreenShareError";
6273
+ AvatarNotificationCode["AgentRecoveryExhausted"] = "AgentRecoveryExhausted";
6274
+ AvatarNotificationCode["ConversationTimeWarning"] = "ConversationTimeWarning";
6275
+ })(AvatarNotificationCode || (AvatarNotificationCode = {}));
6276
+ const disconnectReasonVariantMap = {
6277
+ [DisconnectReasons.ConnectionError]: AlertIconEnum.Error,
6278
+ [DisconnectReasons.ExceededTierLimits]: AlertIconEnum.Warning,
6279
+ [DisconnectReasons.NoAgentsAvailable]: AlertIconEnum.Warning,
6280
+ [DisconnectReasons.UserMediaInitializationFailed]: AlertIconEnum.Error,
6281
+ [DisconnectReasons.UserRequested]: AlertIconEnum.Success,
6282
+ [DisconnectReasons.WebsocketConnectionFailed]: AlertIconEnum.Error,
6283
+ [DisconnectReasons.WebsocketDisconnected]: AlertIconEnum.Warning,
6284
+ [DisconnectReasons.PeerRemoved]: AlertIconEnum.Warning,
6285
+ [DisconnectReasons.BadRequest]: AlertIconEnum.Error,
6286
+ [DisconnectReasons.ASRConnectionFailed]: AlertIconEnum.Warning,
6287
+ [DisconnectReasons.DestroyFailed]: AlertIconEnum.Error,
6288
+ [DisconnectReasons.ConversationEnded]: AlertIconEnum.Warning,
6289
+ [DisconnectReasons.UnknownReason]: AlertIconEnum.Error,
6290
+ [DisconnectReasons.DevicesPermissionDenied]: AlertIconEnum.Warning,
6291
+ [DisconnectReasons.AgentResponseTimeout]: AlertIconEnum.Warning,
6292
+ [DisconnectReasons.UnsupportedClient]: AlertIconEnum.Error,
6293
+ [DisconnectReasons.JoinRoomTimeout]: AlertIconEnum.Warning,
6294
+ [DisconnectReasons.ConnectionTimeout]: AlertIconEnum.Warning,
6295
+ [DisconnectReasons.PlayerConnectionFailed]: AlertIconEnum.Error
6296
+ };
6297
+ const defaultDisconnectVariant = AlertIconEnum.Error;
6298
+ function isMappedAvatarDisconnectReason(reason) {
6299
+ return !!disconnectReasonVariantMap[reason];
6300
+ }
6301
+ function getAvatarDisconnectNotificationVariant(reason) {
6302
+ var _a;
6303
+ return (_a = disconnectReasonVariantMap[reason]) !== null && _a !== void 0 ? _a : defaultDisconnectVariant;
6304
+ }
6263
6305
 
6264
6306
  const AvatarConnectionMachineId = 'AvatarClient';
6265
6307
 
@@ -19259,97 +19301,6 @@ const setDisconnectData = assign$1(({
19259
19301
  });
19260
19302
  });
19261
19303
 
19262
- const avatarConnectionNotificationsMap = {
19263
- [DisconnectReasons.ConnectionError]: {
19264
- text: 'There was a problem connecting to the server. Please try again later.',
19265
- variant: AlertIconEnum.Error
19266
- },
19267
- [DisconnectReasons.ExceededTierLimits]: {
19268
- text: 'You have exceeded your usage limits. Please upgrade your plan or try again later.',
19269
- variant: AlertIconEnum.Warning
19270
- },
19271
- [DisconnectReasons.NoAgentsAvailable]: {
19272
- text: 'No agents are currently available. Please try again later.',
19273
- variant: AlertIconEnum.Warning
19274
- },
19275
- [DisconnectReasons.UserMediaInitializationFailed]: {
19276
- text: 'Unable to access your microphone or camera. Please check your device settings.',
19277
- variant: AlertIconEnum.Error
19278
- },
19279
- [DisconnectReasons.UserRequested]: {
19280
- text: 'You have ended the session.',
19281
- variant: AlertIconEnum.Success
19282
- },
19283
- [DisconnectReasons.WebsocketConnectionFailed]: {
19284
- text: 'WebSocket connection failed. Please check your internet connection and try again.',
19285
- variant: AlertIconEnum.Error
19286
- },
19287
- [DisconnectReasons.WebsocketDisconnected]: {
19288
- text: 'The connection was lost. Please try reconnecting.',
19289
- variant: AlertIconEnum.Warning
19290
- },
19291
- [DisconnectReasons.PeerRemoved]: {
19292
- text: 'The session has ended as the peer has disconnected.',
19293
- variant: AlertIconEnum.Warning
19294
- },
19295
- [DisconnectReasons.BadRequest]: {
19296
- text: 'There was a bad request error. Please verify your settings and try again.',
19297
- variant: AlertIconEnum.Error
19298
- },
19299
- [DisconnectReasons.ASRConnectionFailed]: {
19300
- text: 'Voice Activity Detection connection failed. Some features may not work properly.',
19301
- variant: AlertIconEnum.Warning
19302
- },
19303
- [DisconnectReasons.DestroyFailed]: {
19304
- text: 'An error occurred while ending the session. Please try again later.',
19305
- variant: AlertIconEnum.Error
19306
- },
19307
- [DisconnectReasons.ConversationEnded]: {
19308
- text: 'The conversation has ended.',
19309
- variant: AlertIconEnum.Warning
19310
- },
19311
- [DisconnectReasons.UnknownReason]: {
19312
- text: 'An unknown error occurred. Please try again later or contact support.',
19313
- variant: AlertIconEnum.Error
19314
- },
19315
- [DisconnectReasons.DevicesPermissionDenied]: {
19316
- text: 'Microphone access was denied. Please allow microphone permissions and try again.',
19317
- variant: AlertIconEnum.Warning
19318
- },
19319
- [DisconnectReasons.AgentResponseTimeout]: {
19320
- text: 'The agent took too long to respond. Please try again later.',
19321
- variant: AlertIconEnum.Warning
19322
- },
19323
- [DisconnectReasons.UnsupportedClient]: {
19324
- text: 'The client you are using is not supported. Please contact support.',
19325
- variant: AlertIconEnum.Error
19326
- },
19327
- [DisconnectReasons.JoinRoomTimeout]: {
19328
- text: 'Joining the room timed out. Please check your connection and try again.',
19329
- variant: AlertIconEnum.Warning
19330
- },
19331
- [DisconnectReasons.ConnectionTimeout]: {
19332
- text: 'The connection timed out. Please check your internet connection and try again.',
19333
- variant: AlertIconEnum.Warning
19334
- },
19335
- [DisconnectReasons.PlayerConnectionFailed]: {
19336
- text: 'A playback error occurred while connecting to the avatar. Please try again.',
19337
- variant: AlertIconEnum.Error
19338
- }
19339
- };
19340
- const defaultDisconnectNotification = {
19341
- text: 'An unknown error occurred. Please try again later or contact support.',
19342
- variant: AlertIconEnum.Error
19343
- };
19344
- function isMappedAvatarDisconnectReason(reason) {
19345
- return !!avatarConnectionNotificationsMap[reason];
19346
- }
19347
- function getAvatarConnectionNotification(reason) {
19348
- return Object.assign({
19349
- type: NotificationTypes.Alert
19350
- }, avatarConnectionNotificationsMap[reason] || defaultDisconnectNotification);
19351
- }
19352
-
19353
19304
  const showDisconnectNotification = ({
19354
19305
  context
19355
19306
  }) => {
@@ -19377,7 +19328,10 @@ const showDisconnectNotification = ({
19377
19328
  }
19378
19329
  });
19379
19330
  }
19380
- const notification = getAvatarConnectionNotification(context.disconnectData.reason);
19331
+ const notification = {
19332
+ code: context.disconnectData.reason,
19333
+ variant: getAvatarDisconnectNotificationVariant(context.disconnectData.reason)
19334
+ };
19381
19335
  try {
19382
19336
  context.externalActions.showNotification(notification);
19383
19337
  } catch (error) {
@@ -19428,6 +19382,7 @@ const onConversationEnded = fromCallback(({
19428
19382
  });
19429
19383
  });
19430
19384
 
19385
+ const USAGE_LIMIT_EXCEEDED_CODE = 'USAGE_LIMIT_EXCEEDED';
19431
19386
  const source$g = createTinyPubsubEventsSource(websocketMessage, {
19432
19387
  disconnect: {
19433
19388
  schema: null
@@ -19451,7 +19406,7 @@ const source$g = createTinyPubsubEventsSource(websocketMessage, {
19451
19406
  schema: null
19452
19407
  },
19453
19408
  unsupportedClient: {
19454
- schema: null
19409
+ schema: unsupportedClientSchema
19455
19410
  }
19456
19411
  }, {
19457
19412
  queueWhilePending: true
@@ -19480,7 +19435,10 @@ const onError = fromCallback(({
19480
19435
  throwToNoAgent: createHandler(DisconnectReasons.NoAgentsAvailable),
19481
19436
  throwToExceededTier: createHandler(DisconnectReasons.ExceededTierLimits),
19482
19437
  throwToBadRequest: createHandler(DisconnectReasons.BadRequest),
19483
- unsupportedClient: createHandler(DisconnectReasons.UnsupportedClient)
19438
+ unsupportedClient: event => {
19439
+ const reason = (event === null || event === void 0 ? void 0 : event.code) === USAGE_LIMIT_EXCEEDED_CODE ? DisconnectReasons.ExceededTierLimits : DisconnectReasons.UnsupportedClient;
19440
+ createHandler(reason)(event);
19441
+ }
19484
19442
  }
19485
19443
  });
19486
19444
  });
@@ -20407,9 +20365,11 @@ const showTimeWarningNotification = ({
20407
20365
  }) => {
20408
20366
  assertEvent(event, AvatarConnectionMachineEventTypes.ConversationTimeWarningReceived);
20409
20367
  const notification = {
20410
- type: NotificationTypes.Alert,
20411
- text: `Your conversation will end in ${event.payload.remainingTime} seconds.`,
20368
+ code: AvatarNotificationCode.ConversationTimeWarning,
20412
20369
  variant: AlertIconEnum.Warning,
20370
+ params: {
20371
+ remainingTime: event.payload.remainingTime
20372
+ },
20413
20373
  options: {
20414
20374
  duration: event.payload.remainingTime,
20415
20375
  showClose: true
@@ -21423,8 +21383,7 @@ const showScreenShareErrorNotification = ({
21423
21383
  }) => {
21424
21384
  try {
21425
21385
  context.externalActions.showNotification({
21426
- type: NotificationTypes.Alert,
21427
- text: 'Screen sharing encountered an error. Please try again.',
21386
+ code: AvatarNotificationCode.ScreenShareError,
21428
21387
  variant: AlertIconEnum.Error
21429
21388
  });
21430
21389
  } catch (error) {
@@ -23287,8 +23246,7 @@ const showAgentRecoveryExhaustedNotification = ({
23287
23246
  context
23288
23247
  }) => {
23289
23248
  const notification = {
23290
- type: NotificationTypes.Alert,
23291
- text: "We're having trouble getting a response. Please try asking again.",
23249
+ code: AvatarNotificationCode.AgentRecoveryExhausted,
23292
23250
  variant: AlertIconEnum.Warning,
23293
23251
  options: {
23294
23252
  showClose: true
@@ -24390,4 +24348,4 @@ class AvatarClientManager extends ActorManager {
24390
24348
  }
24391
24349
  }
24392
24350
 
24393
- export { ApplicationFeatures, AvatarClientManager, AvatarConnectionMachineEventTypes, AvatarConnectionMachineId, ButtonNames, PageNames, agentRawTextClientToolDeltaSchema, agentRawTextDeltaSchema, agentRawTextSchema, agentTurnToTalkSchema, askPermissionsSchema, avatarClientLoggerFactory, avatarConnectionMachine, avatarRTCClientManager, clientConfigurationSchema, conversationEndedSchema, conversationTimeWarningSchema, createTinyPubsubEventsHandler, createTinyPubsubEventsSource, generatingSpeechSchema, getQueryParam, initializeLogsCollectionIfNeeded, isMobileDevice, joinCompleteSchema, noAgentSchema, onServerConnectedSchema, pauseExpiryWarningSchema, resetWebsocketClientTeardownState, showAgentSchema, showStartSpeechSchema, stvFinishedTalkingSchema, stvNewSessionSchema, stvSpeechChunkSchema, stvStartedTalkingSchema, timingTracker, websocketClientManager, websocketDebugInfo, websocketMessage, websocketNonRecoveredReconnect, websocketRecoveryState, websocketSystemMessage };
24351
+ export { ApplicationFeatures, AvatarClientManager, AvatarConnectionMachineEventTypes, AvatarConnectionMachineId, AvatarNotificationCode, ButtonNames, PageNames, agentRawTextClientToolDeltaSchema, agentRawTextDeltaSchema, agentRawTextSchema, agentTurnToTalkSchema, askPermissionsSchema, avatarClientLoggerFactory, avatarConnectionMachine, avatarRTCClientManager, clientConfigurationSchema, conversationEndedSchema, conversationTimeWarningSchema, createTinyPubsubEventsHandler, createTinyPubsubEventsSource, generatingSpeechSchema, getAvatarDisconnectNotificationVariant, getQueryParam, initializeLogsCollectionIfNeeded, isMappedAvatarDisconnectReason, isMobileDevice, joinCompleteSchema, noAgentSchema, onServerConnectedSchema, pauseExpiryWarningSchema, resetWebsocketClientTeardownState, showAgentSchema, showStartSpeechSchema, stvFinishedTalkingSchema, stvNewSessionSchema, stvSpeechChunkSchema, stvStartedTalkingSchema, timingTracker, unsupportedClientSchema, websocketClientManager, websocketDebugInfo, websocketMessage, websocketNonRecoveredReconnect, websocketRecoveryState, websocketSystemMessage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaltura-sdk/avatars",
3
- "version": "1.15.4",
3
+ "version": "1.15.5",
4
4
  "author": "kaltura",
5
5
  "license": "AGPL-3.0",
6
6
  "repository": {
@@ -9,8 +9,8 @@
9
9
  },
10
10
  "types": "./src/index.d.ts",
11
11
  "dependencies": {
12
- "@kaltura-sdk/rtc-avatar": "^1.32.28",
13
- "@kaltura-sdk/rtc-core": "^1.25.17",
12
+ "@kaltura-sdk/rtc-avatar": "^1.32.34",
13
+ "@kaltura-sdk/rtc-core": "^1.25.21",
14
14
  "@local/genie-shared-utils": "^1.0.0",
15
15
  "@unisphere/core": "^1.99.0",
16
16
  "@unisphere/genie-types": "^1.39.1",
@@ -1,5 +1,5 @@
1
1
  import { UnisphereLoggerType } from '@unisphere/core';
2
- import { Notifications } from '@unisphere/notifications-core';
2
+ import { AvatarNotificationRequest } from './notifications';
3
3
  import { clientConfigurationSchema } from './schemas';
4
4
  import { z } from 'zod/mini';
5
5
  import { KalturaAnalyticsServiceType, PubSubServiceType } from '@unisphere/runtime';
@@ -53,7 +53,7 @@ export interface AvatarConnectionMachineContext {
53
53
  /** @deprecated TODO sk consider to avoid saving entire service object inside the machine's context */
54
54
  pubSubService: PubSubServiceType;
55
55
  externalActions: {
56
- showNotification: (notification: Notifications) => void;
56
+ showNotification: (notification: AvatarNotificationRequest) => void;
57
57
  };
58
58
  connectionId: string;
59
59
  clientConfiguration: z.infer<typeof clientConfigurationSchema>['clientConfiguration'] | null;
@@ -6,6 +6,7 @@ export * from './events';
6
6
  export * from './context';
7
7
  export * from './input';
8
8
  export * from './schemas';
9
+ export * from './notifications';
9
10
  export declare const AvatarConnectionMachineId = "AvatarClient";
10
11
  export type AvatarConnectionActor = ActorRefFrom<typeof avatarConnectionMachine>;
11
12
  export type AvatarConnectionMachineState = SnapshotFrom<typeof avatarConnectionMachine>;
@@ -1,5 +1,5 @@
1
1
  import { UnisphereLoggerType } from '@unisphere/core';
2
- import { Notifications } from '@unisphere/notifications-core';
2
+ import { AvatarNotificationRequest } from './notifications';
3
3
  import { KalturaAnalyticsServiceType, PubSubServiceType } from '@unisphere/runtime';
4
4
  import { AvatarRuntimeSettings } from '@unisphere/genie-types';
5
5
  import type { ClientToolHandler, ClientToolsInput, ClientToolsRegistry, GetClientToolHandler } from '@local/genie-shared-utils';
@@ -14,7 +14,7 @@ export interface AvatarConnectionMachineInput {
14
14
  kalturaAnalyticsService: KalturaAnalyticsServiceType;
15
15
  pubSubService: PubSubServiceType;
16
16
  externalActions: {
17
- showNotification: (notification: Notifications) => void;
17
+ showNotification: (notification: AvatarNotificationRequest) => void;
18
18
  };
19
19
  runtimeSettings: AvatarRuntimeSettings;
20
20
  stickyId?: string;
@@ -1,4 +1,21 @@
1
- import { Notifications } from '@unisphere/notifications-core';
1
+ import { AlertIconEnum } from '@unisphere/notifications-core';
2
2
  import { DisconnectReasons } from '@unisphere/genie-types';
3
+ export declare enum AvatarNotificationCode {
4
+ ScreenShareError = "ScreenShareError",
5
+ AgentRecoveryExhausted = "AgentRecoveryExhausted",
6
+ ConversationTimeWarning = "ConversationTimeWarning"
7
+ }
8
+ export type AvatarNotificationReasonCode = DisconnectReasons | AvatarNotificationCode;
9
+ export interface AvatarNotificationRequest {
10
+ code: AvatarNotificationReasonCode;
11
+ variant: AlertIconEnum;
12
+ /** Interpolation values the host's translation for `code` may reference. */
13
+ params?: Record<string, string | number>;
14
+ options?: {
15
+ duration?: number;
16
+ isPermanent?: boolean;
17
+ showClose?: boolean;
18
+ };
19
+ }
3
20
  export declare function isMappedAvatarDisconnectReason(reason: DisconnectReasons): boolean;
4
- export declare function getAvatarConnectionNotification(reason: DisconnectReasons): Notifications;
21
+ export declare function getAvatarDisconnectNotificationVariant(reason: DisconnectReasons): AlertIconEnum;
@@ -103,3 +103,6 @@ export declare const stvSpeechChunkSchema: z.ZodMiniObject<{
103
103
  durationMs: z.ZodMiniNumber<number>;
104
104
  speechId: z.ZodMiniString<string>;
105
105
  }, z.core.$strip>;
106
+ export declare const unsupportedClientSchema: z.ZodMiniObject<{
107
+ code: z.ZodMiniOptional<z.ZodMiniString<string>>;
108
+ }, z.core.$strip>;
@@ -1,4 +1,4 @@
1
- import { Notifications } from '@unisphere/notifications-core';
1
+ import { AvatarNotificationRequest } from './machines/avatar-connection/types/notifications';
2
2
  export type AvatarClientManagerActions = {
3
- showNotification: (notification: Notifications) => void;
3
+ showNotification: (notification: AvatarNotificationRequest) => void;
4
4
  };