guideai-app 0.2.4 → 0.2.6

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 (65) hide show
  1. package/GuideAI.js +1 -1
  2. package/GuideAI.js.map +1 -1
  3. package/README.md +39 -1
  4. package/dist/GuideAI.js +1 -1
  5. package/dist/GuideAI.js.map +1 -1
  6. package/dist/components/TextInput.d.ts +8 -0
  7. package/dist/components/TranscriptBox.d.ts +17 -0
  8. package/dist/index.d.ts +2 -0
  9. package/dist/metric/event-listner.d.ts +113 -0
  10. package/dist/metric/index.d.ts +4 -0
  11. package/dist/metric/metadata-tracker.d.ts +33 -0
  12. package/dist/styles/GuideAI.styles.d.ts +1 -1
  13. package/dist/types/GuideAI.types.d.ts +18 -0
  14. package/dist/types/metadata.types.d.ts +46 -0
  15. package/dist/utils/api.d.ts +4 -0
  16. package/dist/utils/constants.d.ts +1 -1
  17. package/dist/utils/messageStorage.d.ts +1 -1
  18. package/metadata-tracking-example.md +324 -0
  19. package/package.json +1 -1
  20. package/text-input-usage.md +321 -0
  21. package/transcript-toggle-usage.md +267 -0
  22. package/dist/GuideAI.js.LICENSE.txt +0 -16
  23. package/dist/components/Styles.d.ts +0 -3
  24. package/dist/components/Styles.js +0 -6
  25. package/dist/components/Styles.js.map +0 -1
  26. package/dist/hooks/useConversation.d.ts +0 -11
  27. package/dist/hooks/useConversation.js +0 -286
  28. package/dist/hooks/useConversation.js.map +0 -1
  29. package/dist/hooks/useRecording.d.ts +0 -12
  30. package/dist/hooks/useRecording.js +0 -362
  31. package/dist/hooks/useRecording.js.map +0 -1
  32. package/dist/index.esm.js +0 -1
  33. package/dist/index.esm.js.map +0 -1
  34. package/dist/index.js +0 -1
  35. package/dist/index.js.map +0 -1
  36. package/dist/messageStorageUtils.d.ts +0 -26
  37. package/dist/types/index.d.ts +0 -20
  38. package/dist/types/index.js +0 -2
  39. package/dist/types/index.js.map +0 -1
  40. package/dist/types/workflow.d.ts +0 -24
  41. package/dist/types.d.ts +0 -1
  42. package/dist/types.js +0 -2
  43. package/dist/types.js.map +0 -1
  44. package/dist/utils/api-services.d.ts +0 -5
  45. package/dist/utils/api-services.js +0 -203
  46. package/dist/utils/api-services.js.map +0 -1
  47. package/dist/utils/dom-interaction.d.ts +0 -2
  48. package/dist/utils/dom-interaction.js +0 -195
  49. package/dist/utils/dom-interaction.js.map +0 -1
  50. package/dist/utils/dom.d.ts +0 -1
  51. package/dist/utils/messageStorageUtils.d.ts +0 -26
  52. package/dist/utils/react-hooks.d.ts +0 -9
  53. package/dist/utils/react-hooks.js +0 -19
  54. package/dist/utils/react-hooks.js.map +0 -1
  55. package/dist/utils/storage.d.ts +0 -14
  56. package/dist/utils/storage.js +0 -27
  57. package/dist/utils/storage.js.map +0 -1
  58. package/dist/utils/webrtc.d.ts +0 -3
  59. package/dist/utils/webrtc.js +0 -135
  60. package/dist/utils/webrtc.js.map +0 -1
  61. package/dist/utils/workflowUtils.d.ts +0 -17
  62. package/dist/utils/workflowValidator.d.ts +0 -17
  63. package/dist/workflows/certificateWorkflow.d.ts +0 -7
  64. package/dist/workflows/index.d.ts +0 -6
  65. package/todo.md +0 -2
@@ -0,0 +1,267 @@
1
+ # Transcript Toggle Feature - Usage Guide
2
+
3
+ ## Overview
4
+
5
+ The GuideAI package now includes a transcript toggle feature that allows users to show/hide the conversation transcript and provides programmatic control over transcript visibility.
6
+
7
+ ## Features
8
+
9
+ ✅ **Toggle Button**: Optional button that appears in the transcript area (bottom-right corner)
10
+ ✅ **Programmatic Control**: Global API methods to control transcript visibility
11
+ ✅ **Configurable Default State**: Set whether transcript shows by default
12
+ ✅ **Auto-Show/Hide**: Configure whether transcript automatically appears with conversations
13
+ ✅ **Visual Feedback**: Clear visual indicators for transcript state
14
+
15
+ ## Configuration Options
16
+
17
+ ### Basic Configuration
18
+
19
+ ```typescript
20
+ <GuideAI
21
+ organizationKey="your-org-key"
22
+ transcript={{
23
+ enabled: true, // Show transcript by default (default: true)
24
+ showToggleButton: true, // Show the toggle button (default: true)
25
+ position: 'right' // Position of transcript (default: 'right')
26
+ }}
27
+ />
28
+ ```
29
+
30
+ ### Configuration Options
31
+
32
+ ```typescript
33
+ interface TranscriptConfig {
34
+ // Whether to show transcript by default when conversations start
35
+ enabled?: boolean; // default: true
36
+
37
+ // Whether to show the toggle button near the main icon
38
+ showToggleButton?: boolean; // default: true
39
+
40
+ // Position of the transcript box (future enhancement)
41
+ position?: 'right' | 'left' | 'top' | 'bottom'; // default: 'right'
42
+ }
43
+ ```
44
+
45
+ ## Usage Examples
46
+
47
+ ### 1. Default Configuration (Transcript Enabled)
48
+
49
+ ```typescript
50
+ // Transcript shows by default with toggle button
51
+ <GuideAI organizationKey="your-org-key" />
52
+ ```
53
+
54
+ ### 2. Transcript Disabled by Default
55
+
56
+ ```typescript
57
+ <GuideAI
58
+ organizationKey="your-org-key"
59
+ transcript={{
60
+ enabled: false, // Don't show by default
61
+ showToggleButton: true // But provide toggle button
62
+ }}
63
+ />
64
+ ```
65
+
66
+ ### 3. No Toggle Button (Manual Control Only)
67
+
68
+ ```typescript
69
+ <GuideAI
70
+ organizationKey="your-org-key"
71
+ transcript={{
72
+ enabled: true,
73
+ showToggleButton: false // Hide the toggle button
74
+ }}
75
+ />
76
+ ```
77
+
78
+ ### 4. Completely Hidden Transcript
79
+
80
+ ```typescript
81
+ <GuideAI
82
+ organizationKey="your-org-key"
83
+ transcript={{
84
+ enabled: false,
85
+ showToggleButton: false // No button, no auto-show
86
+ }}
87
+ />
88
+ ```
89
+
90
+ ## Programmatic Control
91
+
92
+ ### Global API Methods
93
+
94
+ Access transcript controls via the global `window.GuideAI.transcript` object:
95
+
96
+ ```typescript
97
+ // Toggle transcript visibility
98
+ window.GuideAI.transcript.toggle();
99
+
100
+ // Show transcript
101
+ window.GuideAI.transcript.show();
102
+
103
+ // Hide transcript
104
+ window.GuideAI.transcript.hide();
105
+
106
+ // Check if transcript is currently visible
107
+ const isVisible = window.GuideAI.transcript.isVisible();
108
+ console.log('Transcript visible:', isVisible);
109
+ ```
110
+
111
+ ### Integration Examples
112
+
113
+ #### Custom Toggle Button
114
+
115
+ ```typescript
116
+ function MyCustomControls() {
117
+ const [transcriptVisible, setTranscriptVisible] = useState(false);
118
+
119
+ const handleToggle = () => {
120
+ window.GuideAI.transcript.toggle();
121
+ setTranscriptVisible(window.GuideAI.transcript.isVisible());
122
+ };
123
+
124
+ return (
125
+ <button onClick={handleToggle}>
126
+ {transcriptVisible ? 'Hide' : 'Show'} Transcript
127
+ </button>
128
+ );
129
+ }
130
+ ```
131
+
132
+ #### Keyboard Shortcuts
133
+
134
+ ```typescript
135
+ useEffect(() => {
136
+ const handleKeyPress = (event) => {
137
+ // Toggle transcript with Ctrl/Cmd + T
138
+ if ((event.ctrlKey || event.metaKey) && event.key === 't') {
139
+ event.preventDefault();
140
+ window.GuideAI.transcript.toggle();
141
+ }
142
+ };
143
+
144
+ document.addEventListener('keydown', handleKeyPress);
145
+ return () => document.removeEventListener('keydown', handleKeyPress);
146
+ }, []);
147
+ ```
148
+
149
+ #### Auto-Hide on Mobile
150
+
151
+ ```typescript
152
+ useEffect(() => {
153
+ const isMobile = window.innerWidth < 768;
154
+
155
+ if (isMobile) {
156
+ // Hide transcript on mobile by default
157
+ window.GuideAI.transcript.hide();
158
+ }
159
+ }, []);
160
+ ```
161
+
162
+ ## Visual Design
163
+
164
+ ### Toggle Button
165
+
166
+ - **Position**: Appears as a floating circular button in the bottom-right corner, above the transcript area
167
+ - **Icons**: 📄 (when visible) / 📋 (when hidden)
168
+ - **Hover Effects**: Scales up and shows tooltip
169
+ - **Animation**: Smooth fade-in when conversation starts
170
+ - **Design**: Dark themed button with blur effect to match transcript styling
171
+
172
+ ### States
173
+
174
+ - **Visible**: 📄 icon with full opacity
175
+ - **Hidden**: 📋 icon with reduced opacity
176
+ - **Hover**: Scale animation and enhanced shadow
177
+
178
+ ## Behavior Details
179
+
180
+ ### When Toggle Button Appears
181
+
182
+ The toggle button only shows when:
183
+ 1. `showToggleButton` is not set to `false`
184
+ 2. A conversation is active (`isConversationActive === true`)
185
+ 3. There are messages in the conversation (`allMessages.length > 0`)
186
+
187
+ ### Auto-Show/Hide Logic
188
+
189
+ - **Conversation Start**: If `enabled !== false`, transcript shows automatically
190
+ - **Conversation End**: If `enabled !== false`, transcript hides automatically
191
+ - **Manual Toggle**: User's manual toggle state persists until next conversation start/end
192
+
193
+ ### Persistence
194
+
195
+ The transcript toggle state does **not** persist across page reloads - it resets to the configured default (`enabled` setting).
196
+
197
+ ## Advanced Integration
198
+
199
+ ### Custom Positioning (Future Enhancement)
200
+
201
+ ```typescript
202
+ // Future feature - custom transcript positioning
203
+ <GuideAI
204
+ transcript={{
205
+ position: 'left', // Position transcript on the left side
206
+ enabled: true
207
+ }}
208
+ />
209
+ ```
210
+
211
+ ### Event Listeners (Future Enhancement)
212
+
213
+ ```typescript
214
+ // Future feature - listen to transcript visibility changes
215
+ window.GuideAI.transcript.onVisibilityChange((isVisible) => {
216
+ console.log('Transcript visibility changed:', isVisible);
217
+ // Update your UI accordingly
218
+ });
219
+ ```
220
+
221
+ ## Troubleshooting
222
+
223
+ ### Toggle Button Not Appearing
224
+
225
+ Check that:
226
+ 1. `showToggleButton` is not set to `false`
227
+ 2. A conversation is active
228
+ 3. Messages exist in the conversation
229
+ 4. CSS styles are loaded properly
230
+
231
+ ### Programmatic Methods Not Working
232
+
233
+ Ensure:
234
+ 1. GuideAI has finished initializing
235
+ 2. You're calling methods after component mount
236
+ 3. The global API is available: `window.GuideAI.transcript`
237
+
238
+ ### Styling Issues
239
+
240
+ The toggle button uses these CSS classes:
241
+ - `.guideai-transcript-toggle` - Main button container
242
+ - `.guideai-transcript-icon` - Icon styling
243
+ - `.guideai-transcript-icon.visible` - When transcript is visible
244
+ - `.guideai-transcript-icon.hidden` - When transcript is hidden
245
+
246
+ ## Migration Guide
247
+
248
+ ### Existing Implementations
249
+
250
+ If you're using GuideAI without transcript config, no changes needed:
251
+ ```typescript
252
+ // This continues to work - transcript enabled by default
253
+ <GuideAI organizationKey="your-org-key" />
254
+ ```
255
+
256
+ ### To Disable Transcript
257
+
258
+ ```typescript
259
+ // Old: No way to disable
260
+ // New: Explicit control
261
+ <GuideAI
262
+ organizationKey="your-org-key"
263
+ transcript={{ enabled: false }}
264
+ />
265
+ ```
266
+
267
+ This implementation provides flexible control over transcript visibility while maintaining backward compatibility with existing code.
@@ -1,16 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2023 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- declare const Styles: React.FC;
3
- export default Styles;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- var Styles = function () {
3
- return (React.createElement("style", null, "\n .sarge-main-ui {\n position: relative;\n } \n \n .sarge-welcome-bubble {\n position: absolute;\n top: 70px;\n left: 50%;\n transform: translateX(-50%);\n background: #0066ff;\n color: white;\n padding: 8px 16px;\n border-radius: 20px;\n font-size: 14px;\n white-space: nowrap;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);\n animation: bubble-pulse 2s infinite;\n }\n\n .sarge-welcome-bubble::after {\n content: '';\n position: absolute;\n top: -8px;\n left: 50%;\n transform: translateX(-50%);\n border-left: 8px solid transparent;\n border-right: 8px solid transparent;\n border-bottom: 8px solid #0066ff;\n }\n\n @keyframes bubble-pulse {\n 0% { transform: translateX(-50%) scale(1); }\n 50% { transform: translateX(-50%) scale(1.05); }\n 100% { transform: translateX(-50%) scale(1); }\n }\n \n .sarge-icon-wrapper {\n width: 60px;\n height: 60px;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: rgba(255, 255, 255, 0.9);\n border-radius: 50%;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);\n cursor: pointer;\n transition: all 0.2s ease;\n }\n \n .sarge-icon-wrapper:not(.initializing):hover {\n transform: scale(1.1);\n }\n \n .sarge-icon-wrapper.initializing {\n background-color: rgba(255, 255, 255, 0.9);\n box-shadow: 0 0 0 2px rgba(128, 128, 128, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);\n animation: sarge-spin 1.5s linear infinite;\n opacity: 0.7;\n cursor: default;\n }\n \n .sarge-icon-wrapper.recording {\n background-color: rgba(255, 255, 255, 0.9);\n box-shadow: 0 0 0 2px rgba(255, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);\n animation: sarge-pulse 1s infinite alternate;\n }\n \n .sarge-icon-wrapper.processing {\n background-color: rgba(255, 255, 255, 0.9);\n box-shadow: 0 0 0 2px rgba(255, 165, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);\n animation: sarge-spin 1s linear infinite;\n }\n \n .sarge-icon-wrapper.playing {\n background-color: rgba(255, 255, 255, 0.9);\n box-shadow: 0 0 0 2px rgba(0, 128, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);\n }\n \n @keyframes sarge-pulse {\n 0% { transform: scale(1); }\n 100% { transform: scale(1.05); }\n }\n \n @keyframes sarge-spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n \n @keyframes click-ripple-animation {\n 0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }\n 50% { transform: translate(-50%, -50%) scale(1.2); opacity: 0.6; }\n 100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }\n }\n \n @keyframes click-dot-animation {\n 0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }\n 60% { transform: translate(-50%, -50%) scale(1); opacity: 1; }\n 100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }\n }\n \n @keyframes cursor-jiggle {\n 0% { transform: translate(-50%, 0) scale(1); }\n 25% { transform: translate(-50%, -5px) scale(1.1); }\n 50% { transform: translate(-50%, 0) scale(1); }\n 75% { transform: translate(-50%, 5px) scale(1.1); }\n 100% { transform: translate(-50%, 0) scale(1); filter: drop-shadow(0 0 8px #0066ff); }\n }\n \n .sarge-icon {\n width: 40px;\n height: 40px;\n background-size: contain;\n background-repeat: no-repeat;\n background-position: center;\n }\n \n .sarge-icon.initializing {\n background-image: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\"><path fill=\"%23808080\" d=\"M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z\"/></svg>');\n }\n \n .sarge-icon.microphone {\n background-image: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 352 512\"><path fill=\"%230000FF\" d=\"M176 352c53.02 0 96-42.98 96-96V96c0-53.02-42.98-96-96-96S80 42.98 80 96v160c0 53.02 42.98 96 96 96zm160-160h-16c-8.84 0-16 7.16-16 16v48c0 74.8-64.49 134.82-140.79 127.38C96.71 376.89 48 317.11 48 250.3V208c0-8.84-7.16-16-16-16H16c-8.84 0-16 7.16-16 16v40.16c0 89.64 63.97 169.55 152 181.69V464H96c-8.84 0-16 7.16-16 16v16c0 8.84 7.16 16 16 16h160c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16h-56v-33.77C285.71 418.47 352 344.9 352 256v-48c0-8.84-7.16-16-16-16z\"/></svg>');\n }\n \n .sarge-icon.recording {\n background-image: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\"><circle cx=\"256\" cy=\"256\" r=\"128\" fill=\"%23FF0000\"/><circle cx=\"256\" cy=\"256\" r=\"200\" stroke=\"%23FF0000\" stroke-width=\"20\" fill=\"none\"/></svg>');\n }\n \n .sarge-icon.processing {\n background-image: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\"><path fill=\"%23FFA500\" d=\"M304 48c0 26.51-21.49 48-48 48s-48-21.49-48-48 21.49-48 48-48 48 21.49 48 48zm-48 368c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm208-208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM96 256c0-26.51-21.49-48-48-48S0 229.49 0 256s21.49 48 48 48 48-21.49 48-48zm12.922 99.078c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.491-48-48-48zm294.156 0c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48c0-26.509-21.49-48-48-48zM108.922 60.922c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.491-48-48-48z\"/></svg>');\n }\n \n .sarge-icon.playing {\n background-image: url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"%23008000\" d=\"M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z\"/></svg>');\n }\n \n .sarge-response {\n position: absolute;\n top: -70px;\n left: 50%;\n transform: translateX(-50%);\n background: white;\n padding: 12px;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\n max-width: 250px;\n text-align: center;\n min-width: 180px;\n }\n "));
4
- };
5
- export default Styles;
6
- //# sourceMappingURL=Styles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Styles.js","sourceRoot":"","sources":["../../src/components/Styles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,IAAM,MAAM,GAAa;IACvB,OAAO,CACL,mCAAQ,umOA0JP,CAAS,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1,11 +0,0 @@
1
- import { ConversationItem } from '../types';
2
- export declare const useConversation: (organizationKey: string, onError: (error: string | Error, context?: string) => void) => {
3
- conversationItems: ConversationItem[];
4
- conversationIdRef: import("react").MutableRefObject<string | null>;
5
- storeConversationItem: (eventData: any) => void;
6
- updateConversationItem: (itemId: string, updateData: Partial<any>) => void;
7
- logMessageToConversation: (content: string, sender: "GUIDEAI" | "HUMAN") => Promise<void>;
8
- addConversationHistory: (sendMessageFn: (message: any) => void) => void;
9
- isAddingHistoryContext: import("react").MutableRefObject<boolean>;
10
- hasCreatedConversationRef: import("react").MutableRefObject<boolean>;
11
- };
@@ -1,286 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
23
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- var __rest = (this && this.__rest) || function (s, e) {
49
- var t = {};
50
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
- t[p] = s[p];
52
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
- t[p[i]] = s[p[i]];
56
- }
57
- return t;
58
- };
59
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
60
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
61
- if (ar || !(i in from)) {
62
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
63
- ar[i] = from[i];
64
- }
65
- }
66
- return to.concat(ar || Array.prototype.slice.call(from));
67
- };
68
- import { useEffect, useRef, useState } from 'react';
69
- import { getFromStorage, saveToStorage, STORAGE_KEYS } from '../utils/storage';
70
- import { createNewConversation, logMessage } from '../utils/api-services';
71
- var orderConversationItems = function (items) {
72
- var _a, _b;
73
- // Clone array to avoid modifying original
74
- var itemsToProcess = __spreadArray([], items, true);
75
- var orderedItems = [];
76
- // Find the first item (one with no previous_item_id or oldest if multiple)
77
- var rootItems = itemsToProcess.filter(function (item) { return !item.previous_item_id; });
78
- if (rootItems.length === 0 && itemsToProcess.length > 0) {
79
- // If no items without previous_item_id, take the oldest item
80
- rootItems = [itemsToProcess.reduce(function (oldest, current) {
81
- return (oldest.timestamp < current.timestamp) ? oldest : current;
82
- })];
83
- }
84
- if (rootItems.length > 0) {
85
- // Start with the first root item
86
- var firstItem_1 = rootItems.sort(function (a, b) { return a.timestamp - b.timestamp; })[0];
87
- orderedItems.push(firstItem_1);
88
- // Need to check item.item.id instead of item.id with the new structure
89
- itemsToProcess.splice(itemsToProcess.findIndex(function (i) { var _a, _b; return ((_a = i.item) === null || _a === void 0 ? void 0 : _a.id) === ((_b = firstItem_1.item) === null || _b === void 0 ? void 0 : _b.id); }), 1);
90
- // Build the chain of items
91
- var currentId_1 = (_a = firstItem_1.item) === null || _a === void 0 ? void 0 : _a.id;
92
- // Safety counter to prevent infinite loops
93
- var iterations = 0;
94
- var maxIterations = 100;
95
- var _loop_1 = function () {
96
- iterations++;
97
- // Find next item in chain
98
- var nextItem = itemsToProcess.find(function (item) { return item.previous_item_id === currentId_1; });
99
- if (nextItem) {
100
- orderedItems.push(nextItem);
101
- itemsToProcess.splice(itemsToProcess.findIndex(function (i) { var _a, _b; return ((_a = i.item) === null || _a === void 0 ? void 0 : _a.id) === ((_b = nextItem.item) === null || _b === void 0 ? void 0 : _b.id); }), 1);
102
- currentId_1 = (_b = nextItem.item) === null || _b === void 0 ? void 0 : _b.id;
103
- }
104
- else {
105
- return "break";
106
- }
107
- };
108
- while (itemsToProcess.length > 0 && iterations < maxIterations) {
109
- var state_1 = _loop_1();
110
- if (state_1 === "break")
111
- break;
112
- }
113
- // Add any remaining items (in case of broken chains)
114
- if (itemsToProcess.length > 0) {
115
- itemsToProcess.sort(function (a, b) { return a.timestamp - b.timestamp; });
116
- orderedItems.push.apply(orderedItems, itemsToProcess);
117
- }
118
- }
119
- else {
120
- // If no items at all, return empty array
121
- return [];
122
- }
123
- return orderedItems;
124
- };
125
- export var useConversation = function (organizationKey, onError) {
126
- var _a = useState(function () {
127
- return getFromStorage(STORAGE_KEYS.CONVERSATION_ITEMS, []);
128
- }), conversationItems = _a[0], setConversationItems = _a[1];
129
- var conversationIdRef = useRef(getFromStorage(STORAGE_KEYS.CONVERSATION_ID, null));
130
- var hasCreatedConversationRef = useRef(!!conversationIdRef.current);
131
- var isAddingHistoryContext = useRef(false);
132
- var isInitializingRef = useRef(false);
133
- // Check if the conversation is stale (more than 15 minutes old)
134
- var isConversationStale = function () {
135
- var lastActivity = getFromStorage(STORAGE_KEYS.LAST_ACTIVITY, 0);
136
- if (!lastActivity)
137
- return true;
138
- var now = Date.now();
139
- var fifteenMinutesMs = 15 * 60 * 1000;
140
- return (now - lastActivity) > fifteenMinutesMs;
141
- };
142
- var storeConversationItem = function (eventData) {
143
- var conversationItem = {
144
- event_id: eventData.event_id,
145
- type: eventData.type,
146
- previous_item_id: eventData.previous_item_id || null,
147
- item: eventData.item ? (function (_a) {
148
- var object = _a.object, rest = __rest(_a, ["object"]);
149
- return rest;
150
- })(eventData.item) : {},
151
- timestamp: Date.now()
152
- };
153
- saveToStorage(STORAGE_KEYS.LAST_ACTIVITY, conversationItem.timestamp);
154
- setConversationItems(function (prevItems) {
155
- // Replace the item if it already exists by item.id
156
- var exists = prevItems.some(function (existing) { var _a; return existing.item && existing.item.id === ((_a = conversationItem.item) === null || _a === void 0 ? void 0 : _a.id); });
157
- var updatedItems = exists
158
- ? prevItems.map(function (existing) {
159
- var _a;
160
- return existing.item && existing.item.id === ((_a = conversationItem.item) === null || _a === void 0 ? void 0 : _a.id)
161
- ? conversationItem
162
- : existing;
163
- })
164
- : __spreadArray(__spreadArray([], prevItems, true), [conversationItem], false);
165
- // Keep only the last 20 items to avoid localStorage size limits
166
- if (updatedItems.length > 20) {
167
- updatedItems = updatedItems.slice(-20);
168
- }
169
- saveToStorage(STORAGE_KEYS.CONVERSATION_ITEMS, updatedItems);
170
- return updatedItems;
171
- });
172
- };
173
- var updateConversationItem = function (itemId, updateData) {
174
- if (!itemId)
175
- return;
176
- console.log('updateConversationItem', itemId, updateData);
177
- setConversationItems(function (prevItems) {
178
- var updatedItems = prevItems.map(function (item) {
179
- var _a;
180
- if (((_a = item.item) === null || _a === void 0 ? void 0 : _a.id) === itemId) {
181
- return __assign(__assign({}, item), { item: __assign(__assign({}, item.item), updateData) });
182
- }
183
- return item;
184
- });
185
- saveToStorage(STORAGE_KEYS.CONVERSATION_ITEMS, updatedItems);
186
- saveToStorage(STORAGE_KEYS.LAST_ACTIVITY, Date.now());
187
- return updatedItems;
188
- });
189
- };
190
- var initializeConversation = function () { return __awaiter(void 0, void 0, void 0, function () {
191
- var newConversationId;
192
- return __generator(this, function (_a) {
193
- switch (_a.label) {
194
- case 0:
195
- if (isInitializingRef.current)
196
- return [2 /*return*/];
197
- isInitializingRef.current = true;
198
- _a.label = 1;
199
- case 1:
200
- _a.trys.push([1, , 4, 5]);
201
- // Check if conversation is stale and needs to be reset
202
- if (isConversationStale()) {
203
- console.log('Conversation is stale (>15 minutes old), creating new conversation');
204
- // Clear existing conversation history and ID
205
- setConversationItems([]);
206
- saveToStorage(STORAGE_KEYS.CONVERSATION_ITEMS, []);
207
- conversationIdRef.current = null;
208
- saveToStorage(STORAGE_KEYS.CONVERSATION_ID, null);
209
- hasCreatedConversationRef.current = false;
210
- }
211
- if (!!conversationIdRef.current) return [3 /*break*/, 3];
212
- return [4 /*yield*/, createNewConversation(organizationKey)];
213
- case 2:
214
- newConversationId = _a.sent();
215
- if (newConversationId) {
216
- conversationIdRef.current = newConversationId;
217
- saveToStorage(STORAGE_KEYS.CONVERSATION_ID, newConversationId);
218
- hasCreatedConversationRef.current = true;
219
- }
220
- _a.label = 3;
221
- case 3: return [3 /*break*/, 5];
222
- case 4:
223
- isInitializingRef.current = false;
224
- return [7 /*endfinally*/];
225
- case 5: return [2 /*return*/];
226
- }
227
- });
228
- }); };
229
- var logMessageToConversation = function (content, sender) { return __awaiter(void 0, void 0, void 0, function () {
230
- return __generator(this, function (_a) {
231
- switch (_a.label) {
232
- case 0:
233
- if (!conversationIdRef.current)
234
- return [2 /*return*/];
235
- // Just update the activity timestamp
236
- saveToStorage(STORAGE_KEYS.LAST_ACTIVITY, Date.now());
237
- return [4 /*yield*/, logMessage(conversationIdRef.current, content, sender)];
238
- case 1:
239
- _a.sent();
240
- return [2 /*return*/];
241
- }
242
- });
243
- }); };
244
- var addConversationHistory = function (sendMessageFn) {
245
- if (!conversationItems.length) {
246
- isAddingHistoryContext.current = false;
247
- return;
248
- }
249
- console.log("Adding conversation history (".concat(conversationItems.length, " items)"));
250
- // Sort conversation items in the correct order
251
- var orderedItems = orderConversationItems(conversationItems);
252
- // sendMessageFn({
253
- // type: "conversation.item.create",
254
- // item: {
255
- // id: "1",
256
- // type: "message",
257
- // role: "user",
258
- // content: [{type: "input_audio", audio: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"}]
259
- // },
260
- // previous_item_id: null
261
- // });
262
- // Add each item in the correct order
263
- orderedItems.forEach(function (item) {
264
- sendMessageFn({
265
- type: "conversation.item.create",
266
- previous_item_id: item.previous_item_id
267
- });
268
- });
269
- isAddingHistoryContext.current = false;
270
- };
271
- // Initialize conversation on mount
272
- useEffect(function () {
273
- initializeConversation();
274
- }, [organizationKey]);
275
- return {
276
- conversationItems: conversationItems,
277
- conversationIdRef: conversationIdRef,
278
- storeConversationItem: storeConversationItem,
279
- updateConversationItem: updateConversationItem,
280
- logMessageToConversation: logMessageToConversation,
281
- addConversationHistory: addConversationHistory,
282
- isAddingHistoryContext: isAddingHistoryContext,
283
- hasCreatedConversationRef: hasCreatedConversationRef
284
- };
285
- };
286
- //# sourceMappingURL=useConversation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useConversation.js","sourceRoot":"","sources":["../../src/hooks/useConversation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAE1E,IAAM,sBAAsB,GAAG,UAAC,KAAyB;;IACvD,0CAA0C;IAC1C,IAAM,cAAc,qBAAO,KAAK,OAAC,CAAC;IAClC,IAAM,YAAY,GAAuB,EAAE,CAAC;IAE5C,2EAA2E;IAC3E,IAAI,SAAS,GAAG,cAAc,CAAC,MAAM,CAAC,UAAA,IAAI,IAAI,OAAA,CAAC,IAAI,CAAC,gBAAgB,EAAtB,CAAsB,CAAC,CAAC;IACtE,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxD,6DAA6D;QAC7D,SAAS,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,UAAC,MAAM,EAAE,OAAO;gBACjD,OAAA,CAAC,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;YAAzD,CAAyD,CAC1D,CAAC,CAAC;IACL,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,iCAAiC;QACjC,IAAM,WAAS,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AAG,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;QAC/D,kBAAkB;QAClB,sCAAsC;QACtC,YAAY;QACZ,eAAe;QACf,uBAAuB;QACvB,oBAAoB;QACpB,0oBAA0oB;QAC1oB,OAAO;QACP,2BAA2B;QAC3B,MAAM;QACN,qCAAqC;QACrC,YAAY,CAAC,OAAO,CAAC,UAAA,IAAI;YACvB,aAAa,CAAC;gBACZ,IAAI,EAAE,0BAA0B;gBAChC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;aACxC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,sBAAsB,CAAC,OAAO,GAAG,KAAK,CAAC;IACzC,CAAC,CAAC;IAEF,mCAAmC;IACnC,SAAS,CAAC;QACR,sBAAsB,EAAE,CAAC;IAC3B,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;IAEtB,OAAO;QACL,iBAAiB,mBAAA;QACjB,iBAAiB,mBAAA;QACjB,qBAAqB,uBAAA;QACrB,sBAAsB,wBAAA;QACtB,wBAAwB,0BAAA;QACxB,sBAAsB,wBAAA;QACtB,sBAAsB,wBAAA;QACtB,yBAAyB,2BAAA;KAC1B,CAAC;AACJ,CAAC,CAAC"}
@@ -1,12 +0,0 @@
1
- import { RecordingStatus } from '../types';
2
- export declare const useRecording: (organizationKey: string, onError: (error: string | Error, context?: string) => void, logMessageFn: (message: string, sender: "GUIDEAI" | "HUMAN") => Promise<void>, addConversationHistoryFn: (sendMessageFn: (message: any) => void) => void, storeConversationItemFn: (item: any) => void, updateConversationItem: (itemId: string, updateData: Partial<any>) => void, isAddingHistoryContextRef: React.MutableRefObject<boolean>) => {
3
- status: RecordingStatus;
4
- isSessionReady: boolean;
5
- isConversationActive: boolean;
6
- toggleRecording: () => Promise<void>;
7
- toggleConversation: () => Promise<void>;
8
- cleanupWebRTC: () => void;
9
- audioElementRef: import("react").MutableRefObject<HTMLAudioElement | null>;
10
- ephemeralToken: string | null;
11
- setEphemeralToken: import("react").Dispatch<import("react").SetStateAction<string | null>>;
12
- };