guideai-app 0.1.8 → 0.2.0
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/dist/GuideAI.js +1 -1
- package/dist/GuideAI.js.map +1 -1
- package/dist/components/Styles.d.ts +3 -0
- package/dist/components/Styles.js +6 -0
- package/dist/components/Styles.js.map +1 -0
- package/dist/hooks/useConversation.d.ts +11 -0
- package/dist/hooks/useConversation.js +286 -0
- package/dist/hooks/useConversation.js.map +1 -0
- package/dist/hooks/useRecording.d.ts +12 -0
- package/dist/hooks/useRecording.js +362 -0
- package/dist/hooks/useRecording.js.map +1 -0
- package/dist/index.esm.js +1 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +1 -19
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +20 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/api-services.d.ts +5 -0
- package/dist/utils/api-services.js +203 -0
- package/dist/utils/api-services.js.map +1 -0
- package/dist/utils/dom-interaction.d.ts +2 -0
- package/dist/utils/dom-interaction.js +195 -0
- package/dist/utils/dom-interaction.js.map +1 -0
- package/dist/utils/react-hooks.d.ts +9 -0
- package/dist/utils/react-hooks.js +19 -0
- package/dist/utils/react-hooks.js.map +1 -0
- package/dist/utils/storage.d.ts +9 -0
- package/dist/utils/storage.js +27 -0
- package/dist/utils/storage.js.map +1 -0
- package/dist/utils/webrtc.d.ts +3 -0
- package/dist/utils/webrtc.js +135 -0
- package/dist/utils/webrtc.js.map +1 -0
- package/obfuscate.js +40 -0
- package/package.json +1 -1
- package/rollup.config.js +34 -0
- package/structure.md +128 -0
- package/todo.md +2 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webrtc.js","sourceRoot":"","sources":["../../src/utils/webrtc.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;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AO,CAAC,KAAK,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC;gBAC3C,MAAM,IAAI,KAAK,CAAC,8CAAuC,WAAW,CAAC,MAAM,gBAAM,SAAS,CAAE,CAAC,CAAC;oBAG5E,qBAAM,WAAW,CAAC,IAAI,EAAE,EAAA;;gBAApC,SAAS,GAAG,SAAwB;gBAEpC,MAAM,GAAG;oBACb,IAAI,EAAE,QAAQ;oBACd,GAAG,EAAE,SAAS;iBACf,CAAC;gBAEF,qBAAM,IAAE,CAAC,oBAAoB,CAAC,MAAmC,CAAC,EAAA;;gBAAlE,SAAkE,CAAC;gBAEnE,sBAAO,IAAI,EAAC;;;gBAEZ,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,OAAK,CAAC,CAAC;gBACnD,sBAAO,KAAK,EAAC;;;;KAEhB,CAAC;AAEF,MAAM,CAAC,IAAM,WAAW,GAAG,UACzB,WAAkC,EAClC,OAAY;IAEZ,IAAI,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,UAAU,MAAK,MAAM,EAAE,CAAC;QACvC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAC5D,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC"}
|
package/obfuscate.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const JavaScriptObfuscator = require('javascript-obfuscator');
|
|
4
|
+
|
|
5
|
+
// Files to obfuscate
|
|
6
|
+
const files = [
|
|
7
|
+
'dist/index.js',
|
|
8
|
+
'dist/index.esm.js'
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
// Load obfuscator config
|
|
12
|
+
const config = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'obfuscator.json'), 'utf8'));
|
|
13
|
+
|
|
14
|
+
// Process each file
|
|
15
|
+
|
|
16
|
+
files.forEach(file => {
|
|
17
|
+
const filePath = path.resolve(__dirname, file);
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
// Check if file exists
|
|
21
|
+
if (!fs.existsSync(filePath)) {
|
|
22
|
+
console.warn(`Warning: ${file} does not exist, skipping obfuscation.`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// Read the file
|
|
28
|
+
const code = fs.readFileSync(filePath, 'utf8');
|
|
29
|
+
|
|
30
|
+
// Obfuscate the code
|
|
31
|
+
const obfuscationResult = JavaScriptObfuscator.obfuscate(code, config);
|
|
32
|
+
|
|
33
|
+
// Write the obfuscated code back to the file
|
|
34
|
+
fs.writeFileSync(filePath, obfuscationResult.getObfuscatedCode());
|
|
35
|
+
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error(`Error obfuscating ${file}:`, error);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
});
|
package/package.json
CHANGED
package/rollup.config.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
2
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
3
|
+
import typescript from '@rollup/plugin-typescript';
|
|
4
|
+
import { terser } from 'rollup-plugin-terser';
|
|
5
|
+
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
input: 'src/index.ts',
|
|
9
|
+
output: [
|
|
10
|
+
{
|
|
11
|
+
file: 'dist/index.js',
|
|
12
|
+
format: 'cjs',
|
|
13
|
+
sourcemap: true,
|
|
14
|
+
exports: 'named'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
file: 'dist/index.esm.js',
|
|
18
|
+
format: 'esm',
|
|
19
|
+
sourcemap: true,
|
|
20
|
+
exports: 'named'
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
plugins: [
|
|
24
|
+
peerDepsExternal(),
|
|
25
|
+
resolve(),
|
|
26
|
+
commonjs(),
|
|
27
|
+
typescript({
|
|
28
|
+
tsconfig: './tsconfig.json',
|
|
29
|
+
exclude: ['**/__tests__/**'],
|
|
30
|
+
}),
|
|
31
|
+
terser(),
|
|
32
|
+
],
|
|
33
|
+
external: ['react', 'react-dom', 'openai'],
|
|
34
|
+
};
|
package/structure.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# GuideAI Package Structure
|
|
2
|
+
|
|
3
|
+
## Directory Structure
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
guide-ai-package/src/
|
|
7
|
+
├── GuideAI.tsx # Main component
|
|
8
|
+
├── index.ts # Package entry point
|
|
9
|
+
├── components/ # React components
|
|
10
|
+
│ └── Styles.tsx # Styling for the component
|
|
11
|
+
├── hooks/ # React hooks
|
|
12
|
+
│ ├── useConversation.ts # Conversation management
|
|
13
|
+
│ └── useRecording.ts # Audio recording and WebRTC
|
|
14
|
+
├── types/ # TypeScript type definitions
|
|
15
|
+
│ └── index.ts # Type definitions
|
|
16
|
+
└── utils/ # Utility functions
|
|
17
|
+
├── api-services.ts # API related functions
|
|
18
|
+
├── dom-interaction.ts # DOM manipulation utilities
|
|
19
|
+
├── react-hooks.ts # React hooks utilities
|
|
20
|
+
├── storage.ts # Local storage utilities
|
|
21
|
+
└── webrtc.ts # WebRTC related utilities
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## File Descriptions
|
|
25
|
+
|
|
26
|
+
### Main Files
|
|
27
|
+
|
|
28
|
+
#### `GuideAI.tsx`
|
|
29
|
+
The main component exported by the package that provides the user interface for audio interactions.
|
|
30
|
+
|
|
31
|
+
**Functions & Components:**
|
|
32
|
+
- `GuideAI(props: GuideAIProps)`: Main component that renders the UI
|
|
33
|
+
- Sets up conversation management
|
|
34
|
+
- Initializes audio recording
|
|
35
|
+
- Handles user interactions
|
|
36
|
+
|
|
37
|
+
#### `index.ts`
|
|
38
|
+
Entry point for the package, exports the GuideAI component and types.
|
|
39
|
+
|
|
40
|
+
**Exports:**
|
|
41
|
+
- `GuideAI`
|
|
42
|
+
- `GuideAIProps` (type)
|
|
43
|
+
|
|
44
|
+
### Components
|
|
45
|
+
|
|
46
|
+
#### `components/Styles.tsx`
|
|
47
|
+
Contains the CSS styling for the GuideAI component.
|
|
48
|
+
|
|
49
|
+
**Functions & Components:**
|
|
50
|
+
- `Styles()`: Component that injects CSS styles into the page
|
|
51
|
+
|
|
52
|
+
### Hooks
|
|
53
|
+
|
|
54
|
+
#### `hooks/useConversation.ts`
|
|
55
|
+
Custom hook for managing conversation state and interaction with the API.
|
|
56
|
+
|
|
57
|
+
**Functions:**
|
|
58
|
+
- `useConversation(organizationKey, onError)`: Main hook function
|
|
59
|
+
- `storeConversationItem(item)`: Stores a conversation item
|
|
60
|
+
- `initializeConversation()`: Creates or restores a conversation
|
|
61
|
+
- `logMessageToConversation(content, sender)`: Logs a message to the conversation
|
|
62
|
+
- `addConversationHistory(sendMessageFn)`: Adds conversation history to a new session
|
|
63
|
+
- `isConversationStale()`: Checks if conversation is more than 15 minutes old
|
|
64
|
+
|
|
65
|
+
#### `hooks/useRecording.ts`
|
|
66
|
+
Custom hook for managing audio recording, WebRTC connections, and handling responses.
|
|
67
|
+
|
|
68
|
+
**Functions:**
|
|
69
|
+
- `useRecording(organizationKey, onError, logMessageFn, addConversationHistoryFn, storeConversationItemFn, isAddingHistoryContextRef)`: Main hook function
|
|
70
|
+
- `sendWebRTCMessage(message)`: Sends a message through WebRTC
|
|
71
|
+
- `cleanupWebRTC()`: Cleans up WebRTC connections and media streams
|
|
72
|
+
- `handleWebRTCMessage(message)`: Handles incoming WebRTC messages
|
|
73
|
+
- `startRecording()`: Starts audio recording
|
|
74
|
+
- `stopRecording()`: Stops audio recording
|
|
75
|
+
- `toggleRecording()`: Toggles recording state
|
|
76
|
+
|
|
77
|
+
### Types
|
|
78
|
+
|
|
79
|
+
#### `types/index.ts`
|
|
80
|
+
Contains TypeScript type definitions used throughout the package.
|
|
81
|
+
|
|
82
|
+
**Types:**
|
|
83
|
+
- `ConversationItem`: Represents an item in the conversation
|
|
84
|
+
- `RecordingStatus`: Status of the recording ('idle' | 'recording' | 'processing' | 'playing' | 'initializing')
|
|
85
|
+
- `GuideAIProps`: Props for the GuideAI component
|
|
86
|
+
|
|
87
|
+
### Utils
|
|
88
|
+
|
|
89
|
+
#### `utils/api-services.ts`
|
|
90
|
+
Functions for interacting with external APIs.
|
|
91
|
+
|
|
92
|
+
**Functions:**
|
|
93
|
+
- `createNewConversation(organizationKey)`: Creates a new conversation
|
|
94
|
+
- `logMessage(conversationId, content, sender)`: Logs a message to the conversation
|
|
95
|
+
- `fetchEphemeralToken(organizationKey)`: Fetches an ephemeral token for WebRTC
|
|
96
|
+
- `geminiFlash(prompt)`: Makes a call to the Gemini API
|
|
97
|
+
|
|
98
|
+
#### `utils/dom-interaction.ts`
|
|
99
|
+
Utilities for interacting with the DOM.
|
|
100
|
+
|
|
101
|
+
**Functions:**
|
|
102
|
+
- `highlightElement(selector, logMessageFn)`: Highlights an element on the page
|
|
103
|
+
- DOM traversal and interaction functions
|
|
104
|
+
|
|
105
|
+
#### `utils/react-hooks.ts`
|
|
106
|
+
Utilities for React hooks to avoid duplicate React instances.
|
|
107
|
+
|
|
108
|
+
**Functions:**
|
|
109
|
+
- `getReactHooks()`: Returns React hooks from the host application or fall back to local ones
|
|
110
|
+
|
|
111
|
+
#### `utils/storage.ts`
|
|
112
|
+
Local storage utility functions.
|
|
113
|
+
|
|
114
|
+
**Constants:**
|
|
115
|
+
- `STORAGE_PREFIX`: Prefix for storage keys
|
|
116
|
+
- `STORAGE_KEYS`: Object containing all storage keys
|
|
117
|
+
|
|
118
|
+
**Functions:**
|
|
119
|
+
- `saveToStorage(key, value)`: Saves a value to localStorage
|
|
120
|
+
- `getFromStorage(key, defaultValue)`: Gets a value from localStorage
|
|
121
|
+
|
|
122
|
+
#### `utils/webrtc.ts`
|
|
123
|
+
WebRTC related utilities for audio streaming.
|
|
124
|
+
|
|
125
|
+
**Functions:**
|
|
126
|
+
- `initializeWebRTC(audioStream, token, audioElementRef, peerConnectionRef, dataChannelRef, handleMessageCallback)`: Sets up WebRTC connection
|
|
127
|
+
- `sendMessage(dataChannel, message)`: Sends a message through the data channel
|
|
128
|
+
- `orderConversationItems(items)`: Orders conversation items for replay
|
package/todo.md
ADDED