@rqmii_immersive/agent-react-sdk 5.1.2 → 5.2.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/dist/{RqmiiCloudAvatarPlayer-CldnIv4K.js → RqmiiCloudAvatarPlayer-BL7GVcr_.js} +1052 -1054
- package/dist/RqmiiCloudAvatarPlayer-BL7GVcr_.js.map +1 -0
- package/dist/{RqmiiCloudAvatarPlayer-Bm730tzg.cjs → RqmiiCloudAvatarPlayer-Dc1h266_.cjs} +82 -82
- package/dist/RqmiiCloudAvatarPlayer-Dc1h266_.cjs.map +1 -0
- package/dist/agent-react-sdk.css +1 -1
- package/dist/core/managers/session.d.ts +2 -3
- package/dist/core/managers/session.d.ts.map +1 -1
- package/dist/embed.js +351 -351
- package/dist/embed.js.map +1 -1
- package/dist/hooks/use-rqmii-connection.d.ts +1 -1
- package/dist/hooks/use-rqmii-connection.d.ts.map +1 -1
- package/dist/hooks/use-rqmii-sdk.d.ts +0 -1
- package/dist/hooks/use-rqmii-sdk.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/provider/use-manager-lifecycle.d.ts +2 -3
- package/dist/provider/use-manager-lifecycle.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/ui/RqmiiAgentChat.d.ts +1 -1
- package/dist/ui/RqmiiAgentChat.d.ts.map +1 -1
- package/dist/ui/agent-data.d.ts +2 -8
- package/dist/ui/agent-data.d.ts.map +1 -1
- package/dist/ui/languages/list.d.ts.map +1 -1
- package/dist/ui/languages/text.d.ts.map +1 -1
- package/dist/ui/languages/translations/ar-eg.d.ts +4 -0
- package/dist/ui/languages/translations/ar-eg.d.ts.map +1 -0
- package/dist/ui/languages/translations/ar-sa.d.ts +4 -0
- package/dist/ui/languages/translations/ar-sa.d.ts.map +1 -0
- package/dist/ui.cjs +11 -11
- package/dist/ui.cjs.map +1 -1
- package/dist/ui.d.ts +1 -1
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +996 -935
- package/dist/ui.js.map +1 -1
- package/package.json +1 -1
- package/README.frameworks.md +0 -244
- package/README.md +0 -168
- package/README.simple.md +0 -114
- package/dist/RqmiiCloudAvatarPlayer-Bm730tzg.cjs.map +0 -1
- package/dist/RqmiiCloudAvatarPlayer-CldnIv4K.js.map +0 -1
package/package.json
CHANGED
package/README.frameworks.md
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
# Rqmii React Agent SDK - Framework Recipes
|
|
2
|
-
|
|
3
|
-
This guide shows integration patterns for Vite, Next.js, and CRA.
|
|
4
|
-
|
|
5
|
-
## 1. Vite
|
|
6
|
-
|
|
7
|
-
### Install
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install @rqmii_immersive/agent-react-sdk
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
### Env
|
|
14
|
-
|
|
15
|
-
`.env`:
|
|
16
|
-
|
|
17
|
-
```env
|
|
18
|
-
VITE_AGENT_API_URL=https://api.example.com
|
|
19
|
-
VITE_AGENT_WS_URL=wss://realtime.example.com
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### App Example
|
|
23
|
-
|
|
24
|
-
```jsx
|
|
25
|
-
import {
|
|
26
|
-
RqmiiAgentRoom,
|
|
27
|
-
useRqmiiMessages,
|
|
28
|
-
} from "@rqmii_immersive/agent-react-sdk";
|
|
29
|
-
|
|
30
|
-
function UI() {
|
|
31
|
-
const { sendTextMessage } = useRqmiiMessages();
|
|
32
|
-
return <button onClick={() => sendTextMessage("Hi")}>Send</button>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export default function App() {
|
|
36
|
-
return (
|
|
37
|
-
<RqmiiAgentRoom
|
|
38
|
-
wsUrl={import.meta.env.VITE_AGENT_WS_URL}
|
|
39
|
-
restUrl={import.meta.env.VITE_AGENT_API_URL}
|
|
40
|
-
session={{ mode: "initialize", apiKey: "YOUR_API_KEY", language: "en" }}
|
|
41
|
-
connect
|
|
42
|
-
>
|
|
43
|
-
<UI />
|
|
44
|
-
</RqmiiAgentRoom>
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## 2. Next.js (App Router)
|
|
50
|
-
|
|
51
|
-
Use client components for SDK usage.
|
|
52
|
-
|
|
53
|
-
### Install
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
npm install @rqmii_immersive/agent-react-sdk
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Env
|
|
60
|
-
|
|
61
|
-
`.env.local`:
|
|
62
|
-
|
|
63
|
-
```env
|
|
64
|
-
NEXT_PUBLIC_AGENT_API_URL=https://api.example.com
|
|
65
|
-
NEXT_PUBLIC_AGENT_WS_URL=wss://realtime.example.com
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### Client Component
|
|
69
|
-
|
|
70
|
-
`app/agent/page.jsx`:
|
|
71
|
-
|
|
72
|
-
```jsx
|
|
73
|
-
"use client";
|
|
74
|
-
|
|
75
|
-
import {
|
|
76
|
-
RqmiiAgentRoom,
|
|
77
|
-
useRqmiiConnection,
|
|
78
|
-
useRqmiiMessages,
|
|
79
|
-
} from "@rqmii_immersive/agent-react-sdk";
|
|
80
|
-
|
|
81
|
-
function UI() {
|
|
82
|
-
const { connectionState } = useRqmiiConnection();
|
|
83
|
-
const { messages, sendTextMessage } = useRqmiiMessages();
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<div>
|
|
87
|
-
<div>{connectionState}</div>
|
|
88
|
-
<button onClick={() => sendTextMessage("Hello")}>Send</button>
|
|
89
|
-
<pre>{JSON.stringify(messages, null, 2)}</pre>
|
|
90
|
-
</div>
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export default function AgentPage() {
|
|
95
|
-
return (
|
|
96
|
-
<RqmiiAgentRoom
|
|
97
|
-
wsUrl={process.env.NEXT_PUBLIC_AGENT_WS_URL}
|
|
98
|
-
restUrl={process.env.NEXT_PUBLIC_AGENT_API_URL}
|
|
99
|
-
session={{ mode: "initialize", apiKey: "YOUR_API_KEY", language: "en" }}
|
|
100
|
-
connect
|
|
101
|
-
>
|
|
102
|
-
<UI />
|
|
103
|
-
</RqmiiAgentRoom>
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### Next.js Notes
|
|
109
|
-
|
|
110
|
-
- Do not use SDK in server components.
|
|
111
|
-
- Keep all SDK consumers under `'use client'`.
|
|
112
|
-
- For cloud avatar player, render it only on client.
|
|
113
|
-
|
|
114
|
-
## 3. Create React App (CRA)
|
|
115
|
-
|
|
116
|
-
### Install
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
npm install @rqmii_immersive/agent-react-sdk
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Env
|
|
123
|
-
|
|
124
|
-
`.env`:
|
|
125
|
-
|
|
126
|
-
```env
|
|
127
|
-
REACT_APP_AGENT_API_URL=https://api.example.com
|
|
128
|
-
REACT_APP_AGENT_WS_URL=wss://realtime.example.com
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### App Example
|
|
132
|
-
|
|
133
|
-
```jsx
|
|
134
|
-
import {
|
|
135
|
-
RqmiiAgentRoom,
|
|
136
|
-
useRqmiiMessages,
|
|
137
|
-
} from "@rqmii_immersive/agent-react-sdk";
|
|
138
|
-
|
|
139
|
-
function UI() {
|
|
140
|
-
const { sendTextMessage } = useRqmiiMessages();
|
|
141
|
-
return <button onClick={() => sendTextMessage("Hello")}>Send</button>;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export default function App() {
|
|
145
|
-
return (
|
|
146
|
-
<RqmiiAgentRoom
|
|
147
|
-
wsUrl={process.env.REACT_APP_AGENT_WS_URL}
|
|
148
|
-
restUrl={process.env.REACT_APP_AGENT_API_URL}
|
|
149
|
-
session={{ mode: "initialize", apiKey: "YOUR_API_KEY", language: "en" }}
|
|
150
|
-
connect
|
|
151
|
-
>
|
|
152
|
-
<UI />
|
|
153
|
-
</RqmiiAgentRoom>
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
## 4. Common Recipes
|
|
159
|
-
|
|
160
|
-
### Cloud Avatar
|
|
161
|
-
|
|
162
|
-
```jsx
|
|
163
|
-
import {
|
|
164
|
-
RqmiiCloudAvatarPlayer,
|
|
165
|
-
useRqmiiAvatar,
|
|
166
|
-
} from "@rqmii_immersive/agent-react-sdk";
|
|
167
|
-
|
|
168
|
-
function AvatarPanel() {
|
|
169
|
-
const { cloudStreamState, isAvatarSpeaking } = useRqmiiAvatar();
|
|
170
|
-
return (
|
|
171
|
-
<>
|
|
172
|
-
<div>stream: {cloudStreamState}</div>
|
|
173
|
-
<div>speaking: {String(isAvatarSpeaking)}</div>
|
|
174
|
-
<RqmiiCloudAvatarPlayer muted={false} />
|
|
175
|
-
</>
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
### Desktop Avatar Join
|
|
181
|
-
|
|
182
|
-
```jsx
|
|
183
|
-
<RqmiiAgentRoom
|
|
184
|
-
wsUrl={WS_URL}
|
|
185
|
-
restUrl={REST_URL}
|
|
186
|
-
session={{ mode: "join_desktop", uniqueId: "A1B2C3" }}
|
|
187
|
-
connect
|
|
188
|
-
>
|
|
189
|
-
<UI />
|
|
190
|
-
</RqmiiAgentRoom>
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### Manual Provider Control
|
|
194
|
-
|
|
195
|
-
```jsx
|
|
196
|
-
import {
|
|
197
|
-
RqmiiAgentProvider,
|
|
198
|
-
useRqmiiConnection,
|
|
199
|
-
} from "@rqmii_immersive/agent-react-sdk";
|
|
200
|
-
|
|
201
|
-
function Controls() {
|
|
202
|
-
const { initializeSession, disconnect } = useRqmiiConnection();
|
|
203
|
-
return (
|
|
204
|
-
<>
|
|
205
|
-
<button
|
|
206
|
-
onClick={() => initializeSession({ apiKey: "KEY", language: "en" })}
|
|
207
|
-
>
|
|
208
|
-
Init
|
|
209
|
-
</button>
|
|
210
|
-
<button onClick={disconnect}>Disconnect</button>
|
|
211
|
-
</>
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
export default function App() {
|
|
216
|
-
return (
|
|
217
|
-
<RqmiiAgentProvider wsUrl={WS_URL} restUrl={REST_URL}>
|
|
218
|
-
<Controls />
|
|
219
|
-
</RqmiiAgentProvider>
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
## 5. Troubleshooting by Framework
|
|
225
|
-
|
|
226
|
-
### Vite
|
|
227
|
-
|
|
228
|
-
- Ensure env keys start with `VITE_`.
|
|
229
|
-
- Restart dev server after env changes.
|
|
230
|
-
|
|
231
|
-
### Next.js
|
|
232
|
-
|
|
233
|
-
- Ensure page/component is client-side (`'use client'`).
|
|
234
|
-
- Use `NEXT_PUBLIC_` env keys.
|
|
235
|
-
|
|
236
|
-
### CRA
|
|
237
|
-
|
|
238
|
-
- Ensure env keys start with `REACT_APP_`.
|
|
239
|
-
- Restart `npm start` after env changes.
|
|
240
|
-
|
|
241
|
-
## 6. Where to Read More
|
|
242
|
-
|
|
243
|
-
- Full technical docs: `README.md`
|
|
244
|
-
- Quick docs: `README.simple.md`
|
package/README.md
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
# @rqmii_immersive/agent-react-sdk
|
|
2
|
-
|
|
3
|
-
Standalone React SDK for Rqmii Agent realtime sessions. Version 4.0.0 — complete TypeScript rewrite with reducer-based state management and event emitter system.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @rqmii_immersive/agent-react-sdk
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
### Peer Dependencies
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm install react react-dom lucide-react
|
|
15
|
-
# Optional (for 3D orb):
|
|
16
|
-
npm install three @react-three/fiber @react-three/drei
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Quick Start
|
|
20
|
-
|
|
21
|
-
### Core Setup
|
|
22
|
-
|
|
23
|
-
```tsx
|
|
24
|
-
import { RqmiiAgentProvider, useRqmiiConnection, useRqmiiMessages } from '@rqmii_immersive/agent-react-sdk';
|
|
25
|
-
|
|
26
|
-
function App() {
|
|
27
|
-
return (
|
|
28
|
-
<RqmiiAgentProvider wsUrl="wss://your-server" restUrl="https://your-api">
|
|
29
|
-
<Chat />
|
|
30
|
-
</RqmiiAgentProvider>
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function Chat() {
|
|
35
|
-
const { initializeSession, isConnected } = useRqmiiConnection();
|
|
36
|
-
const { messages, sendTextMessage } = useRqmiiMessages();
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<div>
|
|
40
|
-
{messages.map(m => <div key={m.id}>{m.text}</div>)}
|
|
41
|
-
<button onClick={() => sendTextMessage("Hello")}>Send</button>
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### Using RqmiiAgentRoom (auto-connect)
|
|
48
|
-
|
|
49
|
-
```tsx
|
|
50
|
-
import { RqmiiAgentRoom, useRqmiiMessages } from '@rqmii_immersive/agent-react-sdk';
|
|
51
|
-
|
|
52
|
-
function App() {
|
|
53
|
-
return (
|
|
54
|
-
<RqmiiAgentRoom
|
|
55
|
-
wsUrl="wss://your-server"
|
|
56
|
-
restUrl="https://your-api"
|
|
57
|
-
session={{ apiKey: 'your-key', language: 'en' }}
|
|
58
|
-
>
|
|
59
|
-
<Chat />
|
|
60
|
-
</RqmiiAgentRoom>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Full Chat Widget
|
|
66
|
-
|
|
67
|
-
```tsx
|
|
68
|
-
import { RqmiiAgentChat } from '@rqmii_immersive/agent-react-sdk/ui';
|
|
69
|
-
|
|
70
|
-
function App() {
|
|
71
|
-
return (
|
|
72
|
-
<RqmiiAgentChat
|
|
73
|
-
wsUrl="wss://your-server"
|
|
74
|
-
restUrl="https://your-api"
|
|
75
|
-
publicChatId="your-chat-id"
|
|
76
|
-
/>
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
## Architecture
|
|
82
|
-
|
|
83
|
-
### Entry Points
|
|
84
|
-
|
|
85
|
-
- `@rqmii_immersive/agent-react-sdk` — Core: provider, hooks, types, constants
|
|
86
|
-
- `@rqmii_immersive/agent-react-sdk/ui` — UI components: chat widget, avatar player, orb
|
|
87
|
-
- `@rqmii_immersive/agent-react-sdk/style.css` — Chat widget styles
|
|
88
|
-
|
|
89
|
-
### State Management
|
|
90
|
-
|
|
91
|
-
State is managed via `useReducer` with a single `RqmiiState` shape. All mutations go through typed actions.
|
|
92
|
-
|
|
93
|
-
### Event System
|
|
94
|
-
|
|
95
|
-
The provider exposes an `events` EventEmitter for subscribing to lifecycle events:
|
|
96
|
-
|
|
97
|
-
```tsx
|
|
98
|
-
import { useRqmiiAgent } from '@rqmii_immersive/agent-react-sdk';
|
|
99
|
-
|
|
100
|
-
function Component() {
|
|
101
|
-
const { events } = useRqmiiAgent();
|
|
102
|
-
|
|
103
|
-
useEffect(() => {
|
|
104
|
-
const unsub = events.on('session:ready', (payload) => {
|
|
105
|
-
console.log('Session ready', payload);
|
|
106
|
-
});
|
|
107
|
-
return unsub;
|
|
108
|
-
}, []);
|
|
109
|
-
}
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
Available events: `session:ready`, `session:joined`, `session:terminated`, `session:expired`, `message:received`, `message:sent`, `audio:playing`, `audio:stopped`, `avatar:speaking`, `avatar:speaking_done`, `state:changed`, `connection:connected`, `connection:disconnected`, `connection:reconnecting`, `connection:failed`, `error`, `credits:exhausted`, `transcript`, `partial_transcript`, `interrupted`.
|
|
113
|
-
|
|
114
|
-
## API Reference
|
|
115
|
-
|
|
116
|
-
### RqmiiAgentProvider Props
|
|
117
|
-
|
|
118
|
-
| Prop | Type | Default | Description |
|
|
119
|
-
|------|------|---------|-------------|
|
|
120
|
-
| `wsUrl` | `string` | required | WebSocket server URL |
|
|
121
|
-
| `restUrl` | `string` | required | REST API base URL |
|
|
122
|
-
| `reconnectOptions` | `RqmiiReconnectOptions` | `{ enabled: true, maxAttempts: 8, initialDelayMs: 500, maxDelayMs: 5000, timeoutMs: 8000 }` | Reconnection config |
|
|
123
|
-
| `enableAudio` | `boolean` | `true` | Enable PCM audio playback |
|
|
124
|
-
| `pcmOptions` | `RqmiiPCMOptions` | `{ encoding: '16bitInt', channels: 1, sampleRate: 16000 }` | PCM player config |
|
|
125
|
-
| `debug` | `boolean` | `false` | Enable debug logging |
|
|
126
|
-
| `withCredentials` | `boolean` | `false` | Include cookies in CORS requests |
|
|
127
|
-
| `heartbeatIntervalSeconds` | `number` | `15` | Heartbeat interval |
|
|
128
|
-
| `onSessionExpired` | `(payload?) => void` | — | Callback |
|
|
129
|
-
| `onSessionTerminated` | `() => void` | — | Callback |
|
|
130
|
-
| `onError` | `(payload?) => void` | — | Callback |
|
|
131
|
-
| `onDisconnect` | `(reason?) => void` | — | Callback |
|
|
132
|
-
| `onReconnectSuccess` | `(payload?) => void` | — | Callback |
|
|
133
|
-
| `onReconnectFailed` | `(payload?) => void` | — | Callback |
|
|
134
|
-
|
|
135
|
-
### Hooks
|
|
136
|
-
|
|
137
|
-
| Hook | Returns |
|
|
138
|
-
|------|---------|
|
|
139
|
-
| `useRqmiiAgent()` | Full context value |
|
|
140
|
-
| `useRqmiiConnection()` | Connection state + session actions |
|
|
141
|
-
| `useRqmiiSession()` | Session state booleans |
|
|
142
|
-
| `useRqmiiMessages()` | Messages array + send/clear |
|
|
143
|
-
| `useRqmiiVoice()` | Audio controls + transcript |
|
|
144
|
-
| `useRqmiiAvatar()` | Avatar state + cloud stream |
|
|
145
|
-
| `useRqmiiAudioElement(ref)` | Attaches audio element |
|
|
146
|
-
| `useRqmiiPressToTalk(options)` | PTT recording |
|
|
147
|
-
| `useRqmiiVAD(options)` | Voice Activity Detection |
|
|
148
|
-
| `useRqmiiEvents(event, handler, deps)` | Event subscription |
|
|
149
|
-
|
|
150
|
-
## Breaking Changes from v3
|
|
151
|
-
|
|
152
|
-
1. **`useRqmiiSessionState` renamed to `useRqmiiSession`** — The hook is now `useRqmiiSession()`.
|
|
153
|
-
|
|
154
|
-
2. **Context value spread** — The context value now includes all state fields directly (no nested `state` object). Access `ctx.messages` instead of `ctx.state.messages`.
|
|
155
|
-
|
|
156
|
-
3. **Event emitter replaces some callbacks** — While legacy callbacks (`onSessionExpired`, etc.) still work, the preferred approach is using `events.on()`.
|
|
157
|
-
|
|
158
|
-
4. **TypeScript only** — All source is now `.ts`/`.tsx`. JavaScript consumers get full type inference via bundled `.d.ts` files.
|
|
159
|
-
|
|
160
|
-
5. **`terminateSession` return type simplified** — Now returns `Promise<{ success: boolean }>` instead of the previous shape with `skipped` and `error` fields.
|
|
161
|
-
|
|
162
|
-
6. **`useRqmiiVAD` return** — Added `isErrored` field to match the VAD library's state.
|
|
163
|
-
|
|
164
|
-
7. **Internal module structure changed** — If you were importing from internal paths (e.g., `@rqmii_immersive/agent-react-sdk/react/core/...`), those paths no longer exist. Use the public exports only.
|
|
165
|
-
|
|
166
|
-
## License
|
|
167
|
-
|
|
168
|
-
UNLICENSED
|
package/README.simple.md
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
# Rqmii React Agent SDK (Simple Guide)
|
|
2
|
-
|
|
3
|
-
Minimal guide to integrate quickly.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @rqmii_immersive/agent-react-sdk
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Required Config
|
|
12
|
-
|
|
13
|
-
You need:
|
|
14
|
-
|
|
15
|
-
- `restUrl` -> REST API URL
|
|
16
|
-
- `wsUrl` -> realtime Socket.IO URL
|
|
17
|
-
|
|
18
|
-
Example env:
|
|
19
|
-
|
|
20
|
-
```env
|
|
21
|
-
VITE_AGENT_API_URL=https://api.example.com
|
|
22
|
-
VITE_AGENT_WS_URL=wss://realtime.example.com
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Basic Usage
|
|
26
|
-
|
|
27
|
-
```jsx
|
|
28
|
-
import {
|
|
29
|
-
RqmiiAgentRoom,
|
|
30
|
-
useRqmiiConnection,
|
|
31
|
-
useRqmiiMessages,
|
|
32
|
-
useRqmiiPressToTalk,
|
|
33
|
-
} from "@rqmii_immersive/agent-react-sdk";
|
|
34
|
-
|
|
35
|
-
function ChatUI() {
|
|
36
|
-
const { connectionState, isSessionReady, error } = useRqmiiConnection();
|
|
37
|
-
const { messages, sendTextMessage } = useRqmiiMessages();
|
|
38
|
-
const { eventHandlers, isRecording } = useRqmiiPressToTalk();
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<div>
|
|
42
|
-
<div>{connectionState}</div>
|
|
43
|
-
<div>ready: {String(isSessionReady)}</div>
|
|
44
|
-
{error && <div style={{ color: "red" }}>{error}</div>}
|
|
45
|
-
|
|
46
|
-
<button onClick={() => sendTextMessage("Hello")}>Send</button>
|
|
47
|
-
<button {...eventHandlers}>
|
|
48
|
-
{isRecording ? "Recording..." : "Hold to Talk"}
|
|
49
|
-
</button>
|
|
50
|
-
<pre>{JSON.stringify(messages, null, 2)}</pre>
|
|
51
|
-
</div>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export default function App() {
|
|
56
|
-
return (
|
|
57
|
-
<RqmiiAgentRoom
|
|
58
|
-
wsUrl={import.meta.env.VITE_AGENT_WS_URL}
|
|
59
|
-
restUrl={import.meta.env.VITE_AGENT_API_URL}
|
|
60
|
-
session={{ mode: "initialize", apiKey: "YOUR_API_KEY", language: "en" }}
|
|
61
|
-
connect
|
|
62
|
-
>
|
|
63
|
-
<ChatUI />
|
|
64
|
-
</RqmiiAgentRoom>
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## Cloud Avatar
|
|
70
|
-
|
|
71
|
-
```jsx
|
|
72
|
-
import {
|
|
73
|
-
RqmiiCloudAvatarPlayer,
|
|
74
|
-
useRqmiiAvatar,
|
|
75
|
-
} from "@rqmii_immersive/agent-react-sdk";
|
|
76
|
-
|
|
77
|
-
function CloudAvatarUI() {
|
|
78
|
-
const { isAvatarSpeaking, cloudStreamState } = useRqmiiAvatar();
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<>
|
|
82
|
-
<div>speaking: {String(isAvatarSpeaking)}</div>
|
|
83
|
-
<div>stream: {cloudStreamState}</div>
|
|
84
|
-
<RqmiiCloudAvatarPlayer muted={false} />
|
|
85
|
-
</>
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Desktop Avatar Join
|
|
91
|
-
|
|
92
|
-
```jsx
|
|
93
|
-
<RqmiiAgentRoom
|
|
94
|
-
wsUrl={WS_URL}
|
|
95
|
-
restUrl={REST_URL}
|
|
96
|
-
session={{ mode: "join_desktop", uniqueId: "A1B2C3" }}
|
|
97
|
-
connect
|
|
98
|
-
>
|
|
99
|
-
<YourUI />
|
|
100
|
-
</RqmiiAgentRoom>
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## Voice Input / Output
|
|
104
|
-
|
|
105
|
-
- send mic chunks: `sendAudioChunk(chunk)`
|
|
106
|
-
- end utterance: `endAudioStream()`
|
|
107
|
-
- interrupt: `interrupt()`
|
|
108
|
-
- SDK plays output audio internally using `pcm-stream-player`
|
|
109
|
-
|
|
110
|
-
## Notes
|
|
111
|
-
|
|
112
|
-
- Reconnection is built-in and follows backend reconnect credential flow.
|
|
113
|
-
- Avatar speaking state comes from backend avatar events.
|
|
114
|
-
- For full docs, see `README.md`.
|