@foisit/react-wrapper 2.1.2 β†’ 2.4.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 CHANGED
@@ -7,39 +7,38 @@
7
7
 
8
8
  Transform your React app into an intelligent, voice-ready platform. Foisit provides a drop-in AI layer that understands natural language, manages multi-step workflows, and executes actionsβ€”all with zero backend required.
9
9
 
10
- > [!NOTE]
11
- > πŸŽ™οΈ **Voice Support Status**: Voice recognition and responses are currently in development and will be released in a future update. The current version focuses on high-performance text-based interactions and AI intent matching.
10
+ > [!NOTE] > **Voice Support Status**: Voice recognition and responses are currently in development and will be released in a future update. The current version focuses on high-performance text-based interactions and AI intent matching.
12
11
 
13
12
  ---
14
13
 
15
- ## πŸ“‹ Table of Contents
14
+ ## Table of Contents
16
15
 
17
- - [Features](#-features)
18
- - [Installation](#-installation)
19
- - [Quick Start](#-quick-start)
20
- - [Core Concepts](#-core-concepts)
21
- - [API Reference](#-api-reference)
22
- - [Advanced Usage](#-advanced-usage)
23
- - [Examples](#-examples)
24
- - [TypeScript Support](#-typescript-support)
25
- - [Best Practices](#-best-practices)
16
+ - [Features](#features)
17
+ - [Installation](#installation)
18
+ - [Quick Start](#quick-start)
19
+ - [Core Concepts](#core-concepts)
20
+ - [API Reference](#api-reference)
21
+ - [Advanced Usage](#advanced-usage)
22
+ - [Examples](#examples)
23
+ - [TypeScript Support](#typescript-support)
24
+ - [Best Practices](#best-practices)
26
25
 
27
26
  ---
28
27
 
29
- ## ✨ Features
28
+ ## Features
30
29
 
31
- - **🧠 Natural Language Understanding** - AI-powered intent matching using GPT-4o mini (proxied securely)
32
- - **πŸ“ Smart Slot Filling** - Auto-generates forms for missing parameters
33
- - **⚠️ Critical Action Protection** - Built-in confirmation dialogs for dangerous operations
34
- - **🎨 Premium UI** - Glassmorphic overlay with dark/light mode support
35
- - **πŸ”’ Zero Backend Required** - Secure proxy architecture keeps API keys server-side
36
- - **⚑ React Native** - Uses Hooks, Context API, and modern React patterns
37
- - **🎯 Type-Safe** - Full TypeScript support with comprehensive types
38
- - **πŸ“± Responsive** - Works flawlessly on desktop and mobile
30
+ - **Natural Language Understanding** - AI-powered intent matching using GPT-4o mini (proxied securely)
31
+ - **Smart Slot Filling** - Auto-generates forms for missing parameters
32
+ - **Critical Action Protection** - Built-in confirmation dialogs for dangerous operations
33
+ - **Premium UI** - Glassmorphic overlay with dark/light mode support
34
+ - **Zero Backend Required** - Secure proxy architecture keeps API keys server-side
35
+ - **React Native** - Uses Hooks, Context API, and modern React patterns
36
+ - **Type-Safe** - Full TypeScript support with comprehensive types
37
+ - **Responsive** - Works flawlessly on desktop and mobile
39
38
 
40
39
  ---
41
40
 
42
- ## πŸš€ Installation
41
+ ## Installation
43
42
 
44
43
  ```bash
45
44
  npm install @foisit/react-wrapper
@@ -56,7 +55,7 @@ npm install @foisit/react-wrapper
56
55
 
57
56
  ---
58
57
 
59
- ## 🏁 Quick Start
58
+ ## Quick Start
60
59
 
61
60
  ### Step 1: Wrap Your App
62
61
 
@@ -104,7 +103,7 @@ function MyComponent() {
104
103
 
105
104
  ---
106
105
 
107
- ## 🎯 Core Concepts
106
+ ## Core Concepts
108
107
 
109
108
  ### 1. Commands
110
109
 
@@ -135,30 +134,85 @@ Define parameters and Foisit will automatically generate forms to collect them:
135
134
  }
136
135
  ```
137
136
 
137
+ **Enterprise-safe param collection controls**
138
+
139
+ - `collectRequiredViaForm` (default: true): force missing/invalid required params to be collected via a form instead of conversational guessing.
140
+ - `allowAiParamExtraction` (default: true): when false, ignore AI-extracted params and always prompt the user for required fields.
141
+
142
+ Example:
143
+
144
+ ```tsx
145
+ {
146
+ command: 'secure create user',
147
+ description: 'No AI guessing, form-only',
148
+ collectRequiredViaForm: true,
149
+ allowAiParamExtraction: false,
150
+ parameters: [
151
+ { name: 'fullName', type: 'string', required: true },
152
+ { name: 'email', type: 'string', required: true },
153
+ { name: 'age', type: 'number', required: true, min: 18 },
154
+ ],
155
+ action: (params) => userService.create(params),
156
+ }
157
+ ```
158
+
138
159
  **Supported Parameter Types:**
139
160
 
140
161
  - `string` - Text input
141
162
  - `number` - Numeric input
142
163
  - `date` - Date picker
143
164
  - `select` - Dropdown (static or async options)
165
+ - `file` - File upload input
166
+
167
+ ### 3. File Parameters
144
168
 
145
- ### 3. Critical Actions
169
+ Collect files via the built-in form UI and receive them in your command `action`.
170
+
171
+ ```tsx
172
+ {
173
+ command: 'upload file',
174
+ description: 'Pick a file and return it to the action',
175
+ parameters: [
176
+ {
177
+ name: 'attachment',
178
+ type: 'file',
179
+ required: true,
180
+ accept: ['image/*', 'audio/*', 'video/*'],
181
+ multiple: false,
182
+ // delivery: 'file' | 'base64' (default: 'file')
183
+ delivery: 'file',
184
+ },
185
+ ],
186
+ action: async (params) => {
187
+ const file = params?.attachment as File | undefined;
188
+ if (!file) return { type: 'error', message: 'No file provided.' };
189
+ return {
190
+ type: 'success',
191
+ message: `File received. Name: ${file.name}, Type: ${file.type || 'unknown'}, Size: ${file.size} bytes`,
192
+ };
193
+ },
194
+ }
195
+ ```
196
+
197
+ `FileParameter` supports validations like `maxFiles`, `maxSizeBytes`, `maxTotalBytes`, and media/image constraints like `maxDurationSec`, `maxWidth`, and `maxHeight`.
198
+
199
+ ### 4. Critical Actions
146
200
 
147
201
  Protect dangerous operations with automatic confirmation dialogs:
148
202
 
149
203
  ```tsx
150
204
  {
151
205
  command: 'delete all data',
152
- critical: true, // πŸ”’ Requires confirmation
206
+ critical: true, // Requires confirmation
153
207
  description: 'Permanently delete all application data',
154
208
  action: async () => {
155
209
  await dataService.deleteAll();
156
- return 'βœ… All data deleted successfully.';
210
+ return 'All data deleted successfully.';
157
211
  }
158
212
  }
159
213
  ```
160
214
 
161
- ### 4. Select Parameters (Static)
215
+ ### 5. Select Parameters (Static)
162
216
 
163
217
  Provide predefined options:
164
218
 
@@ -178,7 +232,7 @@ Provide predefined options:
178
232
  }
179
233
  ```
180
234
 
181
- ### 5. Dynamic Select Parameters
235
+ ### 6. Dynamic Select Parameters
182
236
 
183
237
  Load options from APIs:
184
238
 
@@ -202,7 +256,7 @@ Load options from APIs:
202
256
 
203
257
  ---
204
258
 
205
- ## πŸ“˜ API Reference
259
+ ## API Reference
206
260
 
207
261
  ### `useAssistant()` Hook
208
262
 
@@ -229,7 +283,7 @@ assistant.toggle(
229
283
 
230
284
  ##### `addCommand(command, action?)`
231
285
 
232
- Dynamically add a command at runtime.
286
+ Dynamically add or update a command at runtime. Commands added via `addCommand` take effect immediately; they are stored in memory for the current session. Re-register commands on app initialization if you need them after a full page reload.
233
287
 
234
288
  ```tsx
235
289
  // Add a simple command
@@ -259,6 +313,26 @@ assistant.addCommand({
259
313
  });
260
314
  ```
261
315
 
316
+ ### Dynamic Updates (Add / Remove / Update commands at runtime) βœ…
317
+
318
+ - `addCommand` registers or can replace commands for the current session.
319
+ - `removeCommand(commandPhrase)` removes a registered command immediately.
320
+ - For one-off commands created inside components, unregister them in a cleanup effect (React's `useEffect` cleanup) to avoid leaking commands.
321
+
322
+ Example β€” add/remove a temporary command:
323
+
324
+ ```tsx
325
+ useEffect(() => {
326
+ assistant.addCommand('temp action', () => 'Temp action');
327
+ return () => assistant.removeCommand('temp action');
328
+ }, [assistant]);
329
+ ```
330
+
331
+ Notes:
332
+
333
+ - If a command has optional params and is invoked with no params, you may return a `form` InteractiveResponse to prompt for the values.
334
+ - Commands are not persisted across reloads by default; store and re-register them if needed.
335
+
262
336
  ##### `removeCommand(commandPhrase)`
263
337
 
264
338
  Remove a registered command.
@@ -278,7 +352,7 @@ console.log('Available commands:', commands);
278
352
 
279
353
  ---
280
354
 
281
- ## πŸ”§ Configuration Options
355
+ ## Configuration Options
282
356
 
283
357
  ### `AssistantConfig`
284
358
 
@@ -314,7 +388,7 @@ interface AssistantConfig {
314
388
 
315
389
  ---
316
390
 
317
- ## 🎨 Advanced Usage
391
+ ## Advanced Usage
318
392
 
319
393
  ### Example 1: Multi-Step Booking System with State
320
394
 
@@ -475,7 +549,7 @@ function AccountManager() {
475
549
 
476
550
  ---
477
551
 
478
- ## πŸ“ TypeScript Support
552
+ ## TypeScript Support
479
553
 
480
554
  ### Full Type Definitions
481
555
 
@@ -518,7 +592,7 @@ const assistant = useAssistant();
518
592
 
519
593
  ---
520
594
 
521
- ## 🎯 Best Practices
595
+ ## Best Practices
522
596
 
523
597
  ### 1. Cleanup Effects
524
598
 
@@ -571,7 +645,7 @@ Wrap your app with error boundaries:
571
645
 
572
646
  ---
573
647
 
574
- ## πŸ§ͺ Testing
648
+ ## Testing
575
649
 
576
650
  ### Unit Testing with React Testing Library
577
651
 
@@ -592,7 +666,7 @@ test('renders assistant', () => {
592
666
 
593
667
  ---
594
668
 
595
- ## πŸ”— Related Packages
669
+ ## Related Packages
596
670
 
597
671
  - **[@foisit/core](../core)** - Core engine (auto-installed)
598
672
  - **[@foisit/angular-wrapper](../angular-wrapper)** - Angular integration
@@ -600,7 +674,7 @@ test('renders assistant', () => {
600
674
 
601
675
  ---
602
676
 
603
- ## πŸ› Troubleshooting
677
+ ## Troubleshooting
604
678
 
605
679
  ### Hook error: "useAssistant must be used within AssistantProvider"
606
680
 
@@ -616,23 +690,23 @@ Make sure you're using React 18+ and have proper type definitions.
616
690
 
617
691
  ---
618
692
 
619
- ## πŸ“„ License
693
+ ## License
620
694
 
621
695
  MIT Β© [Foisit](https://github.com/boluwatifee4/foisit)
622
696
 
623
697
  ---
624
698
 
625
- ## 🀝 Contributing
699
+ ## Contributing
626
700
 
627
701
  Contributions are welcome! Please read our [Contributing Guide](../../CONTRIBUTING.md) first.
628
702
 
629
703
  ---
630
704
 
631
- ## πŸ“¬ Support
705
+ ## Support
632
706
 
633
- - πŸ“§ Email: support@foisit.com
634
- - πŸ’¬ Discord: [Join our community](https://discord.gg/foisit)
635
- - πŸ› Issues: [GitHub Issues](https://github.com/boluwatifee4/foisit/issues)
707
+ - Email: support@foisit.com
708
+ - Discord: [Join our community](https://discord.gg/foisit)
709
+ - Issues: [GitHub Issues](https://github.com/boluwatifee4/foisit/issues)
636
710
 
637
711
  ---
638
712