@foisit/vue-wrapper 2.0.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 CHANGED
@@ -7,39 +7,38 @@
7
7
 
8
8
  Transform your Vue 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
- - **⚑ Vue Native** - Uses Composition API, `provide/inject`, and Vue 3 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
+ - **Vue Native** - Uses Composition API, `provide/inject`, and Vue 3 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/vue-wrapper
@@ -55,7 +54,7 @@ npm install @foisit/vue-wrapper
55
54
 
56
55
  ---
57
56
 
58
- ## 🏁 Quick Start
57
+ ## Quick Start
59
58
 
60
59
  ### Step 1: Wrap Your App
61
60
 
@@ -106,7 +105,7 @@ const openAssistant = () => {
106
105
 
107
106
  ---
108
107
 
109
- ## 🎯 Core Concepts
108
+ ## Core Concepts
110
109
 
111
110
  ### 1. Commands
112
111
 
@@ -143,24 +142,57 @@ Define parameters and Foisit will automatically generate forms to collect them:
143
142
  - `number` - Numeric input
144
143
  - `date` - Date picker
145
144
  - `select` - Dropdown (static or async options)
145
+ - `file` - File upload input
146
146
 
147
- ### 3. Critical Actions
147
+ ### 3. File Parameters
148
+
149
+ Collect files via the built-in form UI and receive them in your command `action`.
150
+
151
+ ```javascript
152
+ {
153
+ command: 'upload file',
154
+ description: 'Pick a file and return it to the action',
155
+ parameters: [
156
+ {
157
+ name: 'attachment',
158
+ type: 'file',
159
+ required: true,
160
+ accept: ['image/*', 'audio/*', 'video/*'],
161
+ multiple: false,
162
+ // delivery: 'file' | 'base64' (default: 'file')
163
+ delivery: 'file',
164
+ },
165
+ ],
166
+ action: async (params) => {
167
+ const file = params?.attachment;
168
+ if (!file) return { type: 'error', message: 'No file provided.' };
169
+ return {
170
+ type: 'success',
171
+ message: `File received. Name: ${file.name}, Type: ${file.type || 'unknown'}, Size: ${file.size} bytes`,
172
+ };
173
+ },
174
+ }
175
+ ```
176
+
177
+ `FileParameter` supports validations like `maxFiles`, `maxSizeBytes`, `maxTotalBytes`, and media/image constraints like `maxDurationSec`, `maxWidth`, and `maxHeight`.
178
+
179
+ ### 4. Critical Actions
148
180
 
149
181
  Protect dangerous operations with automatic confirmation dialogs:
150
182
 
151
183
  ```javascript
152
184
  {
153
185
  command: 'delete all data',
154
- critical: true, // πŸ”’ Requires confirmation
186
+ critical: true, // Requires confirmation
155
187
  description: 'Permanently delete all application data',
156
188
  action: async () => {
157
189
  await dataService.deleteAll();
158
- return 'βœ… All data deleted successfully.';
190
+ return 'All data deleted successfully.';
159
191
  }
160
192
  }
161
193
  ```
162
194
 
163
- ### 4. Select Parameters (Static)
195
+ ### 5. Select Parameters (Static)
164
196
 
165
197
  Provide predefined options:
166
198
 
@@ -180,7 +212,7 @@ Provide predefined options:
180
212
  }
181
213
  ```
182
214
 
183
- ### 5. Dynamic Select Parameters
215
+ ### 6. Dynamic Select Parameters
184
216
 
185
217
  Load options from APIs:
186
218
 
@@ -204,7 +236,7 @@ Load options from APIs:
204
236
 
205
237
  ---
206
238
 
207
- ## πŸ“˜ API Reference
239
+ ## API Reference
208
240
 
209
241
  ### `AssistantService` (via `inject`)
210
242
 
@@ -237,7 +269,7 @@ const openWithCallbacks = () => {
237
269
 
238
270
  ##### `addCommand(command, action?)`
239
271
 
240
- Dynamically add a command at runtime.
272
+ Dynamically add or update a command at runtime. Commands registered with `addCommand` apply immediately for the running session; they are stored in memory and are not automatically persisted across page reloads.
241
273
 
242
274
  ```vue
243
275
  <script setup>
@@ -275,6 +307,23 @@ onMounted(() => {
275
307
  </script>
276
308
  ```
277
309
 
310
+ ### Dynamic Updates (Add / Remove / Update commands at runtime) βœ…
311
+
312
+ - Use `addCommand` to add or replace a command for the current runtime.
313
+ - Use `removeCommand(commandPhrase)` to unregister a command immediately.
314
+ - When adding temporary commands inside components, remove them in `onUnmounted` (or equivalent) to avoid leaving stale commands behind.
315
+
316
+ Example β€” register and remove a temporary command:
317
+
318
+ ```vue
319
+ import { onMounted, onUnmounted, inject } from 'vue'; const assistant = inject('assistantService'); onMounted(() => { assistant?.addCommand('temp action', () => 'Temporary action'); }); onUnmounted(() => { assistant?.removeCommand('temp action'); });
320
+ ```
321
+
322
+ Notes:
323
+
324
+ - Commands with optional parameters can return a `form` InteractiveResponse to prompt the user when no params are provided.
325
+ - Commands are not persisted by default; to persist them, re-register at app startup.
326
+
278
327
  ##### `removeCommand(commandPhrase)`
279
328
 
280
329
  Remove a registered command.
@@ -294,7 +343,7 @@ console.log('Available commands:', commands);
294
343
 
295
344
  ---
296
345
 
297
- ## πŸ”§ Configuration Options
346
+ ## Configuration Options
298
347
 
299
348
  ### `AssistantConfig`
300
349
 
@@ -330,7 +379,7 @@ interface AssistantConfig {
330
379
 
331
380
  ---
332
381
 
333
- ## 🎨 Advanced Usage
382
+ ## Advanced Usage
334
383
 
335
384
  ### Example 1: Multi-Step Booking System with Reactive State
336
385
 
@@ -371,7 +420,7 @@ onMounted(() => {
371
420
  bookings.value.push(booking);
372
421
  return {
373
422
  type: 'success',
374
- message: `βœ… Appointment booked for ${params.date}!`,
423
+ message: `Appointment booked for ${params.date}!`,
375
424
  };
376
425
  },
377
426
  });
@@ -486,7 +535,7 @@ onMounted(() => {
486
535
 
487
536
  ---
488
537
 
489
- ## πŸ“ TypeScript Support
538
+ ## TypeScript Support
490
539
 
491
540
  ### Full Type Definitions
492
541
 
@@ -520,7 +569,7 @@ const myCommand: AssistantCommand = {
520
569
 
521
570
  ---
522
571
 
523
- ## 🎯 Best Practices
572
+ ## Best Practices
524
573
 
525
574
  ### 1. Use `onMounted` for Commands
526
575
 
@@ -576,7 +625,7 @@ action: async (params) => {
576
625
 
577
626
  ---
578
627
 
579
- ## πŸ§ͺ Testing
628
+ ## Testing
580
629
 
581
630
  ### Unit Testing with Vitest
582
631
 
@@ -601,7 +650,7 @@ test('renders assistant', () => {
601
650
 
602
651
  ---
603
652
 
604
- ## πŸ”— Related Packages
653
+ ## Related Packages
605
654
 
606
655
  - **[@foisit/core](../core)** - Core engine (auto-installed)
607
656
  - **[@foisit/angular-wrapper](../angular-wrapper)** - Angular integration
@@ -609,7 +658,7 @@ test('renders assistant', () => {
609
658
 
610
659
  ---
611
660
 
612
- ## πŸ› Troubleshooting
661
+ ## Troubleshooting
613
662
 
614
663
  ### Assistant service is undefined
615
664
 
@@ -625,23 +674,23 @@ Make sure you're using Vue 3.3+ and have proper type definitions.
625
674
 
626
675
  ---
627
676
 
628
- ## πŸ“„ License
677
+ ## License
629
678
 
630
679
  MIT Β© [Foisit](https://github.com/boluwatifee4/foisit)
631
680
 
632
681
  ---
633
682
 
634
- ## 🀝 Contributing
683
+ ## Contributing
635
684
 
636
685
  Contributions are welcome! Please read our [Contributing Guide](../../CONTRIBUTING.md) first.
637
686
 
638
687
  ---
639
688
 
640
- ## πŸ“¬ Support
689
+ ## Support
641
690
 
642
- - πŸ“§ Email: support@foisit.com
643
- - πŸ’¬ Discord: [Join our community](https://discord.gg/foisit)
644
- - πŸ› Issues: [GitHub Issues](https://github.com/boluwatifee4/foisit/issues)
691
+ - Email: support@foisit.com
692
+ - Discord: [Join our community](https://discord.gg/foisit)
693
+ - Issues: [GitHub Issues](https://github.com/boluwatifee4/foisit/issues)
645
694
 
646
695
  ---
647
696
 
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { default as AssistantProvider } from './lib/components/AssistantProvider.vue';
2
+ export { useAssistant } from './lib/composables/useAssistant';
3
+ export { AssistantService } from './lib/services/AssistantService';