@floe-ai/sdk 0.1.0-dev.3 → 0.1.0-dev.30

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.
@@ -1,26 +1,8 @@
1
- declare interface ContextData {
2
- screenshot?: string;
3
- url: string;
4
- structure: PageStructure;
5
- timestamp: number;
6
- userProfile?: any;
7
- }
8
-
9
- declare interface ElementInfo {
10
- selector: string;
11
- type: string;
12
- text?: string;
13
- visible: boolean;
14
- position: DOMRect;
15
- attributes: Record<string, string>;
16
- }
17
-
18
- declare class EventEmitter {
19
- private events;
20
- on(event: string, listener: (...args: any[]) => void): this;
21
- off(event: string, listener: (...args: any[]) => void): this;
22
- emit(event: string, ...args: any[]): boolean;
23
- }
1
+ import { ContextData } from './types';
2
+ import { EventEmitter } from './types';
3
+ import { ScreenshotOptions } from './types';
4
+ import { SDKConfig } from './types';
5
+ import { UIAction } from './types';
24
6
 
25
7
  /**
26
8
  * Initialize Floe SDK
@@ -72,6 +54,20 @@ export declare interface FloeConfig {
72
54
  userInfo?: FloeUserInfo;
73
55
  /** Skip the welcome modal for returning users */
74
56
  skipOnboardingModal?: boolean;
57
+ /** Nudge configuration - Intercom Fin-style sliding notification */
58
+ nudge?: FloeNudgeConfig;
59
+ }
60
+
61
+ /**
62
+ * Nudge configuration for Intercom Fin-style sliding notification
63
+ */
64
+ export declare interface FloeNudgeConfig {
65
+ /** Main nudge message (default: "Hi 👋 How can I help you today?") */
66
+ text?: string;
67
+ /** Auto-show nudge when minimized (default: true) */
68
+ autoShow?: boolean;
69
+ /** Auto-hide after ms, 0 = never (default: 0) */
70
+ autoHideDelay?: number;
75
71
  }
76
72
 
77
73
  /**
@@ -126,6 +122,7 @@ declare class OnboardingSDK extends EventEmitter {
126
122
  private botAudioAnalyzer;
127
123
  private userAudioAnalyzer;
128
124
  private userMicStream;
125
+ private userMicStreamRequestId;
129
126
  private audioElements;
130
127
  private pageTracker;
131
128
  private screenShareEnabled;
@@ -138,12 +135,20 @@ declare class OnboardingSDK extends EventEmitter {
138
135
  private endUserStatus;
139
136
  private connectionProgress;
140
137
  private isReturningUser;
138
+ private hasSkippedOnboarding;
141
139
  private _isMinimized;
140
+ private textModeEnabled;
141
+ private planProgress;
142
142
  constructor(config: SDKConfig);
143
143
  /**
144
144
  * Generate unique session ID
145
145
  */
146
146
  private generateSessionId;
147
+ /**
148
+ * Validate client key and check if bot is enabled for this site.
149
+ * This is called before showing any UI to ensure the bot should be displayed.
150
+ */
151
+ private validateClientKeyAndBotStatus;
147
152
  /**
148
153
  * Start screen sharing: sends the tab/window as a WebRTC video track to Pipecat.
149
154
  */
@@ -152,10 +157,20 @@ declare class OnboardingSDK extends EventEmitter {
152
157
  * Initialize the SDK and connect to servers
153
158
  */
154
159
  init(): Promise<void>;
160
+ /**
161
+ * Setup navigation detection for page navigation events.
162
+ * Ensures navigationCompleteDetector is instantiated and started regardless
163
+ * of text/voice mode — navigation tracking is needed in both modes so the
164
+ * server always knows the current page context.
165
+ */
166
+ private setupNavigationDetection;
155
167
  /**
156
168
  * Setup audio playback for bot audio tracks with real-time level analysis.
157
- * Centralizes all audio element handling, analyzer instantiation, and navigation detector setup.
158
- * This is the single source of truth for audio/navigation initialization to prevent duplicates.
169
+ * Centralizes all audio element handling and analyzer instantiation.
170
+ * This is the single source of truth for audio initialization to prevent duplicates.
171
+ *
172
+ * Note: Navigation detection is handled separately by setupNavigationDetection()
173
+ * so it works in both voice and text modes.
159
174
  */
160
175
  private setupAudioPlayback;
161
176
  /**
@@ -269,6 +284,32 @@ declare class OnboardingSDK extends EventEmitter {
269
284
  * Actions: highlight, click, type, focus, hover, scroll
270
285
  */
271
286
  private handleHybridAction;
287
+ /**
288
+ * Wait for navigation to complete by polling the current URL.
289
+ * Compares normalized URL components (origin, pathname, search, hash)
290
+ * to avoid false positives from substring matching.
291
+ *
292
+ * @param expectedUrl - Absolute URL we're navigating to (already resolved)
293
+ * @param timeoutMs - Maximum time to wait in milliseconds
294
+ * @returns true if navigation was observed, false if timed out
295
+ */
296
+ private waitForNavigation;
297
+ /**
298
+ * Finalize any pending bot navigation that was interrupted by a full-page load.
299
+ *
300
+ * When navigate sets `window.location.href` for a cross-origin or MPA target the
301
+ * entire JS context is destroyed, so the optimistic sendMetadata never fires.
302
+ * The navigate handler persists a record to sessionStorage before triggering
303
+ * the navigation. On the next page load this method reads it back, validates
304
+ * that we actually arrived at the expected destination, and sends the final
305
+ * bot_action_complete metadata so the server can auto-advance the task.
306
+ *
307
+ * Called once during init() — safe to call before the WebRTC transport is
308
+ * connected because sendMetadata already guards on `this.isConnected`.
309
+ * We retry briefly after init to cover the case where the transport
310
+ * connects a moment later.
311
+ */
312
+ private _finalizePendingNavigation;
272
313
  /**
273
314
  * Check a precondition and report the result to the server.
274
315
  * Used for conditional task execution (e.g., check if an option exists before selecting it).
@@ -291,8 +332,23 @@ declare class OnboardingSDK extends EventEmitter {
291
332
  */
292
333
  private handleDropdownOptionClick;
293
334
  /**
294
- * Find a visible dropdown option by text
295
- * Uses STRICT matching to avoid selecting wrong options
335
+ * Check if a dropdown/listbox is currently open on the page.
336
+ * Delegates to shared dropdown-helpers module.
337
+ */
338
+ private isDropdownCurrentlyOpen;
339
+ /**
340
+ * Find the search input within or associated with a dropdown.
341
+ * Delegates to shared dropdown-helpers module.
342
+ */
343
+ private findDropdownSearchInput;
344
+ /**
345
+ * Type text into a dropdown search input to filter options, then find the target option.
346
+ * Delegates to shared dropdown-helpers module.
347
+ */
348
+ private typeToFilterDropdown;
349
+ /**
350
+ * Find a visible dropdown option by text.
351
+ * Delegates to shared dropdown-helpers module.
296
352
  */
297
353
  private findVisibleDropdownOption;
298
354
  /**
@@ -345,6 +401,24 @@ declare class OnboardingSDK extends EventEmitter {
345
401
  * @returns true if action succeeded
346
402
  */
347
403
  private executeActionFast;
404
+ /**
405
+ * Handle direct API execution request from server
406
+ * Part of Capability-Based Guidance - allows bot to execute APIs directly
407
+ *
408
+ * The SDK makes the fetch() call with the user's session/cookies,
409
+ * then reports the result back to the bot.
410
+ */
411
+ private handleExecuteApi;
412
+ /**
413
+ * Evaluate a JSONPath-style condition (simple implementation)
414
+ * Supports: $.path.to.value == "expected" or just $.path.to.value (truthy check)
415
+ */
416
+ private evaluateJsonPathCondition;
417
+ /**
418
+ * Extract value from object using simple JSONPath
419
+ * Supports: $.path.to.value or just path.to.value
420
+ */
421
+ private extractJsonPath;
348
422
  /**
349
423
  * Handle batched navigation request from server
350
424
  * Executes multiple navigation steps quickly without LLM round-trips
@@ -387,9 +461,25 @@ declare class OnboardingSDK extends EventEmitter {
387
461
  * Public API Methods
388
462
  */
389
463
  /**
390
- * Send text message
464
+ * Send text message (low-level)
391
465
  */
392
466
  sendText(text: string): Promise<void>;
467
+ /**
468
+ * Toggle text mode on/off
469
+ * When text mode is enabled, mic is muted and user types messages.
470
+ * When disabled, mic is re-enabled and voice mode resumes.
471
+ */
472
+ toggleTextMode(): void;
473
+ /**
474
+ * Send a text message with optimistic UI update.
475
+ * Uses custom 'text_message' RTVI message type (Approach B) instead of
476
+ * Pipecat's native send-text, so the server-side handler can run the full
477
+ * processing pipeline (state machine, system prompt refresh, activity
478
+ * recording, goal extraction, transcript recording) — not just LLM injection.
479
+ *
480
+ * In text mode, TTS is skipped (audio_response: false).
481
+ */
482
+ sendTextMessage(text: string): Promise<void>;
393
483
  /**
394
484
  * Toggle microphone mute
395
485
  */
@@ -503,59 +593,4 @@ declare class OnboardingSDK extends EventEmitter {
503
593
  disconnect(): Promise<void>;
504
594
  }
505
595
 
506
- declare interface PageStructure {
507
- title: string;
508
- url: string;
509
- elements: ElementInfo[];
510
- viewport: {
511
- width: number;
512
- height: number;
513
- };
514
- }
515
-
516
- declare interface ScreenshotOptions {
517
- redact?: boolean;
518
- scale?: number;
519
- quality?: number;
520
- format?: 'webp' | 'jpeg' | 'png';
521
- }
522
-
523
- declare interface SDKConfig {
524
- clientKey: string;
525
- apiUrl?: string;
526
- enableVideo?: boolean;
527
- enableAudio?: boolean;
528
- enableScreenCapture?: boolean;
529
- redactionPatterns?: Record<string, RegExp>;
530
- debug?: boolean;
531
- industry?: string;
532
- useCase?: string;
533
- companyName?: string;
534
- companySize?: string;
535
- role?: string;
536
- userInfo?: UserInfo;
537
- skipOnboardingModal?: boolean;
538
- enableDiscoveryPopup?: boolean;
539
- }
540
-
541
- declare interface UIAction {
542
- type: 'click' | 'type' | 'select' | 'hover' | 'scroll';
543
- selector: string;
544
- value?: string;
545
- description?: string;
546
- }
547
-
548
- /**
549
- * AI Onboarding Agent SDK
550
- * Voice-first onboarding platform with WebRTC connectivity to Pipecat server
551
- */
552
- declare interface UserInfo {
553
- externalId?: string;
554
- email?: string;
555
- name?: string;
556
- company?: string;
557
- designation?: string;
558
- metadata?: Record<string, any>;
559
- }
560
-
561
596
  export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floe-ai/sdk",
3
- "version": "0.1.0-dev.3",
3
+ "version": "0.1.0-dev.30",
4
4
  "description": "Floe AI Onboarding SDK for React applications",
5
5
  "type": "module",
6
6
  "main": "./dist-sdk/floe-sdk.es.js",
@@ -35,7 +35,9 @@
35
35
  "serve": "node serve-dist.js",
36
36
  "serve:sdk": "vite preview --config vite.config.sdk.ts --port 5174",
37
37
  "clean": "rm -rf dist dist-sdk",
38
- "prepublishOnly": "npm run build:sdk"
38
+ "test": "vitest run",
39
+ "test:watch": "vitest",
40
+ "test:coverage": "vitest run --coverage"
39
41
  },
40
42
  "peerDependencies": {
41
43
  "react": "^18.0.0 || ^19.0.0",
@@ -52,6 +54,7 @@
52
54
  "@types/react": "^18.2.0 || ^19.0.0",
53
55
  "@types/react-dom": "^18.2.0 || ^19.0.0",
54
56
  "@vitejs/plugin-react": "^4.2.0",
57
+ "@vitest/coverage-v8": "^4.0.18",
55
58
  "cors": "^2.8.5",
56
59
  "express": "^5.1.0",
57
60
  "patch-package": "^8.0.0",
@@ -59,7 +62,8 @@
59
62
  "react-dom": "^18.2.0",
60
63
  "typescript": "^5.3.0",
61
64
  "vite": "^5.0.0",
62
- "vite-plugin-dts": "^4.0.0"
65
+ "vite-plugin-dts": "^4.0.0",
66
+ "vitest": "^4.0.18"
63
67
  },
64
68
  "keywords": [
65
69
  "floe",