agora-appbuilder-core 4.1.0-beta-15 → 4.1.0-beta-17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agora-appbuilder-core",
3
- "version": "4.1.0-beta-15",
3
+ "version": "4.1.0-beta-17",
4
4
  "description": "React Native template for RTE app builder",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -67,3 +67,6 @@ export {useBeautyEffects} from '../src/app-state/useBeautyEffects';
67
67
  export {useLiveStreamDataContext} from '../src/components/contexts/LiveStreamDataContext';
68
68
  export {useRtm} from '../src/components/ChatContext';
69
69
  export {useGetHostIds} from '../src/utils/useGetHostUids';
70
+ export {useAIAgent} from '../src/ai-agent/components/AgentControls/AgentContext';
71
+ export type {AIAgentContextInterface} from '../src/ai-agent/components/AgentControls/AgentContext';
72
+ export type {AIAgentState} from '../src/ai-agent/components/AgentControls/const';
@@ -76,8 +76,8 @@ const DefaultConfig = {
76
76
  CHAT_ORG_NAME: '',
77
77
  CHAT_APP_NAME: '',
78
78
  CHAT_URL: '',
79
- CLI_VERSION: '3.1.0-beta-15',
80
- CORE_VERSION: '4.1.0-beta-15',
79
+ CLI_VERSION: '3.1.0-beta-17',
80
+ CORE_VERSION: '4.1.0-beta-17',
81
81
  DISABLE_LANDSCAPE_MODE: false,
82
82
  STT_AUTO_START: false,
83
83
  CLOUD_RECORDING_AUTO_START: false,
@@ -30,7 +30,7 @@ export interface ChatItem {
30
30
  isSelf: boolean;
31
31
  }
32
32
 
33
- export interface AgentContextInterface {
33
+ export interface AIAgentContextInterface {
34
34
  toggleAgentConnection: (forceStop?: boolean) => Promise<boolean>;
35
35
  agentConnectionState: AIAgentState;
36
36
  setAgentConnectionState: (agentState: AIAgentState) => void;
@@ -55,7 +55,7 @@ export interface AgentContextInterface {
55
55
  clearChatHistory: () => void;
56
56
  }
57
57
 
58
- export const AgentContext = createContext<AgentContextInterface>({
58
+ export const AgentContext = createContext<AIAgentContextInterface>({
59
59
  toggleAgentConnection: () => {
60
60
  return Promise.resolve(false);
61
61
  },
@@ -93,7 +93,7 @@ export const AgentProvider: React.FC<{children: React.ReactNode}> = ({
93
93
  const [chatHistory, setChatHistory] = useState<IMessageListItem[]>([]);
94
94
  const [agentId, setAgentId] = useState('');
95
95
  const [agentVoice, setAgentVoice] =
96
- useState<AgentContextInterface['agentVoice']>('');
96
+ useState<AIAgentContextInterface['agentVoice']>('');
97
97
  const [prompt, setPrompt] = useState('');
98
98
  const {activeUids: users} = useContent();
99
99
  const [isStartAPICalled, setStartAPICalled] = useState(false);
@@ -101,7 +101,7 @@ export const AgentProvider: React.FC<{children: React.ReactNode}> = ({
101
101
  const [isInterruptionHandlingEnabled, setIsInterruptionHandlingEnabled] =
102
102
  useState(false);
103
103
  const [language, setLanguage] =
104
- useState<AgentContextInterface['language']>('');
104
+ useState<AIAgentContextInterface['language']>('');
105
105
 
106
106
  const {
107
107
  data: {channel: channel_name, uid: localUid, agents},
@@ -113,7 +113,7 @@ export const AgentProvider: React.FC<{children: React.ReactNode}> = ({
113
113
  const messageCache = {};
114
114
  const TIMEOUT_MS = 5000; // Timeout for incomplete messages
115
115
 
116
- //set agent id when user refresh the page
116
+ //set agent uid when user refresh the page - to maintain the app state
117
117
  useEffect(() => {
118
118
  //@ts-ignore
119
119
  if (store?.agentUID && store?.agentUID !== agentUID) {
@@ -122,6 +122,15 @@ export const AgentProvider: React.FC<{children: React.ReactNode}> = ({
122
122
  }
123
123
  }, [store, agentUID]);
124
124
 
125
+ //set agent id when user refresh the page - to maintain the app state
126
+ useEffect(() => {
127
+ //@ts-ignore
128
+ if (store?.agentId && store?.agentId !== agentId) {
129
+ //@ts-ignore
130
+ setAgentId(store.agentId);
131
+ }
132
+ }, [store, agentId]);
133
+
125
134
  React.useEffect(() => {
126
135
  if (!isSubscribedForStreams) {
127
136
  RtcEngineUnsafe.addListener('onStreamMessage', (...args: any[]) => {
@@ -203,7 +212,7 @@ export const AgentProvider: React.FC<{children: React.ReactNode}> = ({
203
212
  closeMessageEngine(); // release message engine
204
213
  setAgentConnectionState(AgentState.NOT_CONNECTED);
205
214
  if (isStopAPICalled) {
206
- setStartAPICalled(true);
215
+ setStopAPICalled(false);
207
216
  }
208
217
  }
209
218
  }, [
@@ -452,4 +461,4 @@ export const connectToAIAgent = async (
452
461
  }
453
462
  };
454
463
 
455
- export const useAgent = createHook(AgentContext);
464
+ export const useAIAgent = createHook(AgentContext);
@@ -986,10 +986,7 @@ export let messageService: MessageEngine | null = null;
986
986
  * @returns {MessageEngine} Singleton instance of MessageEngine
987
987
  */
988
988
  export function initializeMessageEngine(): MessageEngine {
989
- console.log('debguggingnew initializeMessageEngine getting here');
990
989
  if (!messageService) {
991
- console.log('debuggingnew getting here');
992
-
993
990
  messageService = new MessageEngine(EMessageEngineMode.AUTO, chatHistory => {
994
991
  LocalEventEmitter.emit(LocalEventsEnum.AGENT_TRANSCRIPT_CHANGE, {
995
992
  data: {
@@ -999,7 +996,6 @@ export function initializeMessageEngine(): MessageEngine {
999
996
  });
1000
997
  });
1001
998
  }
1002
- console.log('debguggingnew messageService', messageService);
1003
999
  return messageService;
1004
1000
  }
1005
1001
 
@@ -12,7 +12,7 @@ import {
12
12
  import SelectAiAgent from './SelectAiAgent';
13
13
  import ThemeConfig from '../../theme';
14
14
  import hexadecimalTransparency from '../../utils/hexadecimalTransparency';
15
- import {AgentContext, useAgent} from './AgentControls/AgentContext';
15
+ import {AgentContext, useAIAgent} from './AgentControls/AgentContext';
16
16
  import UserPrompt from './UserPrompt';
17
17
  import {useIsAgentAvailable} from './utils';
18
18
  import Toggle from '../../atoms/Toggle';
@@ -116,7 +116,7 @@ const AdvancedSettings = () => {
116
116
  setIsInterruptionHandlingEnabled,
117
117
  agentId,
118
118
  agentConnectionState,
119
- } = useAgent();
119
+ } = useAIAgent();
120
120
  const {
121
121
  data: {agents},
122
122
  } = useRoomInfo();
@@ -1,6 +1,11 @@
1
1
  import React, {useContext, useEffect, useMemo} from 'react';
2
2
  import {View, Text, StyleSheet} from 'react-native';
3
- import {Dropdown, useRoomInfo, Spacer} from 'customization-api';
3
+ import {
4
+ Dropdown,
5
+ useRoomInfo,
6
+ Spacer,
7
+ useStorageContext,
8
+ } from 'customization-api';
4
9
  import ThemeConfig from '../../theme';
5
10
  import {AgentContext} from './AgentControls/AgentContext';
6
11
 
@@ -8,7 +13,7 @@ const SelectAiAgent = () => {
8
13
  const {
9
14
  data: {agents},
10
15
  } = useRoomInfo();
11
-
16
+ const {setStore} = useStorageContext();
12
17
  const {agentId, setAgentId, agentConnectionState} = useContext(AgentContext);
13
18
 
14
19
  const data = useMemo(() => {
@@ -55,6 +60,13 @@ const SelectAiAgent = () => {
55
60
  onSelect={async ({label, value}) => {
56
61
  if (agentId !== value) {
57
62
  setAgentId(value);
63
+ //setting agent uid in the store so we can retrive it if user refresh the page
64
+ setStore(prevState => {
65
+ return {
66
+ ...prevState,
67
+ agentId: value,
68
+ };
69
+ });
58
70
  }
59
71
  }}
60
72
  />
@@ -24,7 +24,7 @@ const ChatItemBubble = ({item}: {item: any}) => {
24
24
  key={`${item.turn_id}-${item.uid}`}
25
25
  msgId={`${item.turn_id}-${item.uid}`}
26
26
  isLocal={localUid === item.uid}
27
- message={item.text}
27
+ message={item.text ? item.text : item?.metadata?.text}
28
28
  createdTimestamp={item._time}
29
29
  uid={item.uid}
30
30
  isDeleted={false}
@@ -56,6 +56,7 @@ const MobileLayoutComponent: LayoutComponent = () => {
56
56
  ...defaultContent[agentUID],
57
57
  name: 'AI Agent',
58
58
  video: false,
59
+ type: 'ai-agent',
59
60
  }}
60
61
  CustomChild={() =>
61
62
  connected ? (
@@ -100,6 +100,7 @@ const DesktopLayoutComponent: LayoutComponent = () => {
100
100
  ...defaultContent[agentUID],
101
101
  name: 'AI Agent',
102
102
  video: false,
103
+ type: 'ai-agent',
103
104
  }}
104
105
  CustomChild={() =>
105
106
  // show agent voice waves, when agent is connected to the channel, but also not on a state-of-wait,
@@ -17,7 +17,7 @@ import {
17
17
  SidePanelType,
18
18
  } from 'customization-api';
19
19
  import ThemeConfig from '../../theme';
20
- import {useAgent} from '../components/AgentControls/AgentContext';
20
+ import {useAIAgent} from '../components/AgentControls/AgentContext';
21
21
  import {AgentState} from '../components/AgentControls/const';
22
22
  import {useIsAgentAvailable} from '../components/utils';
23
23
 
@@ -98,7 +98,7 @@ const SettingButton = () => {
98
98
  };
99
99
 
100
100
  const DisconnectButton = () => {
101
- const {toggleAgentConnection} = useAgent();
101
+ const {toggleAgentConnection} = useAIAgent();
102
102
  return (
103
103
  <TouchableOpacity
104
104
  style={{backgroundColor: $config.SEMANTIC_ERROR, borderRadius: 50}}
@@ -111,7 +111,7 @@ const DisconnectButton = () => {
111
111
  };
112
112
 
113
113
  export const ConversationalAI: LayoutComponent = () => {
114
- const {agentConnectionState, toggleAgentConnection} = useAgent();
114
+ const {agentConnectionState, toggleAgentConnection} = useAIAgent();
115
115
  // const spline = useRef();
116
116
  // const sphere = useRef();
117
117
 
@@ -51,7 +51,7 @@ import {
51
51
  import {LogSource, logger} from '../../logger/AppBuilderLogger';
52
52
  import {useFullScreen} from '../../utils/useFullScreen';
53
53
  import SpotlightHighligher from './SpotlightHighlighter';
54
- import {useAgent} from '../../ai-agent/components/AgentControls/AgentContext';
54
+ import {useAIAgent} from '../../ai-agent/components/AgentControls/AgentContext';
55
55
 
56
56
  export interface VideoRendererProps {
57
57
  user: ContentInterface;
@@ -71,7 +71,7 @@ const VideoRenderer: React.FC<VideoRendererProps> = ({
71
71
  containerStyle = {},
72
72
  innerContainerStyle = {},
73
73
  }) => {
74
- const {agentConnectionState} = useAgent();
74
+ const {agentConnectionState} = useAIAgent();
75
75
  const {CustomAgentView} = useCustomization(data => {
76
76
  let components: {
77
77
  CustomAgentView: React.ComponentType<CustomAgentInterfaceProps>;
@@ -348,12 +348,12 @@ const VideoRenderer: React.FC<VideoRendererProps> = ({
348
348
  onChange={isVisible => {
349
349
  setVideoTileInViewPortState(user.uid, isVisible);
350
350
  }}>
351
- {CustomChild ? (
352
- <CustomChild />
353
- ) : $config.ENABLE_CONVERSATIONAL_AI &&
354
- user?.type === 'ai-agent' &&
355
- CustomAgentView ? (
351
+ {$config.ENABLE_CONVERSATIONAL_AI &&
352
+ user?.type === 'ai-agent' &&
353
+ CustomAgentView ? (
356
354
  <CustomAgentView connectionState={agentConnectionState} />
355
+ ) : CustomChild ? (
356
+ <CustomChild />
357
357
  ) : (
358
358
  <MaxVideoView
359
359
  fallback={() => {