@cuekit-ai/react 1.0.0 → 1.1.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.
Files changed (2) hide show
  1. package/README.md +220 -164
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,34 +1,43 @@
1
- # CueKit Web SDK
1
+ # @cuekit-ai/react
2
2
 
3
- A powerful voice-controlled navigation and interaction SDK for React applications. CueKit enables users to navigate and interact with web applications using natural voice commands, providing an accessible and intuitive user experience.
3
+ A powerful React SDK for integrating AI-powered voice interactions into your web applications. Built with TypeScript and designed for seamless voice navigation, commands, and interactions.
4
+
5
+ [![npm version](https://badge.fury.io/js/%40cuekit-ai%2Freact.svg)](https://badge.fury.io/js/%40cuekit-ai%2Freact)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
7
 
5
8
  ## 🚀 Features
6
9
 
7
- - **Voice Recognition**: Real-time speech-to-text using Web Speech API
8
- - **Text-to-Speech**: Built-in TTS for audio feedback
9
- - **Smart Navigation**: Automatic route detection and navigation
10
- - **Element Interaction**: Click buttons and interact with UI elements via voice commands
11
- - **Screen Context Awareness**: Captures and analyzes current screen elements
12
- - **Cross-Platform**: Works with any React application (Next.js, Create React App, etc.)
13
- - **Customizable UI**: Flexible microphone button with multiple positioning options
14
- - **TypeScript Support**: Full TypeScript support with comprehensive type definitions
10
+ - **🎤 Voice Recognition**: Real-time speech-to-text with high accuracy
11
+ - **🤖 AI-Powered Navigation**: Intelligent voice commands for app navigation
12
+ - **🎯 Intent Recognition**: Understands user intent and performs actions
13
+ - **🔊 Text-to-Speech**: Natural voice responses using ElevenLabs
14
+ - **🎨 Beautiful UI**: Modern, animated voice assistant interface
15
+ - **📱 Responsive Design**: Works seamlessly across all devices
16
+ - **⚡ Real-time Processing**: Instant voice command processing
17
+ - **🔄 State Management**: Robust state handling for voice interactions
18
+ - **🎭 Portal Rendering**: Modal components render at document body level
19
+ - **✨ Visual Feedback**: Border glow effects and animations
15
20
 
16
21
  ## 📦 Installation
17
22
 
18
23
  ```bash
19
- npm install cuekit-web-sdk
20
- # or
21
- yarn add cuekit-web-sdk
24
+ npm install @cuekit-ai/react
22
25
  ```
23
26
 
24
- ## 🏗️ Quick Start
27
+ ```bash
28
+ yarn add @cuekit-ai/react
29
+ ```
30
+
31
+ ```bash
32
+ pnpm add @cuekit-ai/react
33
+ ```
25
34
 
26
- ### 1. Initialize CueKit
35
+ ## 🎯 Quick Start
27
36
 
28
- Wrap your app with the `CuekitProvider`:
37
+ ### 1. Wrap your app with CuekitProvider
29
38
 
30
39
  ```tsx
31
- import { CuekitProvider } from 'cuekit-web-sdk'
40
+ import { CuekitProvider } from '@cuekit-ai/react'
32
41
 
33
42
  function App() {
34
43
  return (
@@ -39,251 +48,298 @@ function App() {
39
48
  }
40
49
  ```
41
50
 
42
- ### 2. Add Voice Control Button
43
-
44
- Add the `MicButton` component to enable voice interactions:
51
+ ### 2. Add the MicButton component
45
52
 
46
53
  ```tsx
47
- import { MicButton } from 'cuekit-web-sdk'
54
+ import { MicButton } from '@cuekit-ai/react'
48
55
 
49
56
  function YourApp() {
50
57
  return (
51
58
  <div>
52
- {/* Your app content */}
53
- <MicButton screenPosition="bottom-right" buttonSize={60} hasText={false} />
59
+ <h1>My Voice-Enabled App</h1>
60
+ <MicButton
61
+ screenPosition="bottom-right"
62
+ buttonStyle={{
63
+ backgroundColor: 'blue',
64
+ borderRadius: '50%',
65
+ }}
66
+ />
54
67
  </div>
55
68
  )
56
69
  }
57
70
  ```
58
71
 
59
- ### 3. Initialize the SDK
72
+ ## 🎨 Components
60
73
 
61
- Call `InitCuekit` with your API key:
74
+ ### MicButton
62
75
 
63
- ```tsx
64
- import { InitCuekit } from 'cuekit-web-sdk'
76
+ The main voice interaction component with a beautiful animated interface.
65
77
 
66
- // Initialize with API key
67
- InitCuekit('your-api-key')
78
+ ```tsx
79
+ import { MicButton } from '@cuekit-ai/react'
80
+ ;<MicButton
81
+ screenPosition="bottom-right" // 'bottom-left' | 'bottom-center' | 'bottom-right'
82
+ buttonStyle={
83
+ {
84
+ /* custom styles */
85
+ }
86
+ }
87
+ buttonSize={60}
88
+ hasText={false}
89
+ text="Voice Assistant"
90
+ textStyle={
91
+ {
92
+ /* text styles */
93
+ }
94
+ }
95
+ imageSource="path/to/image.png"
96
+ imageStyle={
97
+ {
98
+ /* image styles */
99
+ }
100
+ }
101
+ />
68
102
  ```
69
103
 
70
- ## 🎯 Core Components
104
+ #### Props
105
+
106
+ | Prop | Type | Default | Description |
107
+ | ---------------- | ---------------------------------------------------- | ---------------- | ------------------------------------ |
108
+ | `screenPosition` | `'bottom-left' \| 'bottom-center' \| 'bottom-right'` | `'bottom-right'` | Position of the mic button |
109
+ | `buttonStyle` | `React.CSSProperties` | `{}` | Custom styles for the button |
110
+ | `buttonSize` | `number` | `60` | Size of the button in pixels |
111
+ | `hasText` | `boolean` | `false` | Whether to show text with the button |
112
+ | `text` | `string` | `'CueKit VC'` | Text to display with the button |
113
+ | `textStyle` | `React.CSSProperties` | `{}` | Styles for the text |
114
+ | `imageSource` | `string` | `undefined` | Image source for the button |
115
+ | `imageStyle` | `React.CSSProperties` | `{}` | Styles for the image |
71
116
 
72
117
  ### CuekitProvider
73
118
 
74
- The main provider component that sets up the voice control context.
119
+ The context provider that initializes the voice assistant.
75
120
 
76
121
  ```tsx
77
- <CuekitProvider
122
+ import { CuekitProvider } from '@cuekit-ai/react'
123
+ ;<CuekitProvider
78
124
  apiKey="your-api-key"
79
125
  appId="your-app-id"
80
126
  deviceId="optional-device-id"
81
- navigator={router} // Optional: Pass your router instance
127
+ navigator={yourNavigator}
82
128
  >
83
129
  {children}
84
130
  </CuekitProvider>
85
131
  ```
86
132
 
87
- **Props:**
88
-
89
- - `apiKey` (required): Your CueKit API key
90
- - `appId` (required): Your application ID
91
- - `deviceId` (optional): Unique device identifier
92
- - `navigator` (optional): Router instance for navigation
93
- - `children`: React components to wrap
133
+ #### Props
94
134
 
95
- ### MicButton
135
+ | Prop | Type | Required | Description |
136
+ | ----------- | ----------- | -------- | --------------------------------------------------------- |
137
+ | `apiKey` | `string` | ✅ | Your CueKit API key |
138
+ | `appId` | `string` | ✅ | Your application ID |
139
+ | `deviceId` | `string` | ❌ | Unique device identifier (auto-generated if not provided) |
140
+ | `navigator` | `any` | ❌ | Navigation object for routing |
141
+ | `children` | `ReactNode` | ✅ | Your app components |
96
142
 
97
- A customizable microphone button for voice input.
98
-
99
- ```tsx
100
- <MicButton
101
- hasText={false}
102
- text="Voice Control"
103
- screenPosition="bottom-right"
104
- buttonSize={60}
105
- imageSource="path/to/mic-icon.png"
106
- buttonStyle={{ backgroundColor: '#007bff' }}
107
- />
108
- ```
143
+ ## 🔧 Hooks
109
144
 
110
- **Props:**
145
+ ### useVoice
111
146
 
112
- - `hasText` (optional): Show text instead of icon
113
- - `text` (optional): Button text when `hasText` is true
114
- - `textStyle` (optional): Custom styles for text
115
- - `imageSource` (optional): Custom microphone icon URL
116
- - `imageStyle` (optional): Custom styles for image
117
- - `buttonStyle` (optional): Custom button styles
118
- - `screenPosition` (optional): Button position (`'bottom-right'`, `'bottom-left'`, `'bottom-center'`)
119
- - `buttonSize` (optional): Button size in pixels
120
-
121
- ## 🎤 Voice Recognition
122
-
123
- ### useVoice Hook
124
-
125
- Custom hook for voice recognition functionality:
147
+ Hook for voice recognition and processing.
126
148
 
127
149
  ```tsx
128
- import { useVoice } from 'cuekit-web-sdk'
150
+ import { useVoice } from '@cuekit-ai/react'
129
151
 
130
- function VoiceComponent() {
152
+ function MyComponent() {
131
153
  const { isListening, start, stop, transcript } = useVoice()
132
154
 
133
- const handleVoiceToggle = async () => {
134
- if (isListening) {
135
- await stop()
136
- } else {
137
- await start('Hello, how can I help you?')
138
- }
155
+ const handleVoiceStart = () => {
156
+ start('Hello, how can I help you?')
139
157
  }
140
158
 
141
- return <button onClick={handleVoiceToggle}>{isListening ? 'Stop' : 'Start'} Voice</button>
159
+ const handleVoiceStop = () => {
160
+ stop()
161
+ }
162
+
163
+ return (
164
+ <div>
165
+ <p>Listening: {isListening ? 'Yes' : 'No'}</p>
166
+ <p>Transcript: {transcript}</p>
167
+ <button onClick={handleVoiceStart}>Start Listening</button>
168
+ <button onClick={handleVoiceStop}>Stop Listening</button>
169
+ </div>
170
+ )
142
171
  }
143
172
  ```
144
173
 
145
- ### useVoiceRecognition Hook
174
+ ### useAudioController
146
175
 
147
- Lower-level hook for speech recognition:
176
+ Hook for audio playback control.
148
177
 
149
178
  ```tsx
150
- import { useVoiceRecognition } from 'cuekit-web-sdk'
179
+ import { useAudioController } from '@cuekit-ai/react'
151
180
 
152
- function CustomVoiceComponent() {
153
- const { isListening, startListening, stopListening, speechText } = useVoiceRecognition('en-US')
181
+ function AudioComponent() {
182
+ const { play, pause, stop, isPlaying } = useAudioController()
154
183
 
155
- // Custom voice recognition logic
184
+ return (
185
+ <div>
186
+ <button onClick={play}>Play</button>
187
+ <button onClick={pause}>Pause</button>
188
+ <button onClick={stop}>Stop</button>
189
+ <p>Playing: {isPlaying ? 'Yes' : 'No'}</p>
190
+ </div>
191
+ )
156
192
  }
157
193
  ```
158
194
 
159
- ## 🔧 Advanced Usage
160
-
161
- ### Custom Voice Processing
195
+ ### useVoiceRecognition
162
196
 
163
- Process voice input manually:
197
+ Hook for advanced voice recognition features.
164
198
 
165
199
  ```tsx
166
- import { processVoice } from 'cuekit-web-sdk'
200
+ import { useVoiceRecognition } from '@cuekit-ai/react'
167
201
 
168
- const handleVoiceInput = async (transcript: string) => {
169
- const result = await processVoice(transcript, 'your-api-key', 'your-app-id', 'device-id')
202
+ function VoiceRecognitionComponent() {
203
+ const { isListening, transcript, startListening, stopListening, resetTranscript } =
204
+ useVoiceRecognition()
170
205
 
171
- console.log('Voice processing result:', result)
206
+ return (
207
+ <div>
208
+ <button onClick={startListening}>Start</button>
209
+ <button onClick={stopListening}>Stop</button>
210
+ <button onClick={resetTranscript}>Reset</button>
211
+ <p>Transcript: {transcript}</p>
212
+ </div>
213
+ )
172
214
  }
173
215
  ```
174
216
 
175
- ### Audio Controller
217
+ ## 🛠️ Utilities
218
+
219
+ ### processVoice
176
220
 
177
- Manage text-to-speech functionality:
221
+ Process voice commands and execute actions.
178
222
 
179
223
  ```tsx
180
- import { useAudioController } from 'cuekit-web-sdk'
224
+ import { processVoice } from '@cuekit-ai/react'
181
225
 
182
- function AudioComponent() {
183
- const { speak, stop, isSpeaking } = useAudioController()
226
+ const handleVoiceCommand = async (transcript: string) => {
227
+ const result = await processVoice(transcript, apiKey, appId, deviceId)
184
228
 
185
- const handleSpeak = () => {
186
- speak('Hello, this is a test message')
229
+ if (result) {
230
+ console.log('Voice command processed:', result)
187
231
  }
188
-
189
- return (
190
- <div>
191
- <button onClick={handleSpeak}>Speak</button>
192
- <button onClick={stop}>Stop</button>
193
- {isSpeaking && <span>Speaking...</span>}
194
- </div>
195
- )
196
232
  }
197
233
  ```
198
234
 
199
- ### Navigation Integration
235
+ ### onStateChange
200
236
 
201
- For custom navigation handling:
237
+ Handle navigation state changes.
202
238
 
203
239
  ```tsx
204
- import { onStateChange } from 'cuekit-web-sdk'
240
+ import { onStateChange } from '@cuekit-ai/react'
205
241
 
206
- // Call this when your app's route changes
207
- onStateChange()
242
+ // Automatically called by CuekitProvider
243
+ // Handles route changes and voice command re-triggering
208
244
  ```
209
245
 
210
- ## 🎨 Customization
246
+ ## 🎯 Voice Commands
247
+
248
+ The SDK supports various voice commands for navigation and interaction:
249
+
250
+ ### Navigation Commands
251
+
252
+ - "Go to home"
253
+ - "Navigate to settings"
254
+ - "Open profile page"
255
+ - "Go back"
256
+
257
+ ### Action Commands
258
+
259
+ - "Click the submit button"
260
+ - "Press the login button"
261
+ - "Select the first option"
262
+ - "Scroll down"
263
+
264
+ ### Information Commands
265
+
266
+ - "What's on this page?"
267
+ - "Tell me about this screen"
268
+ - "What can I do here?"
269
+
270
+ ## 🎨 Styling
211
271
 
212
- ### Styling the MicButton
272
+ ### Custom Button Styling
213
273
 
214
274
  ```tsx
215
275
  <MicButton
216
276
  buttonStyle={{
217
- backgroundColor: '#ff6b6b',
218
- boxShadow: '0 4px 12px rgba(0,0,0,0.3)',
219
- border: '2px solid #fff',
220
- }}
221
- textStyle={{
222
- fontSize: '16px',
223
- fontWeight: 'bold',
224
- color: '#fff',
277
+ backgroundColor: 'linear-gradient(45deg, #667eea 0%, #764ba2 100%)',
278
+ boxShadow: '0 4px 15px rgba(0, 0, 0, 0.2)',
279
+ transform: 'scale(1.1)',
225
280
  }}
226
281
  />
227
282
  ```
228
283
 
229
- ### Custom Positioning
284
+ ### Custom Modal Styling
230
285
 
231
- ```tsx
232
- // Bottom right (default)
233
- <MicButton screenPosition="bottom-right" />
286
+ The modal automatically adapts to your app's theme and provides:
234
287
 
235
- // Bottom left
236
- <MicButton screenPosition="bottom-left" />
288
+ - Beautiful gradient backgrounds
289
+ - Smooth animations
290
+ - Responsive design
291
+ - Accessibility features
237
292
 
238
- // Bottom center
239
- <MicButton screenPosition="bottom-center" />
293
+ ```env
294
+ CUEKIT_API_KEY=your-api-key
295
+ CUEKIT_APP_ID=your-app-id
296
+ CUEKIT_DEVICE_ID=optional-device-id
240
297
  ```
241
298
 
242
- ## 🔌 API Integration
299
+ ### API Configuration
243
300
 
244
- The SDK automatically sends component data to the CueKit API for intelligent voice processing. The API analyzes:
301
+ The SDK communicates with the CueKit API for:
245
302
 
246
- - Current screen elements (buttons, links, etc.)
247
- - User voice input
248
- - Screen context
249
- - Navigation patterns
303
+ - Voice command processing
304
+ - Intent recognition
305
+ - Navigation handling
306
+ - Text-to-speech synthesis
250
307
 
251
- ### API Response Format
308
+ ## 🔒 Security
252
309
 
253
- ```typescript
254
- interface CueKitResponse {
255
- actionType: 'navigate' | 'click' | 'audio_only'
256
- routeName?: string
257
- component?: {
258
- hash: string
259
- text: string
260
- componentType: string
261
- }
262
- text?: string
263
- claudeError?: boolean
264
- errorMessage?: string
265
- }
266
- ```
310
+ - All API calls are made over HTTPS
311
+ - API keys are stored securely
312
+ - No sensitive data is logged
313
+ - Device IDs are anonymized
267
314
 
268
- ## 🔒 Security
315
+ ## 🚀 Performance
316
+
317
+ - Lightweight bundle (~40KB gzipped)
318
+ - Optimized for React 18+
319
+ - Efficient re-rendering
320
+ - Minimal memory footprint
321
+
322
+ ## 🐛 Troubleshooting
269
323
 
270
- - API keys are stored securely in the global context
271
- - Device IDs are automatically generated and persisted
272
- - Network requests are validated and error-handled
273
- - No sensitive data is logged to console
324
+ ### Common Issues
274
325
 
275
- ## 🌐 Browser Support
326
+ 1. **Mic not working**
276
327
 
277
- - Chrome/Chromium (recommended)
278
- - Firefox
279
- - Safari (limited TTS support)
280
- - Edge
328
+ - Check browser permissions
329
+ - Ensure HTTPS connection
330
+ - Verify API key is valid
281
331
 
282
- **Note**: Voice recognition requires HTTPS in production environments.
332
+ 2. **Voice commands not recognized**
283
333
 
284
- ## 📝 License
334
+ - Check internet connection
335
+ - Verify app ID is correct
336
+ - Ensure proper CuekitProvider setup
285
337
 
286
- This project is licensed under the MIT License.
338
+ 3. **Modal not appearing**
339
+ - Check z-index conflicts
340
+ - Verify portal rendering
341
+ - Ensure proper state management
287
342
 
343
+ ---
288
344
 
289
- **CueKit Web SDK** - Making web applications voice-controlled and accessible.
345
+ **Made with ❤️ by [CueKit](https://cuekit.ai)**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuekit-ai/react",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {