@foisit/react-wrapper 2.1.1 β 2.4.1
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 +96 -44
- package/index.d.ts +6 -0
- package/index.js +355 -0
- package/index.mjs +1421 -0
- package/lib/components/AssistantActivator.d.ts +8 -0
- package/lib/components/AssistantProvider.d.ts +9 -0
- package/lib/hooks/useAssistant.d.ts +3 -0
- package/lib/hooks/useAssistantState.d.ts +3 -0
- package/lib/react-wrapper.d.ts +2 -0
- package/lib/services/AssistantService.d.ts +44 -0
- package/lib/types/index.d.ts +0 -0
- package/lib/utils/index.d.ts +0 -0
- package/package.json +6 -2
- package/style.css +0 -0
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
|
-
##
|
|
14
|
+
## Table of Contents
|
|
16
15
|
|
|
17
|
-
- [Features](
|
|
18
|
-
- [Installation](
|
|
19
|
-
- [Quick Start](
|
|
20
|
-
- [Core Concepts](
|
|
21
|
-
- [API Reference](
|
|
22
|
-
- [Advanced Usage](
|
|
23
|
-
- [Examples](
|
|
24
|
-
- [TypeScript Support](
|
|
25
|
-
- [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
|
-
##
|
|
28
|
+
## Features
|
|
30
29
|
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
-
|
|
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
|
-
##
|
|
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
|
-
##
|
|
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
|
-
##
|
|
106
|
+
## Core Concepts
|
|
108
107
|
|
|
109
108
|
### 1. Commands
|
|
110
109
|
|
|
@@ -141,24 +140,57 @@ Define parameters and Foisit will automatically generate forms to collect them:
|
|
|
141
140
|
- `number` - Numeric input
|
|
142
141
|
- `date` - Date picker
|
|
143
142
|
- `select` - Dropdown (static or async options)
|
|
143
|
+
- `file` - File upload input
|
|
144
144
|
|
|
145
|
-
### 3.
|
|
145
|
+
### 3. File Parameters
|
|
146
|
+
|
|
147
|
+
Collect files via the built-in form UI and receive them in your command `action`.
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
{
|
|
151
|
+
command: 'upload file',
|
|
152
|
+
description: 'Pick a file and return it to the action',
|
|
153
|
+
parameters: [
|
|
154
|
+
{
|
|
155
|
+
name: 'attachment',
|
|
156
|
+
type: 'file',
|
|
157
|
+
required: true,
|
|
158
|
+
accept: ['image/*', 'audio/*', 'video/*'],
|
|
159
|
+
multiple: false,
|
|
160
|
+
// delivery: 'file' | 'base64' (default: 'file')
|
|
161
|
+
delivery: 'file',
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
action: async (params) => {
|
|
165
|
+
const file = params?.attachment as File | undefined;
|
|
166
|
+
if (!file) return { type: 'error', message: 'No file provided.' };
|
|
167
|
+
return {
|
|
168
|
+
type: 'success',
|
|
169
|
+
message: `File received. Name: ${file.name}, Type: ${file.type || 'unknown'}, Size: ${file.size} bytes`,
|
|
170
|
+
};
|
|
171
|
+
},
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
`FileParameter` supports validations like `maxFiles`, `maxSizeBytes`, `maxTotalBytes`, and media/image constraints like `maxDurationSec`, `maxWidth`, and `maxHeight`.
|
|
176
|
+
|
|
177
|
+
### 4. Critical Actions
|
|
146
178
|
|
|
147
179
|
Protect dangerous operations with automatic confirmation dialogs:
|
|
148
180
|
|
|
149
181
|
```tsx
|
|
150
182
|
{
|
|
151
183
|
command: 'delete all data',
|
|
152
|
-
critical: true, //
|
|
184
|
+
critical: true, // Requires confirmation
|
|
153
185
|
description: 'Permanently delete all application data',
|
|
154
186
|
action: async () => {
|
|
155
187
|
await dataService.deleteAll();
|
|
156
|
-
return '
|
|
188
|
+
return 'All data deleted successfully.';
|
|
157
189
|
}
|
|
158
190
|
}
|
|
159
191
|
```
|
|
160
192
|
|
|
161
|
-
###
|
|
193
|
+
### 5. Select Parameters (Static)
|
|
162
194
|
|
|
163
195
|
Provide predefined options:
|
|
164
196
|
|
|
@@ -178,7 +210,7 @@ Provide predefined options:
|
|
|
178
210
|
}
|
|
179
211
|
```
|
|
180
212
|
|
|
181
|
-
###
|
|
213
|
+
### 6. Dynamic Select Parameters
|
|
182
214
|
|
|
183
215
|
Load options from APIs:
|
|
184
216
|
|
|
@@ -202,7 +234,7 @@ Load options from APIs:
|
|
|
202
234
|
|
|
203
235
|
---
|
|
204
236
|
|
|
205
|
-
##
|
|
237
|
+
## API Reference
|
|
206
238
|
|
|
207
239
|
### `useAssistant()` Hook
|
|
208
240
|
|
|
@@ -229,7 +261,7 @@ assistant.toggle(
|
|
|
229
261
|
|
|
230
262
|
##### `addCommand(command, action?)`
|
|
231
263
|
|
|
232
|
-
Dynamically add a command at runtime.
|
|
264
|
+
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
265
|
|
|
234
266
|
```tsx
|
|
235
267
|
// Add a simple command
|
|
@@ -259,6 +291,26 @@ assistant.addCommand({
|
|
|
259
291
|
});
|
|
260
292
|
```
|
|
261
293
|
|
|
294
|
+
### Dynamic Updates (Add / Remove / Update commands at runtime) β
|
|
295
|
+
|
|
296
|
+
- `addCommand` registers or can replace commands for the current session.
|
|
297
|
+
- `removeCommand(commandPhrase)` removes a registered command immediately.
|
|
298
|
+
- For one-off commands created inside components, unregister them in a cleanup effect (React's `useEffect` cleanup) to avoid leaking commands.
|
|
299
|
+
|
|
300
|
+
Example β add/remove a temporary command:
|
|
301
|
+
|
|
302
|
+
```tsx
|
|
303
|
+
useEffect(() => {
|
|
304
|
+
assistant.addCommand('temp action', () => 'Temp action');
|
|
305
|
+
return () => assistant.removeCommand('temp action');
|
|
306
|
+
}, [assistant]);
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Notes:
|
|
310
|
+
|
|
311
|
+
- If a command has optional params and is invoked with no params, you may return a `form` InteractiveResponse to prompt for the values.
|
|
312
|
+
- Commands are not persisted across reloads by default; store and re-register them if needed.
|
|
313
|
+
|
|
262
314
|
##### `removeCommand(commandPhrase)`
|
|
263
315
|
|
|
264
316
|
Remove a registered command.
|
|
@@ -278,7 +330,7 @@ console.log('Available commands:', commands);
|
|
|
278
330
|
|
|
279
331
|
---
|
|
280
332
|
|
|
281
|
-
##
|
|
333
|
+
## Configuration Options
|
|
282
334
|
|
|
283
335
|
### `AssistantConfig`
|
|
284
336
|
|
|
@@ -314,7 +366,7 @@ interface AssistantConfig {
|
|
|
314
366
|
|
|
315
367
|
---
|
|
316
368
|
|
|
317
|
-
##
|
|
369
|
+
## Advanced Usage
|
|
318
370
|
|
|
319
371
|
### Example 1: Multi-Step Booking System with State
|
|
320
372
|
|
|
@@ -475,7 +527,7 @@ function AccountManager() {
|
|
|
475
527
|
|
|
476
528
|
---
|
|
477
529
|
|
|
478
|
-
##
|
|
530
|
+
## TypeScript Support
|
|
479
531
|
|
|
480
532
|
### Full Type Definitions
|
|
481
533
|
|
|
@@ -518,7 +570,7 @@ const assistant = useAssistant();
|
|
|
518
570
|
|
|
519
571
|
---
|
|
520
572
|
|
|
521
|
-
##
|
|
573
|
+
## Best Practices
|
|
522
574
|
|
|
523
575
|
### 1. Cleanup Effects
|
|
524
576
|
|
|
@@ -571,7 +623,7 @@ Wrap your app with error boundaries:
|
|
|
571
623
|
|
|
572
624
|
---
|
|
573
625
|
|
|
574
|
-
##
|
|
626
|
+
## Testing
|
|
575
627
|
|
|
576
628
|
### Unit Testing with React Testing Library
|
|
577
629
|
|
|
@@ -592,7 +644,7 @@ test('renders assistant', () => {
|
|
|
592
644
|
|
|
593
645
|
---
|
|
594
646
|
|
|
595
|
-
##
|
|
647
|
+
## Related Packages
|
|
596
648
|
|
|
597
649
|
- **[@foisit/core](../core)** - Core engine (auto-installed)
|
|
598
650
|
- **[@foisit/angular-wrapper](../angular-wrapper)** - Angular integration
|
|
@@ -600,7 +652,7 @@ test('renders assistant', () => {
|
|
|
600
652
|
|
|
601
653
|
---
|
|
602
654
|
|
|
603
|
-
##
|
|
655
|
+
## Troubleshooting
|
|
604
656
|
|
|
605
657
|
### Hook error: "useAssistant must be used within AssistantProvider"
|
|
606
658
|
|
|
@@ -616,23 +668,23 @@ Make sure you're using React 18+ and have proper type definitions.
|
|
|
616
668
|
|
|
617
669
|
---
|
|
618
670
|
|
|
619
|
-
##
|
|
671
|
+
## License
|
|
620
672
|
|
|
621
673
|
MIT Β© [Foisit](https://github.com/boluwatifee4/foisit)
|
|
622
674
|
|
|
623
675
|
---
|
|
624
676
|
|
|
625
|
-
##
|
|
677
|
+
## Contributing
|
|
626
678
|
|
|
627
679
|
Contributions are welcome! Please read our [Contributing Guide](../../CONTRIBUTING.md) first.
|
|
628
680
|
|
|
629
681
|
---
|
|
630
682
|
|
|
631
|
-
##
|
|
683
|
+
## Support
|
|
632
684
|
|
|
633
|
-
-
|
|
634
|
-
-
|
|
635
|
-
-
|
|
685
|
+
- Email: support@foisit.com
|
|
686
|
+
- Discord: [Join our community](https://discord.gg/foisit)
|
|
687
|
+
- Issues: [GitHub Issues](https://github.com/boluwatifee4/foisit/issues)
|
|
636
688
|
|
|
637
689
|
---
|
|
638
690
|
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './lib/react-wrapper';
|
|
2
|
+
export * from './lib/components/AssistantProvider';
|
|
3
|
+
export * from './lib/components/AssistantActivator';
|
|
4
|
+
export * from './lib/hooks/useAssistant';
|
|
5
|
+
export * from './lib/hooks/useAssistantState';
|
|
6
|
+
export * from './lib/services/AssistantService';
|