@centive/aria-sdk 0.8.0 → 0.8.2
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/README.md +65 -398
- package/dist/components/AriaStandaloneUI.d.ts.map +1 -1
- package/dist/index.d.ts +48 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1259 -2683
- package/dist/index.js.map +1 -1
- package/dist/lib/AriaSessionManager.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Aria
|
|
1
|
+
# Aria SDK
|
|
2
2
|
|
|
3
|
-
A production-ready
|
|
3
|
+
A production-ready SDK for integrating [Anam AI](https://docs.anam.ai/) into your web application. Simple initialization, automatic session management, and a beautiful AI assistant interface.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@centive/aria-sdk)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -43,19 +43,19 @@ npm install react@^18.0.0 react-dom@^18.0.0 @anam-ai/js-sdk@^4.7.0
|
|
|
43
43
|
| **Tool Call Indicators** | Visual feedback when AI executes functions |
|
|
44
44
|
| **Theme Support** | Light and dark themes |
|
|
45
45
|
|
|
46
|
-
## Configuration
|
|
46
|
+
## Configuration
|
|
47
47
|
|
|
48
48
|
```typescript
|
|
49
|
-
|
|
49
|
+
Aria.init({
|
|
50
50
|
// Required
|
|
51
|
-
websocketUrl: string
|
|
52
|
-
userId: string
|
|
51
|
+
websocketUrl: string, // Your backend WebSocket URL
|
|
52
|
+
userId: string, // Unique user identifier
|
|
53
53
|
|
|
54
54
|
// Optional
|
|
55
|
-
theme?: 'light' | 'dark'
|
|
56
|
-
triggerLabel?: string
|
|
57
|
-
onError?: (error: Error) => void
|
|
58
|
-
}
|
|
55
|
+
theme?: 'light' | 'dark', // UI theme (default: 'light')
|
|
56
|
+
triggerLabel?: string, // Button label (default: 'Talk to Aria')
|
|
57
|
+
onError?: (error: Error) => void, // Error callback
|
|
58
|
+
});
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
### Example with All Options
|
|
@@ -67,19 +67,32 @@ Aria.init({
|
|
|
67
67
|
websocketUrl: 'wss://api.example.com/ws',
|
|
68
68
|
userId: 'user_123',
|
|
69
69
|
theme: 'dark',
|
|
70
|
-
triggerLabel: '
|
|
70
|
+
triggerLabel: 'Need Help?',
|
|
71
71
|
onError: (error) => {
|
|
72
72
|
console.error('Aria SDK error:', error);
|
|
73
|
-
// Send to your error tracking service
|
|
74
73
|
},
|
|
75
74
|
});
|
|
76
75
|
```
|
|
77
76
|
|
|
78
|
-
##
|
|
77
|
+
## API Reference
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
| Method | Description |
|
|
80
|
+
|--------|-------------|
|
|
81
|
+
| `Aria.init(config)` | Initialize the SDK |
|
|
82
|
+
| `Aria.open(mode?)` | Open assistant widget (`'user'` or `'websocket'`) |
|
|
83
|
+
| `Aria.close()` | Close assistant widget |
|
|
84
|
+
| `Aria.minimize()` | Minimize to compact state |
|
|
85
|
+
| `Aria.maximize()` | Restore from minimized |
|
|
86
|
+
| `Aria.destroy()` | Cleanup and remove SDK |
|
|
87
|
+
| `Aria.isInitialized()` | Check if SDK is initialized |
|
|
88
|
+
| `Aria.isOpen()` | Check if widget is open |
|
|
89
|
+
| `Aria.isConnected()` | Check WebSocket connection |
|
|
90
|
+
| `Aria.getSessionId()` | Get current session ID |
|
|
91
|
+
| `Aria.refreshSession()` | Manually refresh session |
|
|
92
|
+
|
|
93
|
+
### Programmatic Control
|
|
82
94
|
|
|
95
|
+
```typescript
|
|
83
96
|
// Open the assistant
|
|
84
97
|
Aria.open();
|
|
85
98
|
|
|
@@ -89,44 +102,28 @@ Aria.open('websocket');
|
|
|
89
102
|
// Close the assistant
|
|
90
103
|
Aria.close();
|
|
91
104
|
|
|
92
|
-
// Minimize
|
|
105
|
+
// Minimize/maximize
|
|
93
106
|
Aria.minimize();
|
|
94
|
-
|
|
95
|
-
// Maximize from minimized state
|
|
96
107
|
Aria.maximize();
|
|
97
108
|
|
|
98
109
|
// Check status
|
|
99
|
-
Aria.
|
|
100
|
-
Aria.
|
|
101
|
-
|
|
102
|
-
Aria.getSessionId(); // string | null
|
|
110
|
+
if (Aria.isConnected()) {
|
|
111
|
+
console.log('Session ID:', Aria.getSessionId());
|
|
112
|
+
}
|
|
103
113
|
|
|
104
|
-
// Cleanup
|
|
114
|
+
// Cleanup when done
|
|
105
115
|
Aria.destroy();
|
|
106
116
|
```
|
|
107
117
|
|
|
108
|
-
---
|
|
109
|
-
|
|
110
118
|
## Backend Requirements
|
|
111
119
|
|
|
112
|
-
The SDK connects to your backend via WebSocket. Your backend
|
|
113
|
-
|
|
114
|
-
### 1. WebSocket Server
|
|
115
|
-
|
|
116
|
-
Provide a WebSocket endpoint that the SDK connects to.
|
|
117
|
-
|
|
118
|
-
```
|
|
119
|
-
wss://your-server.com/ws
|
|
120
|
-
```
|
|
120
|
+
The SDK connects to your backend via WebSocket. Your backend handles:
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
1. **User Authentication** - Validate the connecting user
|
|
123
|
+
2. **Session Token Generation** - Create Anam AI sessions
|
|
124
|
+
3. **Persona Configuration** - Control AI behavior server-side (avatar, voice, LLM, system prompt)
|
|
123
125
|
|
|
124
|
-
|
|
125
|
-
1. Authenticate the user
|
|
126
|
-
2. Call the Anam AI API to create a session
|
|
127
|
-
3. Return the session token to the SDK
|
|
128
|
-
|
|
129
|
-
**Expected Response Format:**
|
|
126
|
+
### Expected Response Format
|
|
130
127
|
|
|
131
128
|
```json
|
|
132
129
|
{
|
|
@@ -135,21 +132,13 @@ When a user connects, your backend should:
|
|
|
135
132
|
"session_data": {
|
|
136
133
|
"session_id": "sess_abc123",
|
|
137
134
|
"token": "eyJhbGciOiJIUzI1NiIs...",
|
|
138
|
-
"expires_at": "2026-01-
|
|
135
|
+
"expires_at": "2026-01-27T12:00:00Z"
|
|
139
136
|
},
|
|
140
137
|
"time_taken": 1234
|
|
141
138
|
}
|
|
142
139
|
```
|
|
143
140
|
|
|
144
|
-
###
|
|
145
|
-
|
|
146
|
-
**Important:** Persona configuration (avatar, voice, LLM, system prompt) is controlled by your backend, not the frontend. This provides:
|
|
147
|
-
|
|
148
|
-
- **Security**: Frontend cannot manipulate AI behavior
|
|
149
|
-
- **Flexibility**: Change personas based on user roles, context, or A/B testing
|
|
150
|
-
- **Centralization**: Manage all configurations in one place
|
|
151
|
-
|
|
152
|
-
**Backend Example (Node.js):**
|
|
141
|
+
### Backend Example (Node.js)
|
|
153
142
|
|
|
154
143
|
```javascript
|
|
155
144
|
const WebSocket = require('ws');
|
|
@@ -162,7 +151,6 @@ wss.on('connection', (ws) => {
|
|
|
162
151
|
const data = JSON.parse(message);
|
|
163
152
|
|
|
164
153
|
if (data.user_trigger !== undefined) {
|
|
165
|
-
// Create Anam session with persona config
|
|
166
154
|
const session = await createAnamSession(data.userId);
|
|
167
155
|
|
|
168
156
|
ws.send(JSON.stringify({
|
|
@@ -180,93 +168,31 @@ wss.on('connection', (ws) => {
|
|
|
180
168
|
});
|
|
181
169
|
|
|
182
170
|
async function createAnamSession(userId) {
|
|
183
|
-
// Get persona config based on user context
|
|
184
|
-
const personaConfig = getPersonaForUser(userId);
|
|
185
|
-
|
|
186
171
|
const response = await axios.post('https://api.anam.ai/v1/sessions', {
|
|
187
|
-
persona:
|
|
172
|
+
persona: {
|
|
173
|
+
name: 'Aria',
|
|
174
|
+
avatarId: 'your-avatar-id',
|
|
175
|
+
voiceId: 'your-voice-id',
|
|
176
|
+
llmId: 'your-llm-id',
|
|
177
|
+
systemPrompt: 'You are Aria, a helpful AI assistant.',
|
|
178
|
+
},
|
|
188
179
|
}, {
|
|
189
180
|
headers: { 'Authorization': `Bearer ${process.env.ANAM_API_KEY}` }
|
|
190
181
|
});
|
|
191
182
|
|
|
192
183
|
return response.data;
|
|
193
184
|
}
|
|
194
|
-
|
|
195
|
-
function getPersonaForUser(userId) {
|
|
196
|
-
// Your business logic here
|
|
197
|
-
return {
|
|
198
|
-
name: 'Aria',
|
|
199
|
-
avatarId: 'your-avatar-id',
|
|
200
|
-
voiceId: 'your-voice-id',
|
|
201
|
-
llmId: 'your-llm-id',
|
|
202
|
-
systemPrompt: 'You are Aria, a helpful AI assistant.',
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
185
|
```
|
|
206
186
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
**Frontend → Backend:**
|
|
210
|
-
|
|
211
|
-
| Message | Description |
|
|
212
|
-
|---------|-------------|
|
|
213
|
-
| `{ user_trigger: true }` | User clicked trigger button |
|
|
214
|
-
| `{ user_trigger: false }` | Auto-preload session |
|
|
215
|
-
| `{ type: 'message_history', ... }` | Conversation history |
|
|
216
|
-
| `{ type: 'session_end', ... }` | User ended session |
|
|
217
|
-
|
|
218
|
-
**Backend → Frontend:**
|
|
219
|
-
|
|
220
|
-
| Message | Description |
|
|
221
|
-
|---------|-------------|
|
|
222
|
-
| Session response | Token and session data |
|
|
223
|
-
| `{ type: 'trigger_event', data: {...} }` | Open assistant in center mode |
|
|
224
|
-
| Acknowledgments | Confirm message receipt |
|
|
225
|
-
|
|
226
|
-
### 5. Trigger Events (Optional)
|
|
227
|
-
|
|
228
|
-
Send events from your backend to open the assistant automatically:
|
|
229
|
-
|
|
230
|
-
```json
|
|
231
|
-
{
|
|
232
|
-
"type": "trigger_event",
|
|
233
|
-
"data": {
|
|
234
|
-
"message": "Incoming support request",
|
|
235
|
-
"caller": "John Doe",
|
|
236
|
-
"eventType": "support_call"
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
---
|
|
242
|
-
|
|
243
|
-
## What the SDK Handles Automatically
|
|
244
|
-
|
|
245
|
-
You don't need to manage any of these - the SDK handles them internally:
|
|
246
|
-
|
|
247
|
-
| Feature | How It Works |
|
|
248
|
-
|---------|--------------|
|
|
249
|
-
| **WebSocket Connection** | Connects on `init()`, maintains connection |
|
|
250
|
-
| **Auto-Reconnect** | Exponential backoff (1s → 30s max), up to 10 attempts |
|
|
251
|
-
| **Session Refresh** | Refreshes 5 minutes before expiry |
|
|
252
|
-
| **Tab Visibility** | Only refreshes when tab is active |
|
|
253
|
-
| **Session Persistence** | Video and session survive page navigation when SDK is at root level |
|
|
254
|
-
| **Error Recovery** | Automatic retries with backoff |
|
|
255
|
-
| **UI Rendering** | Mounts trigger button and widget to DOM |
|
|
256
|
-
|
|
257
|
-
---
|
|
187
|
+
## Session Persistence
|
|
258
188
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
For the video session to persist across page navigation (no black screen when switching pages), ensure the SDK is initialized at the **root level** of your application, outside of any route-specific components.
|
|
262
|
-
|
|
263
|
-
### Correct Placement
|
|
189
|
+
For video sessions to persist across page navigation, initialize the SDK at the **root level** of your application:
|
|
264
190
|
|
|
265
191
|
```tsx
|
|
266
|
-
// App.tsx
|
|
192
|
+
// App.tsx - Correct placement
|
|
267
193
|
import { Aria } from '@centive/aria-sdk';
|
|
268
194
|
|
|
269
|
-
// Initialize once at app startup
|
|
195
|
+
// Initialize once at app startup
|
|
270
196
|
Aria.init({
|
|
271
197
|
websocketUrl: 'wss://your-server.com/ws',
|
|
272
198
|
userId: 'user_123',
|
|
@@ -278,101 +204,34 @@ function App() {
|
|
|
278
204
|
<Routes>
|
|
279
205
|
<Route path="/" element={<HomePage />} />
|
|
280
206
|
<Route path="/dashboard" element={<DashboardPage />} />
|
|
281
|
-
<Route path="/settings" element={<SettingsPage />} />
|
|
282
|
-
{/* SDK persists across all routes - video stays connected */}
|
|
283
207
|
</Routes>
|
|
284
208
|
</Router>
|
|
285
209
|
);
|
|
286
210
|
}
|
|
287
211
|
```
|
|
288
212
|
|
|
289
|
-
|
|
213
|
+
## Bundler Configuration
|
|
290
214
|
|
|
291
|
-
|
|
292
|
-
// DON'T initialize inside route components - this will reinitialize on every navigation!
|
|
293
|
-
function SettingsPage() {
|
|
294
|
-
useEffect(() => {
|
|
295
|
-
Aria.init({ ... }); // Bad - reinitializes when navigating to this page
|
|
296
|
-
}, []);
|
|
297
|
-
|
|
298
|
-
return <div>Settings</div>;
|
|
299
|
-
}
|
|
300
|
-
```
|
|
215
|
+
The `@anam-ai/js-sdk` requires a Buffer polyfill. See the [Integration Guide](./INTEGRATION.md#3-configure-your-bundler) for Vite, Webpack, and Next.js configurations.
|
|
301
216
|
|
|
302
|
-
|
|
217
|
+
**Quick fix for Vite:**
|
|
303
218
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
```tsx
|
|
307
|
-
// Correct - Provider at root, outside Router
|
|
308
|
-
function App() {
|
|
309
|
-
return (
|
|
310
|
-
<AriaProvider config={config}>
|
|
311
|
-
<Router>
|
|
312
|
-
<Routes>
|
|
313
|
-
<Route path="/" element={<HomePage />} />
|
|
314
|
-
<Route path="/settings" element={<SettingsPage />} />
|
|
315
|
-
</Routes>
|
|
316
|
-
</Router>
|
|
317
|
-
</AriaProvider>
|
|
318
|
-
);
|
|
319
|
-
}
|
|
219
|
+
```bash
|
|
220
|
+
npm install buffer
|
|
320
221
|
```
|
|
321
222
|
|
|
322
|
-
```
|
|
323
|
-
//
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
<AriaProvider config={config}>
|
|
327
|
-
<SettingsContent />
|
|
328
|
-
</AriaProvider>
|
|
329
|
-
);
|
|
330
|
-
}
|
|
223
|
+
```typescript
|
|
224
|
+
// main.tsx (at the very top)
|
|
225
|
+
import { Buffer } from 'buffer';
|
|
226
|
+
globalThis.Buffer = Buffer;
|
|
331
227
|
```
|
|
332
228
|
|
|
333
|
-
---
|
|
334
|
-
|
|
335
229
|
## Security Best Practices
|
|
336
230
|
|
|
337
|
-
### Do
|
|
338
|
-
|
|
339
231
|
- Use secure WebSocket connections (`wss://`) in production
|
|
340
|
-
- Validate user IDs on your backend
|
|
341
232
|
- Store Anam API keys only on the backend
|
|
342
|
-
-
|
|
343
|
-
-
|
|
344
|
-
|
|
345
|
-
### Don't
|
|
346
|
-
|
|
347
|
-
- Expose Anam API keys in frontend code
|
|
348
|
-
- Trust user-provided data without validation
|
|
349
|
-
- Allow arbitrary persona configuration from frontend
|
|
350
|
-
|
|
351
|
-
---
|
|
352
|
-
|
|
353
|
-
## Legacy React Provider API
|
|
354
|
-
|
|
355
|
-
For existing applications using the Provider pattern, it's still supported but deprecated:
|
|
356
|
-
|
|
357
|
-
```tsx
|
|
358
|
-
// Deprecated - will be removed in v2.0
|
|
359
|
-
import { AriaProvider } from '@centive/aria-sdk';
|
|
360
|
-
|
|
361
|
-
function App() {
|
|
362
|
-
return (
|
|
363
|
-
<AriaProvider config={{
|
|
364
|
-
websocketUrl: 'ws://localhost:8000/ws',
|
|
365
|
-
userId: 'user_123',
|
|
366
|
-
}}>
|
|
367
|
-
<YourApp />
|
|
368
|
-
</AriaProvider>
|
|
369
|
-
);
|
|
370
|
-
}
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
**Migration:** Replace `AriaProvider` with `Aria.init()` for simpler integration.
|
|
374
|
-
|
|
375
|
-
---
|
|
233
|
+
- Validate user IDs on your backend
|
|
234
|
+
- Never expose API keys in frontend code
|
|
376
235
|
|
|
377
236
|
## Browser Support
|
|
378
237
|
|
|
@@ -383,209 +242,17 @@ function App() {
|
|
|
383
242
|
|
|
384
243
|
Requires WebRTC support for video streaming.
|
|
385
244
|
|
|
386
|
-
---
|
|
387
|
-
|
|
388
|
-
## Troubleshooting
|
|
389
|
-
|
|
390
|
-
### "The requested module 'buffer' does not provide an export named 'Buffer'"
|
|
391
|
-
|
|
392
|
-
This error occurs because `@anam-ai/js-sdk` uses Node.js's `Buffer` which isn't available in browser environments by default.
|
|
393
|
-
|
|
394
|
-
**Fix for Vite users:**
|
|
395
|
-
|
|
396
|
-
1. Install the buffer polyfill:
|
|
397
|
-
|
|
398
|
-
```bash
|
|
399
|
-
npm install buffer
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
2. Create or update your `vite.config.ts`:
|
|
403
|
-
|
|
404
|
-
```typescript
|
|
405
|
-
import { defineConfig } from 'vite'
|
|
406
|
-
import react from '@vitejs/plugin-react'
|
|
407
|
-
|
|
408
|
-
export default defineConfig({
|
|
409
|
-
plugins: [react()],
|
|
410
|
-
define: {
|
|
411
|
-
global: 'globalThis',
|
|
412
|
-
},
|
|
413
|
-
resolve: {
|
|
414
|
-
alias: {
|
|
415
|
-
buffer: 'buffer/',
|
|
416
|
-
},
|
|
417
|
-
},
|
|
418
|
-
optimizeDeps: {
|
|
419
|
-
include: ['buffer'],
|
|
420
|
-
esbuildOptions: {
|
|
421
|
-
define: {
|
|
422
|
-
global: 'globalThis',
|
|
423
|
-
},
|
|
424
|
-
},
|
|
425
|
-
},
|
|
426
|
-
})
|
|
427
|
-
```
|
|
428
|
-
|
|
429
|
-
3. Add the Buffer polyfill to your app's entry point (e.g., `main.tsx` or `index.tsx`):
|
|
430
|
-
|
|
431
|
-
```typescript
|
|
432
|
-
// Add this at the very top of your entry file, before any other imports
|
|
433
|
-
import { Buffer } from 'buffer';
|
|
434
|
-
globalThis.Buffer = Buffer;
|
|
435
|
-
|
|
436
|
-
// Then your other imports
|
|
437
|
-
import React from 'react';
|
|
438
|
-
import ReactDOM from 'react-dom/client';
|
|
439
|
-
// ...
|
|
440
|
-
```
|
|
441
|
-
|
|
442
|
-
**Fix for Webpack users:**
|
|
443
|
-
|
|
444
|
-
1. Install the buffer polyfill:
|
|
445
|
-
|
|
446
|
-
```bash
|
|
447
|
-
npm install buffer
|
|
448
|
-
```
|
|
449
|
-
|
|
450
|
-
2. Add to your `webpack.config.js`:
|
|
451
|
-
|
|
452
|
-
```javascript
|
|
453
|
-
const webpack = require('webpack');
|
|
454
|
-
|
|
455
|
-
module.exports = {
|
|
456
|
-
// ... other config
|
|
457
|
-
resolve: {
|
|
458
|
-
fallback: {
|
|
459
|
-
buffer: require.resolve('buffer/'),
|
|
460
|
-
},
|
|
461
|
-
},
|
|
462
|
-
plugins: [
|
|
463
|
-
new webpack.ProvidePlugin({
|
|
464
|
-
Buffer: ['buffer', 'Buffer'],
|
|
465
|
-
}),
|
|
466
|
-
],
|
|
467
|
-
};
|
|
468
|
-
```
|
|
469
|
-
|
|
470
|
-
**Fix for Next.js users:**
|
|
471
|
-
|
|
472
|
-
1. Install the buffer polyfill:
|
|
473
|
-
|
|
474
|
-
```bash
|
|
475
|
-
npm install buffer
|
|
476
|
-
```
|
|
477
|
-
|
|
478
|
-
2. Update your `next.config.js`:
|
|
479
|
-
|
|
480
|
-
```javascript
|
|
481
|
-
/** @type {import('next').NextConfig} */
|
|
482
|
-
const nextConfig = {
|
|
483
|
-
webpack: (config) => {
|
|
484
|
-
config.resolve.fallback = {
|
|
485
|
-
...config.resolve.fallback,
|
|
486
|
-
buffer: require.resolve('buffer/'),
|
|
487
|
-
};
|
|
488
|
-
return config;
|
|
489
|
-
},
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
module.exports = nextConfig;
|
|
493
|
-
```
|
|
494
|
-
|
|
495
|
-
3. Add to your `_app.tsx` or root layout:
|
|
496
|
-
|
|
497
|
-
```typescript
|
|
498
|
-
import { Buffer } from 'buffer';
|
|
499
|
-
if (typeof window !== 'undefined') {
|
|
500
|
-
globalThis.Buffer = Buffer;
|
|
501
|
-
}
|
|
502
|
-
```
|
|
503
|
-
|
|
504
|
-
---
|
|
505
|
-
|
|
506
|
-
### "WebSocket connection failed"
|
|
507
|
-
|
|
508
|
-
- Check that your backend WebSocket server is running
|
|
509
|
-
- Verify the `websocketUrl` is correct
|
|
510
|
-
- Check browser console for CORS errors
|
|
511
|
-
|
|
512
|
-
### "Session token expired"
|
|
513
|
-
|
|
514
|
-
- The SDK auto-refreshes tokens, but if you see this:
|
|
515
|
-
- Check your backend is returning valid `expires_at` timestamps
|
|
516
|
-
- Ensure your Anam API key is valid
|
|
517
|
-
|
|
518
|
-
### "Not initialized" errors
|
|
519
|
-
|
|
520
|
-
- Call `Aria.init()` before using other methods
|
|
521
|
-
- Check that `init()` completed without errors
|
|
522
|
-
|
|
523
|
-
### UI not appearing
|
|
524
|
-
|
|
525
|
-
- Ensure you're not blocking the SDK's DOM elements with CSS
|
|
526
|
-
- Check browser console for React rendering errors
|
|
527
|
-
|
|
528
|
-
### "Cannot read properties of undefined (reading 'S')" error
|
|
529
|
-
|
|
530
|
-
This error typically occurs when the `@anam-ai/js-sdk` package isn't properly configured in your bundler.
|
|
531
|
-
|
|
532
|
-
**For Vite users**, add the following to your `vite.config.ts`:
|
|
533
|
-
|
|
534
|
-
```typescript
|
|
535
|
-
import { defineConfig } from 'vite'
|
|
536
|
-
import react from '@vitejs/plugin-react'
|
|
537
|
-
|
|
538
|
-
export default defineConfig({
|
|
539
|
-
plugins: [react()],
|
|
540
|
-
optimizeDeps: {
|
|
541
|
-
exclude: ['@anam-ai/js-sdk']
|
|
542
|
-
},
|
|
543
|
-
build: {
|
|
544
|
-
commonjsOptions: {
|
|
545
|
-
exclude: ['@anam-ai/js-sdk']
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
})
|
|
549
|
-
```
|
|
550
|
-
|
|
551
|
-
**For Webpack users**, you may need to add `@anam-ai/js-sdk` to your externals or configure it as a non-bundled dependency.
|
|
552
|
-
|
|
553
|
-
---
|
|
554
|
-
|
|
555
|
-
## API Reference
|
|
556
|
-
|
|
557
|
-
### Aria (Static Class)
|
|
558
|
-
|
|
559
|
-
| Method | Description |
|
|
560
|
-
|--------|-------------|
|
|
561
|
-
| `init(config)` | Initialize the SDK |
|
|
562
|
-
| `destroy()` | Cleanup and remove SDK |
|
|
563
|
-
| `open(mode?)` | Open assistant widget |
|
|
564
|
-
| `close()` | Close assistant widget |
|
|
565
|
-
| `minimize()` | Minimize to compact state |
|
|
566
|
-
| `maximize()` | Restore from minimized |
|
|
567
|
-
| `isInitialized()` | Check if SDK is initialized |
|
|
568
|
-
| `isOpen()` | Check if widget is open |
|
|
569
|
-
| `isConnected()` | Check WebSocket connection |
|
|
570
|
-
| `getSessionId()` | Get current session ID |
|
|
571
|
-
| `refreshSession()` | Manually refresh session |
|
|
572
|
-
|
|
573
|
-
---
|
|
574
|
-
|
|
575
245
|
## Documentation
|
|
576
246
|
|
|
577
|
-
- [
|
|
247
|
+
- [Integration Guide](./INTEGRATION.md) - Complete integration documentation
|
|
578
248
|
- [WebSocket Events](./WEBSOCKET_EVENTS.md) - Message specifications
|
|
579
|
-
- [
|
|
580
|
-
|
|
581
|
-
---
|
|
249
|
+
- [Type Reference](./TYPE_REFERENCE.md) - TypeScript types
|
|
250
|
+
- [Anam AI Docs](https://docs.anam.ai/) - Platform documentation
|
|
582
251
|
|
|
583
252
|
## License
|
|
584
253
|
|
|
585
254
|
MIT © Centive
|
|
586
255
|
|
|
587
|
-
---
|
|
588
|
-
|
|
589
256
|
## Support
|
|
590
257
|
|
|
591
258
|
- [GitHub Issues](https://github.com/centive/aria-sdk/issues)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AriaStandaloneUI.d.ts","sourceRoot":"","sources":["../../src/components/AriaStandaloneUI.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAA4C,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAgB1E,OAAO,KAAK,EAOV,KAAK,EACN,MAAM,SAAS,CAAC;AAOjB,UAAU,qBAAqB;IAC7B,KAAK,EAAE,KAAK,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,WAAW,CAAC;CACxB;AAED,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"AriaStandaloneUI.d.ts","sourceRoot":"","sources":["../../src/components/AriaStandaloneUI.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAA4C,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAgB1E,OAAO,KAAK,EAOV,KAAK,EACN,MAAM,SAAS,CAAC;AAOjB,UAAU,qBAAqB;IAC7B,KAAK,EAAE,KAAK,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,WAAW,CAAC;CACxB;AAED,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAmhBtD,CAAC;AAu5BF,eAAe,gBAAgB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,52 @@
|
|
|
1
1
|
import './lib-styles.css';
|
|
2
|
+
/**
|
|
3
|
+
* Main entry point for the Aria SDK.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { Aria } from '@centive/aria-sdk';
|
|
8
|
+
*
|
|
9
|
+
* // Initialize the SDK
|
|
10
|
+
* Aria.init({
|
|
11
|
+
* websocketUrl: 'wss://your-server.com/ws',
|
|
12
|
+
* userId: 'user_123',
|
|
13
|
+
* theme: 'light',
|
|
14
|
+
* onError: (err) => console.error(err),
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // Programmatic control
|
|
18
|
+
* Aria.open(); // Open the assistant
|
|
19
|
+
* Aria.close(); // Close the assistant
|
|
20
|
+
* Aria.minimize(); // Minimize to compact state
|
|
21
|
+
* Aria.maximize(); // Restore from minimized
|
|
22
|
+
* Aria.destroy(); // Cleanup when done
|
|
23
|
+
*
|
|
24
|
+
* // Status checks
|
|
25
|
+
* Aria.isInitialized(); // true/false
|
|
26
|
+
* Aria.isOpen(); // true/false
|
|
27
|
+
* Aria.isConnected(); // true/false
|
|
28
|
+
* Aria.getSessionId(); // string | null
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
2
31
|
export { AriaCore as Aria } from './lib/AriaCore';
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export { Badge } from './components/ui/badge';
|
|
22
|
-
export { Dialog, DialogContent, DialogHeader, DialogTitle, DialogClose } from './components/ui/dialog';
|
|
23
|
-
export { cn } from './lib/utils';
|
|
32
|
+
/**
|
|
33
|
+
* Configuration for initializing the Aria SDK.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import type { AriaInitConfig } from '@centive/aria-sdk';
|
|
38
|
+
*
|
|
39
|
+
* const config: AriaInitConfig = {
|
|
40
|
+
* websocketUrl: 'wss://your-server.com/ws',
|
|
41
|
+
* userId: 'user_123',
|
|
42
|
+
* theme: 'dark',
|
|
43
|
+
* triggerLabel: 'Help',
|
|
44
|
+
* onError: (err) => console.error(err),
|
|
45
|
+
* };
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export type { AriaInitConfig, Theme } from './types';
|
|
49
|
+
export type { SessionData, SessionSuccessResponse, SessionErrorResponse, SessionResponse, SessionErrorType, WebSocketTriggerEvent, UserTriggerMessage, MessageHistoryEvent, MessageStreamEvent, SessionEndEvent, AnamMessage, MessageHistoryAckResponse, MessageStreamAckResponse, SessionEndAckResponse, SessionEndErrorResponse, GenericAckResponse, MissingFieldsErrorResponse, FrontendToBackendMessage, BackendToFrontendMessage, } from './types';
|
|
24
50
|
export { decodeJWT, extractSessionIdFromToken, isJWT, getTokenInfo, isTokenExpired } from './lib/tokenUtils';
|
|
51
|
+
export type { TokenInfo } from './types';
|
|
25
52
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,CAAC;AAM1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,OAAO,EAAE,QAAQ,IAAI,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAMlD;;;;;;;;;;;;;;;GAeG;AACH,YAAY,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAMrD,YAAY,EAEV,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAGhB,qBAAqB,EAGrB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EACf,WAAW,EAGX,yBAAyB,EACzB,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,0BAA0B,EAG1B,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,SAAS,CAAC;AAMjB,OAAO,EACL,SAAS,EACT,yBAAyB,EACzB,KAAK,EACL,YAAY,EACZ,cAAc,EACf,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC"}
|