@onairos/react-native 3.7.1 → 3.7.3
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/lib/commonjs/api/index.js +219 -9
- package/lib/commonjs/assets/icons/spotify.png +0 -0
- package/lib/commonjs/assets/images/spotify.png +0 -0
- package/lib/commonjs/components/BodyText.js +27 -9
- package/lib/commonjs/components/BrandMark.js +111 -10
- package/lib/commonjs/components/CodeInput.js +116 -9
- package/lib/commonjs/components/EmailInput.js +30 -8
- package/lib/commonjs/components/GoogleButton.js +56 -9
- package/lib/commonjs/components/HeadingGroup.js +43 -9
- package/lib/commonjs/components/LLMDataInputModal.js +664 -14
- package/lib/commonjs/components/ModalHeader.js +99 -9
- package/lib/commonjs/components/ModalSheet.js +47 -9
- package/lib/commonjs/components/Onairos.js +380 -14
- package/lib/commonjs/components/OnairosButton.js +313 -13
- package/lib/commonjs/components/OnairosSignInButton.js +130 -12
- package/lib/commonjs/components/Overlay.js +465 -13
- package/lib/commonjs/components/PersonaImage.js +137 -10
- package/lib/commonjs/components/PersonaLoadingScreen.js +318 -12
- package/lib/commonjs/components/PersonalizationConsentScreen.js +467 -13
- package/lib/commonjs/components/PinCreationScreen.js +403 -12
- package/lib/commonjs/components/PinInput.js +464 -9
- package/lib/commonjs/components/PlatformConnectorsStep.js +1311 -23
- package/lib/commonjs/components/PlatformList.js +137 -10
- package/lib/commonjs/components/PlatformToggle.js +180 -9
- package/lib/commonjs/components/PrimaryButton.js +180 -10
- package/lib/commonjs/components/SignInMatchAnimation.js +197 -9
- package/lib/commonjs/components/SignInStep.js +345 -12
- package/lib/commonjs/components/UniversalOnboarding.js +2780 -30
- package/lib/commonjs/components/VerificationStep.js +176 -11
- package/lib/commonjs/components/WelcomeScreen.js +461 -22
- package/lib/commonjs/components/icons/Basicproficon.js +37 -8
- package/lib/commonjs/components/icons/Basicprofile.js +21 -8
- package/lib/commonjs/components/icons/Checkbox.js +21 -8
- package/lib/commonjs/components/icons/Checkmark.js +27 -8
- package/lib/commonjs/components/icons/Contentanalysis.js +21 -8
- package/lib/commonjs/components/icons/Contenticon.js +39 -8
- package/lib/commonjs/components/icons/EnochE.js +41 -8
- package/lib/commonjs/components/icons/Personalityicon.js +30 -8
- package/lib/commonjs/components/icons/Personalityprofile.js +21 -8
- package/lib/commonjs/components/icons/Personalitytraits.js +21 -8
- package/lib/commonjs/components/icons/Userpreferences.js +21 -8
- package/lib/commonjs/components/icons/index.js +84 -17
- package/lib/commonjs/components/onboarding/OAuthWebView.js +1754 -18
- package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -10
- package/lib/commonjs/components/onboarding/PinInput.js +283 -10
- package/lib/commonjs/components/onboarding/PlatformConnector.js +249 -11
- package/lib/commonjs/config/PLATFORM_APIS.md +849 -0
- package/lib/commonjs/config/api.js +56 -7
- package/lib/commonjs/constants/index.js +120 -7
- package/lib/commonjs/context/AuthContext.js +345 -10
- package/lib/commonjs/hooks/useConnectedAccounts.js +111 -9
- package/lib/commonjs/hooks/useConnections.js +102 -8
- package/lib/commonjs/hooks/useCredentials.js +178 -10
- package/lib/commonjs/hooks/useUserConnections.js +148 -10
- package/lib/commonjs/index.js +439 -34
- package/lib/commonjs/services/apiClient.js +298 -8
- package/lib/commonjs/services/biometricPinService.js +180 -8
- package/lib/commonjs/services/chatGPTConversationExtractor.js +155 -8
- package/lib/commonjs/services/chatGPTConversationService.js +275 -9
- package/lib/commonjs/services/claudeConversationExtractor.js +103 -8
- package/lib/commonjs/services/claudeConversationService.js +158 -9
- package/lib/commonjs/services/connectedAccountsService.js +310 -10
- package/lib/commonjs/services/googleAuthService.js +252 -11
- package/lib/commonjs/services/hingeDataExtractor.js +105 -8
- package/lib/commonjs/services/hingeDataService.js +150 -9
- package/lib/commonjs/services/imageCompressionService.js +260 -7
- package/lib/commonjs/services/instagramDataExtractor.js +126 -8
- package/lib/commonjs/services/instagramDataService.js +163 -9
- package/lib/commonjs/services/jwtStorageService.js +276 -7
- package/lib/commonjs/services/linkedinDOMExtractor.js +245 -7
- package/lib/commonjs/services/linkedinProfileService.js +222 -9
- package/lib/commonjs/services/linkedinScrapingService.js +230 -8
- package/lib/commonjs/services/llmDataStorage.js +294 -8
- package/lib/commonjs/services/mobileTrainingService.js +186 -8
- package/lib/commonjs/services/netflixDataExtractor.js +120 -8
- package/lib/commonjs/services/netflixDataService.js +198 -9
- package/lib/commonjs/services/pinEncryptionService.js +84 -8
- package/lib/commonjs/services/pinStorageUtils.js +105 -7
- package/lib/commonjs/services/platformAuthService.js +1484 -12
- package/lib/commonjs/services/sephoraDataExtractor.js +140 -8
- package/lib/commonjs/services/sephoraDataService.js +200 -9
- package/lib/commonjs/services/spotifyDataExtractor.js +148 -8
- package/lib/commonjs/services/spotifyDataService.js +241 -9
- package/lib/commonjs/services/storageService.js +404 -8
- package/lib/commonjs/services/telegramDataExtractor.js +115 -8
- package/lib/commonjs/services/telegramDataService.js +499 -9
- package/lib/commonjs/services/trainingApiHelpers.js +73 -7
- package/lib/commonjs/services/userConnectionsService.js +340 -10
- package/lib/commonjs/services/youtubeMigrationService.js +416 -10
- package/lib/commonjs/theme/index.js +250 -7
- package/lib/commonjs/types/ambient.d.js +2 -1
- package/lib/commonjs/types/declarations.d.js +2 -1
- package/lib/commonjs/types/index.js +6 -1
- package/lib/commonjs/types/node-fix.d.js +2 -1
- package/lib/commonjs/types/node-override.d.js +2 -1
- package/lib/commonjs/types/opacity.d.js +2 -1
- package/lib/commonjs/types.js +14 -1
- package/lib/commonjs/utils/Portal.js +98 -8
- package/lib/commonjs/utils/api.js +130 -9
- package/lib/commonjs/utils/assetRegistry.js +210 -35
- package/lib/commonjs/utils/auth.js +112 -9
- package/lib/commonjs/utils/connectorTests.js +613 -29
- package/lib/commonjs/utils/crypto.js +62 -8
- package/lib/commonjs/utils/debugHelper.js +64 -1
- package/lib/commonjs/utils/encryption.js +76 -7
- package/lib/commonjs/utils/eventUtils.js +288 -1
- package/lib/commonjs/utils/haptics.js +66 -9
- package/lib/commonjs/utils/imagePreloader.js +6 -1
- package/lib/commonjs/utils/networkDiagnostics.js +226 -8
- package/lib/commonjs/utils/onairosApi.js +350 -9
- package/lib/commonjs/utils/programmaticFlow.js +117 -9
- package/lib/commonjs/utils/retryHelper.js +220 -1
- package/lib/commonjs/utils/secureStorage.js +349 -10
- package/lib/commonjs/utils/webviewScripts/chatgpt.js +551 -1
- package/lib/commonjs/utils/webviewScripts/claude.js +376 -1
- package/lib/commonjs/utils/webviewScripts/hinge.js +411 -1
- package/lib/commonjs/utils/webviewScripts/index.js +698 -15
- package/lib/commonjs/utils/webviewScripts/instagram.js +454 -1
- package/lib/commonjs/utils/webviewScripts/linkedin.js +880 -1
- package/lib/commonjs/utils/webviewScripts/netflix.js +382 -1
- package/lib/commonjs/utils/webviewScripts/sephora.js +516 -1
- package/lib/commonjs/utils/webviewScripts/spotify.js +419 -1
- package/lib/commonjs/utils/webviewScripts/telegram.js +678 -1
- package/lib/module/api/index.js +211 -1
- package/lib/module/assets/icons/spotify.png +0 -0
- package/lib/module/assets/images/spotify.png +0 -0
- package/lib/module/components/BodyText.js +20 -1
- package/lib/module/components/BrandMark.js +104 -1
- package/lib/module/components/CodeInput.js +109 -1
- package/lib/module/components/EmailInput.js +23 -1
- package/lib/module/components/GoogleButton.js +49 -1
- package/lib/module/components/HeadingGroup.js +36 -1
- package/lib/module/components/LLMDataInputModal.js +656 -7
- package/lib/module/components/ModalHeader.js +92 -1
- package/lib/module/components/ModalSheet.js +39 -1
- package/lib/module/components/Onairos.js +373 -1
- package/lib/module/components/OnairosButton.js +305 -1
- package/lib/module/components/OnairosSignInButton.js +121 -1
- package/lib/module/components/Overlay.js +456 -1
- package/lib/module/components/PersonaImage.js +129 -1
- package/lib/module/components/PersonaLoadingScreen.js +310 -1
- package/lib/module/components/PersonalizationConsentScreen.js +460 -1
- package/lib/module/components/PinCreationScreen.js +396 -1
- package/lib/module/components/PinInput.js +456 -1
- package/lib/module/components/PlatformConnectorsStep.js +1302 -6
- package/lib/module/components/PlatformList.js +129 -1
- package/lib/module/components/PlatformToggle.js +173 -1
- package/lib/module/components/PrimaryButton.js +172 -1
- package/lib/module/components/SignInMatchAnimation.js +189 -1
- package/lib/module/components/SignInStep.js +338 -1
- package/lib/module/components/UniversalOnboarding.js +2770 -1
- package/lib/module/components/VerificationStep.js +168 -1
- package/lib/module/components/WelcomeScreen.js +453 -1
- package/lib/module/components/icons/Basicproficon.js +30 -1
- package/lib/module/components/icons/Basicprofile.js +14 -1
- package/lib/module/components/icons/Checkbox.js +14 -1
- package/lib/module/components/icons/Checkmark.js +20 -1
- package/lib/module/components/icons/Contentanalysis.js +14 -1
- package/lib/module/components/icons/Contenticon.js +32 -1
- package/lib/module/components/icons/EnochE.js +34 -1
- package/lib/module/components/icons/Personalityicon.js +23 -1
- package/lib/module/components/icons/Personalityprofile.js +14 -1
- package/lib/module/components/icons/Personalitytraits.js +14 -1
- package/lib/module/components/icons/Userpreferences.js +14 -1
- package/lib/module/components/icons/index.js +13 -1
- package/lib/module/components/onboarding/OAuthWebView.js +1746 -1
- package/lib/module/components/onboarding/OnboardingHeader.js +66 -1
- package/lib/module/components/onboarding/PinInput.js +274 -1
- package/lib/module/components/onboarding/PlatformConnector.js +240 -1
- package/lib/module/config/PLATFORM_APIS.md +849 -0
- package/lib/module/config/api.js +47 -1
- package/lib/module/constants/index.js +114 -1
- package/lib/module/context/AuthContext.js +335 -1
- package/lib/module/hooks/useConnectedAccounts.js +106 -1
- package/lib/module/hooks/useConnections.js +95 -1
- package/lib/module/hooks/useCredentials.js +171 -6
- package/lib/module/hooks/useUserConnections.js +140 -1
- package/lib/module/index.js +172 -1
- package/lib/module/services/apiClient.js +295 -1
- package/lib/module/services/biometricPinService.js +169 -1
- package/lib/module/services/chatGPTConversationExtractor.js +149 -1
- package/lib/module/services/chatGPTConversationService.js +268 -1
- package/lib/module/services/claudeConversationExtractor.js +97 -1
- package/lib/module/services/claudeConversationService.js +151 -1
- package/lib/module/services/connectedAccountsService.js +293 -1
- package/lib/module/services/googleAuthService.js +241 -1
- package/lib/module/services/hingeDataExtractor.js +99 -1
- package/lib/module/services/hingeDataService.js +143 -1
- package/lib/module/services/imageCompressionService.js +250 -1
- package/lib/module/services/instagramDataExtractor.js +120 -1
- package/lib/module/services/instagramDataService.js +156 -1
- package/lib/module/services/jwtStorageService.js +257 -1
- package/lib/module/services/linkedinDOMExtractor.js +234 -1
- package/lib/module/services/linkedinProfileService.js +210 -1
- package/lib/module/services/linkedinScrapingService.js +219 -1
- package/lib/module/services/llmDataStorage.js +277 -1
- package/lib/module/services/mobileTrainingService.js +173 -1
- package/lib/module/services/netflixDataExtractor.js +114 -1
- package/lib/module/services/netflixDataService.js +191 -1
- package/lib/module/services/pinEncryptionService.js +74 -6
- package/lib/module/services/pinStorageUtils.js +93 -1
- package/lib/module/services/platformAuthService.js +1461 -1
- package/lib/module/services/sephoraDataExtractor.js +134 -1
- package/lib/module/services/sephoraDataService.js +193 -1
- package/lib/module/services/spotifyDataExtractor.js +142 -1
- package/lib/module/services/spotifyDataService.js +234 -1
- package/lib/module/services/storageService.js +383 -1
- package/lib/module/services/telegramDataExtractor.js +109 -1
- package/lib/module/services/telegramDataService.js +493 -1
- package/lib/module/services/trainingApiHelpers.js +67 -1
- package/lib/module/services/userConnectionsService.js +329 -1
- package/lib/module/services/youtubeMigrationService.js +405 -1
- package/lib/module/theme/index.js +245 -1
- package/lib/module/types.js +10 -1
- package/lib/module/utils/Portal.js +90 -1
- package/lib/module/utils/api.js +118 -1
- package/lib/module/utils/assetRegistry.js +200 -34
- package/lib/module/utils/auth.js +100 -1
- package/lib/module/utils/connectorTests.js +600 -27
- package/lib/module/utils/crypto.js +54 -1
- package/lib/module/utils/debugHelper.js +54 -1
- package/lib/module/utils/encryption.js +67 -1
- package/lib/module/utils/eventUtils.js +270 -1
- package/lib/module/utils/haptics.js +59 -8
- package/lib/module/utils/imagePreloader.js +3 -1
- package/lib/module/utils/networkDiagnostics.js +217 -1
- package/lib/module/utils/onairosApi.js +333 -1
- package/lib/module/utils/programmaticFlow.js +111 -1
- package/lib/module/utils/retryHelper.js +211 -1
- package/lib/module/utils/secureStorage.js +330 -6
- package/lib/module/utils/webviewScripts/chatgpt.js +545 -1
- package/lib/module/utils/webviewScripts/claude.js +370 -1
- package/lib/module/utils/webviewScripts/hinge.js +405 -1
- package/lib/module/utils/webviewScripts/index.js +434 -1
- package/lib/module/utils/webviewScripts/instagram.js +448 -1
- package/lib/module/utils/webviewScripts/linkedin.js +874 -1
- package/lib/module/utils/webviewScripts/netflix.js +376 -1
- package/lib/module/utils/webviewScripts/sephora.js +510 -1
- package/lib/module/utils/webviewScripts/spotify.js +413 -1
- package/lib/module/utils/webviewScripts/telegram.js +672 -1
- package/package.json +2 -2
|
@@ -1 +1,268 @@
|
|
|
1
|
-
import{API_CONFIG}from'../config/api';function _0x2de8(_0x563574,_0x2de864){_0x563574=_0x563574-0x0;const _0x629384=_0x5635();let _0x9d552e=_0x629384[_0x563574];return _0x9d552e;}import AsyncStorage from'@react-native-async-storage/async-storage';import{Platform}from'react-native';export const storeChatGPTConversations=async(_0xe939d1,_0x51b117)=>{const _0xae2ac={'xxxaL':_0x2de8(0x0),'kFJdK':'🚀\x20[CHATGPT_SERVICE]\x20Storing\x20ChatGPT\x20conversations\x20for:','gXTBo':'📊\x20[CHATGPT_SERVICE]\x20Total\x20messages:','VtuQr':function(_0x3c0094,_0x4d28bd){return _0x3c0094||_0x4d28bd;},'mmszk':_0x2de8(0x1),'QRAXb':_0x2de8(0x2),'MGJma':_0x2de8(0x3),'bTpBW':'auth_token','tylrT':'poOQU','isifu':'KHtlt','NJRzb':_0x2de8(0x4),'aTXwD':_0x2de8(0x5),'YPxsH':'🔑\x20[CHATGPT_SERVICE]\x20Auth\x20token\x20found\x20for\x20conversations','hzFCY':_0x2de8(0x6),'vVAgf':function(_0x56fa6d,_0x563114){return _0x56fa6d===_0x563114;},'PkpjY':_0x2de8(0x7),'hvNGJ':_0x2de8(0x8),'vomxK':function(_0x42ff3f,_0x1513dc){return _0x42ff3f===_0x1513dc;},'fvZih':_0x2de8(0x9),'HiNmC':function(_0x4d8302,_0x52e4ad){return _0x4d8302<_0x52e4ad;},'NnCcH':function(_0x43c4fc,_0x2ba2c8){return _0x43c4fc!==_0x2ba2c8;},'OtPRT':_0x2de8(0xa),'mhsff':function(_0x2c1d69,_0x47ac86){return _0x2c1d69/_0x47ac86;},'dUAMy':'mobile-chatgpt','NjmVl':_0x2de8(0xb),'FwqLG':function(_0x66ef33,_0x570ff9){return _0x66ef33+_0x570ff9;},'CFChN':function(_0x819bc1,_0x53f0c2,_0x5c319a){return _0x819bc1(_0x53f0c2,_0x5c319a);},'KNKKB':function(_0x1df85f,_0x5cf8a8){return _0x1df85f+_0x5cf8a8;},'gjNwy':function(_0x2afce,_0x35209c){return _0x2afce-_0x35209c;},'CdSiF':function(_0x4d8cd1,_0x48eeb6){return _0x4d8cd1>_0x48eeb6;}};console['log'](_0xae2ac[_0x2de8(0xc)],_0xe939d1),console[_0x2de8(0xd)](_0x2de8(0xe),_0x51b117[_0x2de8(0xf)]),console['log'](_0xae2ac[_0x2de8(0x10)],_0x51b117[_0x2de8(0x11)]((_0x4095ac,_0x2e8df6)=>_0x4095ac+_0x2e8df6['user_messages']['length'],0x0));if(_0xae2ac['VtuQr'](!_0xe939d1,!_0x51b117)||_0x51b117[_0x2de8(0xf)]===0x0)return console['error'](_0x2de8(0x12)),{'success':![],'error':_0xae2ac[_0x2de8(0x13)]};try{const _0x18f1ee=await AsyncStorage[_0x2de8(0x14)](_0xae2ac[_0x2de8(0x15)])||await AsyncStorage[_0x2de8(0x14)](_0xae2ac[_0x2de8(0x16)])||await AsyncStorage[_0x2de8(0x14)](_0xae2ac[_0x2de8(0x17)]);if(!_0x18f1ee)return _0xae2ac[_0x2de8(0x18)]!==_0xae2ac[_0x2de8(0x19)]?(console[_0x2de8(0x1a)](_0xae2ac[_0x2de8(0x1b)]),{'success':![],'error':_0xae2ac[_0x2de8(0x1c)]}):(_0xdce85f[_0x2de8(0x1a)](_0xae2ac[_0x2de8(0x1d)],_0x2c3922),{'success':![],'error':_0x241858[_0x2de8(0x1e)]||_0x2de8(0x1f)});console[_0x2de8(0xd)](_0xae2ac['YPxsH']);const _0x4748da={'platform':Platform['OS'],'appVersion':_0xae2ac['hzFCY'],'osVersion':_0xae2ac[_0x2de8(0x20)](Platform['OS'],_0xae2ac['PkpjY'])?_0xae2ac[_0x2de8(0x21)]:Platform['OS'],'deviceModel':_0xae2ac[_0x2de8(0x22)](Platform['OS'],_0xae2ac[_0x2de8(0x23)])?_0x2de8(0x24):_0xae2ac[_0x2de8(0x25)],'isOfflineSync':![]};let _0x42cb17=0x0,_0x192aff=0x0;for(let _0x4a0bc5=0x0;_0xae2ac['HiNmC'](_0x4a0bc5,_0x51b117['length']);_0x4a0bc5++){if(_0xae2ac[_0x2de8(0x26)]('ppzhd',_0xae2ac[_0x2de8(0x27)]))_0x387a5c[_0x2de8(0xd)](_0x2de8(0x28)+_0x2fb628['message']);else{const _0x2d4aec=_0x51b117[_0x4a0bc5],_0x1a32ad=Date[_0x2de8(0x29)](),_0x2a0195=_0x2d4aec[_0x2de8(0x2a)][_0x2de8(0x2b)]((_0x144888,_0x48996f)=>({'id':_0x2d4aec[_0x2de8(0x2c)]+_0x2de8(0x2d)+_0x48996f,'role':_0x2de8(0x2e),'content':_0x144888,'timestamp':new Date(_0x1a32ad-(_0x2d4aec[_0x2de8(0x2a)][_0x2de8(0xf)]-_0x48996f)*0x3e8)['toISOString'](),'metadata':{}})),_0xb9a1ce={'conversationId':_0x2d4aec[_0x2de8(0x2c)],'messages':_0x2a0195,'context':{'title':_0x2d4aec[_0x2de8(0x2f)],'create_time':Math[_0x2de8(0x30)](_0xae2ac[_0x2de8(0x31)](_0x1a32ad,0x3e8)),'update_time':Math[_0x2de8(0x30)](_0x1a32ad/0x3e8)},'mobileMetadata':_0x4748da},_0xdb5ffc={'platform':_0xae2ac[_0x2de8(0x32)],'conversationData':_0xb9a1ce,'memoryType':_0xae2ac[_0x2de8(0x33)]};console[_0x2de8(0xd)]('📡\x20[CHATGPT_SERVICE]\x20Sending\x20conversation\x20'+_0xae2ac[_0x2de8(0x34)](_0x4a0bc5,0x1)+'/'+_0x51b117[_0x2de8(0xf)]+':\x20'+_0x2d4aec[_0x2de8(0x2f)]);try{const _0x4ee392=await _0xae2ac[_0x2de8(0x35)](fetch,API_CONFIG['BASE_URL']+'/llm-data/store',{'method':'POST','headers':{'Content-Type':'application/json','Authorization':_0x2de8(0x36)+_0x18f1ee,'User-Agent':_0x2de8(0x37)+Platform['OS']+')'},'body':JSON[_0x2de8(0x38)](_0xdb5ffc)}),_0x59a88a=await _0x4ee392[_0x2de8(0x39)]();_0x4ee392['ok']?(console[_0x2de8(0xd)]('✅\x20[CHATGPT_SERVICE]\x20Sent\x20conversation\x20'+_0xae2ac[_0x2de8(0x3a)](_0x4a0bc5,0x1)+'/'+_0x51b117[_0x2de8(0xf)]),_0x42cb17++):(console[_0x2de8(0x3b)](_0x2de8(0x3c)+(_0x4a0bc5+0x1)+'/'+_0x51b117['length']+':',_0x59a88a[_0x2de8(0x1a)]||_0x4ee392[_0x2de8(0x3d)]),_0x192aff++);}catch(_0x3bfc91){console[_0x2de8(0x3b)](_0x2de8(0x3e)+_0xae2ac[_0x2de8(0x3a)](_0x4a0bc5,0x1)+':',_0x3bfc91),_0x192aff++;}_0xae2ac[_0x2de8(0x3f)](_0x4a0bc5,_0xae2ac[_0x2de8(0x40)](_0x51b117[_0x2de8(0xf)],0x1))&&await new Promise(_0x430a37=>setTimeout(_0x430a37,0x12c));}}return console[_0x2de8(0xd)]('📊\x20[CHATGPT_SERVICE]\x20Complete:\x20'+_0x42cb17+_0x2de8(0x41)+_0x192aff+_0x2de8(0x42)),_0xae2ac[_0x2de8(0x43)](_0x42cb17,0x0)?{'success':!![],'message':'Stored\x20'+_0x42cb17+'\x20of\x20'+_0x51b117[_0x2de8(0xf)]+_0x2de8(0x44)}:{'success':![],'error':_0x2de8(0x45)+_0x192aff+'\x20errors)'};}catch(_0x542d24){return console['error'](_0x2de8(0x46),_0x542d24),{'success':![],'error':_0x542d24['message']||_0x2de8(0x1f)};}};export const storeChatGPTMemories=async _0xa632d4=>{const _0x509811={'XsoPk':function(_0x5f4292,_0x1b39a8){return _0x5f4292+_0x1b39a8;},'tjLtH':_0x2de8(0x1),'KEEhn':function(_0x538973,_0x18a817){return _0x538973===_0x18a817;},'XubPM':function(_0x42ef3d,_0x58509b){return _0x42ef3d===_0x58509b;},'RcdsK':function(_0x515d6e,_0x1834e8){return _0x515d6e===_0x1834e8;},'AlSrW':function(_0x152e44,_0x3e3de4){return _0x152e44===_0x3e3de4;},'gycyx':function(_0x5d9c9f,_0x25a554){return _0x5d9c9f===_0x25a554;},'ZZLaV':'❌\x20[CHATGPT_SERVICE]\x20Invalid\x20input:\x20memoriesData\x20missing','UknxY':_0x2de8(0x47),'aIerW':'onairos_jwt_token','zVtDI':_0x2de8(0x3),'QUdrG':_0x2de8(0x48),'nXjvO':_0x2de8(0x49),'GxWfs':_0x2de8(0x4a),'FJIRh':_0x2de8(0x6),'CXqsU':function(_0x32158a,_0x25892a){return _0x32158a||_0x25892a;},'paxwD':function(_0x191cfb,_0x3cd8f6,_0x51a147){return _0x191cfb(_0x3cd8f6,_0x51a147);},'sqzrS':_0x2de8(0x4b),'pEaQv':function(_0x3c01e9,_0x2810a7){return _0x3c01e9!==_0x2810a7;},'HdWAE':_0x2de8(0x4c),'yEgKZ':'Memories\x20stored\x20successfully','BSmRB':function(_0x3e6b23,_0x4b2212){return _0x3e6b23!==_0x4b2212;},'rOXOS':'Unknown\x20error','SWnky':_0x2de8(0x0)};var _0x1c55a9,_0x529fed,_0x199e82;console[_0x2de8(0xd)](_0x2de8(0x4d));const _0x1690ea=(_0x509811[_0x2de8(0x4e)](_0xa632d4,null)||_0xa632d4===void 0x0||_0x509811[_0x2de8(0x4e)](_0x1c55a9=_0xa632d4[_0x2de8(0x4f)],null)||_0x1c55a9===void 0x0?void 0x0:_0x1c55a9[_0x2de8(0xf)])||0x0,_0x11c239=(_0x509811[_0x2de8(0x50)](_0xa632d4,null)||_0x509811['KEEhn'](_0xa632d4,void 0x0)||_0x509811['XubPM'](_0x529fed=_0xa632d4['memory_entries'],null)||_0x509811['RcdsK'](_0x529fed,void 0x0)?void 0x0:_0x529fed[_0x2de8(0xf)])||0x0,_0x2ddd62=(_0x509811[_0x2de8(0x51)](_0xa632d4,null)||_0x509811[_0x2de8(0x50)](_0xa632d4,void 0x0)||_0x509811[_0x2de8(0x52)](_0x199e82=_0xa632d4[_0x2de8(0x53)],null)||_0x509811['gycyx'](_0x199e82,void 0x0)?void 0x0:_0x199e82[_0x2de8(0xf)])||0x0,_0x3d63d6=_0x509811['XsoPk'](_0x1690ea+_0x11c239,_0x2ddd62);console[_0x2de8(0xd)]('📋\x20[CHATGPT_SERVICE]\x20Found\x20'+_0x1690ea+_0x2de8(0x54)+_0x11c239+'\x20entries,\x20'+_0x2ddd62+_0x2de8(0x55)+_0x3d63d6+')');if(!_0xa632d4)return console[_0x2de8(0x1a)](_0x509811['ZZLaV']),{'success':![],'error':_0x509811[_0x2de8(0x56)]};try{const _0x228cc5=await AsyncStorage['getItem'](_0x509811[_0x2de8(0x57)])||await AsyncStorage[_0x2de8(0x14)](_0x509811[_0x2de8(0x58)])||await AsyncStorage['getItem'](_0x509811[_0x2de8(0x59)]);if(!_0x228cc5){if(_0x509811['gycyx'](_0x509811[_0x2de8(0x5a)],_0x2de8(0x49)))return console[_0x2de8(0x1a)](_0x2de8(0x4)),{'success':![],'error':_0x2de8(0x5)};else _0x37d35a['log'](_0x2de8(0x5b)+_0x509811[_0x2de8(0x5c)](_0x37e96f,0x1)+'/'+_0x381698['length']),_0x2b518f++;}console[_0x2de8(0xd)](_0x509811[_0x2de8(0x5d)]);const _0x55959a=_0x509811['FJIRh'],_0x304528={'platform':_0x2de8(0x5e),'memoriesData':_0xa632d4,'metadata':{'source':'react-native-sdk','appVersion':_0x55959a,'fetchedAt':new Date()[_0x2de8(0x5f)]()}},_0x48b2cc=Object[_0x2de8(0x60)](_0x509811[_0x2de8(0x61)](_0xa632d4,{}));console[_0x2de8(0xd)](_0x2de8(0x62)),console[_0x2de8(0xd)](_0x2de8(0x63)+API_CONFIG[_0x2de8(0x64)]+_0x2de8(0x65)),console['log'](_0x2de8(0x66)+_0x48b2cc[_0x2de8(0x67)](',\x20')),console[_0x2de8(0xd)](_0x2de8(0x68));const _0x4d4453=await _0x509811['paxwD'](fetch,API_CONFIG[_0x2de8(0x64)]+_0x2de8(0x65),{'method':'POST','headers':{'Content-Type':'application/json','Authorization':_0x2de8(0x36)+_0x228cc5,'User-Agent':_0x2de8(0x69)+_0x55959a+'\x20('+Platform['OS']+')'},'body':JSON[_0x2de8(0x38)](_0x304528)}),_0x3a3ee0=await _0x4d4453[_0x2de8(0x39)]();if(_0x4d4453['ok']){var _0x177242;console[_0x2de8(0xd)](_0x509811['sqzrS']);_0x3a3ee0[_0x2de8(0x1e)]&&console[_0x2de8(0xd)](_0x2de8(0x28)+_0x3a3ee0[_0x2de8(0x1e)]);if(_0x509811[_0x2de8(0x6a)](_0x177242=_0x3a3ee0[_0x2de8(0x6b)],null)&&_0x177242!==void 0x0&&_0x177242['memoriesCount']){if(_0x509811[_0x2de8(0x50)]('oWaoM',_0x509811[_0x2de8(0x6c)]))return{'success':![],'error':_0x2de8(0x45)+_0x2628a3+_0x2de8(0x6d)};else console[_0x2de8(0xd)](_0x2de8(0x6e)+_0x3a3ee0['data'][_0x2de8(0x6f)]+'\x20memory\x20items\x20in\x20database');}return{'success':!![],'message':_0x3a3ee0[_0x2de8(0x1e)]||_0x509811[_0x2de8(0x70)],'data':_0x3a3ee0[_0x2de8(0x6b)]};}else return _0x509811[_0x2de8(0x71)](_0x2de8(0x72),_0x2de8(0x73))?(console[_0x2de8(0x3b)]('⚠️\x20[CHATGPT_SERVICE]\x20Memories\x20backend\x20returned\x20status:\x20'+_0x4d4453[_0x2de8(0x3d)]),console['warn'](_0x2de8(0x74)+(_0x3a3ee0[_0x2de8(0x1a)]||_0x509811[_0x2de8(0x75)])),{'success':![],'error':_0x3a3ee0[_0x2de8(0x1a)]||_0x2de8(0x76)+_0x4d4453['status']}):(_0x397b5c[_0x2de8(0x1a)](_0x2de8(0x12)),{'success':![],'error':_0x509811[_0x2de8(0x77)]});}catch(_0x5753e8){return console[_0x2de8(0x1a)](_0x509811[_0x2de8(0x78)],_0x5753e8),{'success':![],'error':_0x5753e8[_0x2de8(0x1e)]||_0x2de8(0x1f)};}};function _0x5635(){const _0x5da64e=['❌\x20[CHATGPT_SERVICE]\x20Memories\x20network\x20error:','Invalid\x20input:\x20userId\x20or\x20conversations\x20missing.','onairos_jwt_token','enoch_token','❌\x20[CHATGPT_SERVICE]\x20No\x20auth\x20token\x20found\x20in\x20any\x20storage\x20key','Authentication\x20token\x20not\x20found.\x20Please\x20log\x20in\x20again.','1.0.0','ios','17.0','Android','ppzhd','conversation','kFJdK','log','📊\x20[CHATGPT_SERVICE]\x20Number\x20of\x20conversations:','length','gXTBo','reduce','❌\x20[CHATGPT_SERVICE]\x20Invalid\x20input','mmszk','getItem','QRAXb','MGJma','bTpBW','tylrT','isifu','error','NJRzb','aTXwD','xxxaL','message','Network\x20error.\x20Please\x20check\x20your\x20connection.','vVAgf','hvNGJ','vomxK','PkpjY','iPhone','fvZih','NnCcH','OtPRT','📝\x20[CHATGPT_SERVICE]\x20Backend\x20response:\x20','now','user_messages','map','conversation_id','-msg-','user','title','floor','mhsff','dUAMy','NjmVl','FwqLG','CFChN','Bearer\x20','OnairosSDK/1.0.0\x20(','stringify','json','KNKKB','warn','⚠️\x20[CHATGPT_SERVICE]\x20Failed\x20conversation\x20','status','⚠️\x20[CHATGPT_SERVICE]\x20Network\x20error\x20for\x20conversation\x20','HiNmC','gjNwy','\x20success,\x20','\x20failed','CdSiF','\x20conversations','Failed\x20to\x20store\x20conversations\x20(','❌\x20[CHATGPT_SERVICE]\x20Network\x20error:','Invalid\x20input:\x20memoriesData\x20missing.','auth_token','ZWtWB','🔑\x20[CHATGPT_SERVICE]\x20Auth\x20token\x20found\x20for\x20memories','✅\x20[CHATGPT_SERVICE]\x20Successfully\x20sent\x20memories\x20to\x20backend','qAAPJ','🧠\x20[CHATGPT_SERVICE]\x20Storing\x20ChatGPT\x20memories...','KEEhn','items','XubPM','RcdsK','AlSrW','memories','\x20items,\x20','\x20memories\x20(total:\x20','UknxY','aIerW','zVtDI','QUdrG','nXjvO','✅\x20[CHATGPT_SERVICE]\x20Sent\x20conversation\x20','XsoPk','GxWfs','mobile-chatgpt','toISOString','keys','CXqsU','📡\x20[CHATGPT_SERVICE]\x20Sending\x20memories\x20to\x20backend...','📍\x20[CHATGPT_SERVICE]\x20URL:\x20','BASE_URL','/llm-data/store-memories','📦\x20[CHATGPT_SERVICE]\x20Raw\x20memoriesData\x20keys:\x20','join','📦\x20[CHATGPT_SERVICE]\x20Raw\x20response\x20sent\x20as-is\x20(no\x20transformation)','OnairosSDK/','pEaQv','data','HdWAE','\x20errors)','📋\x20[CHATGPT_SERVICE]\x20Stored\x20','memoriesCount','yEgKZ','BSmRB','TXBVJ','DyuDD','⚠️\x20[CHATGPT_SERVICE]\x20Error:\x20','rOXOS','HTTP\x20','tjLtH','SWnky'];_0x5635=function(){return _0x5da64e;};return _0x5635();}
|
|
1
|
+
/**
|
|
2
|
+
* ChatGPT Conversation Service
|
|
3
|
+
*
|
|
4
|
+
* API layer for storing ChatGPT conversation data on backend.
|
|
5
|
+
* Sends extracted user messages to /llm-data/store endpoint.
|
|
6
|
+
* Also handles ChatGPT memories via /llm-data/store-memories endpoint.
|
|
7
|
+
*
|
|
8
|
+
* MATCHES iOS: onairos-flutter/ios/Classes/OnairosChatGPTConnectorPlugin.swift
|
|
9
|
+
* - Sends ONE request per conversation (not all at once)
|
|
10
|
+
* - Uses format: { conversationId, messages[], context }
|
|
11
|
+
* - Platform: "mobile-chatgpt"
|
|
12
|
+
* - Memories sent to /llm-data/store-memories
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { API_CONFIG } from '../config/api';
|
|
16
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
17
|
+
import { Platform } from 'react-native';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Structure of conversation messages extracted from ChatGPT
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Response from backend /llm-data/store endpoint
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Store ChatGPT conversations on backend
|
|
29
|
+
* MATCHES iOS: Sends one request per conversation
|
|
30
|
+
*
|
|
31
|
+
* @param userId - Username or identifier
|
|
32
|
+
* @param conversations - Array of conversations with user messages
|
|
33
|
+
* @returns Response indicating success/failure with metadata
|
|
34
|
+
*/
|
|
35
|
+
export const storeChatGPTConversations = async (userId, conversations) => {
|
|
36
|
+
console.log('🚀 [CHATGPT_SERVICE] Storing ChatGPT conversations for:', userId);
|
|
37
|
+
console.log('📊 [CHATGPT_SERVICE] Number of conversations:', conversations.length);
|
|
38
|
+
console.log('📊 [CHATGPT_SERVICE] Total messages:', conversations.reduce((sum, c) => sum + c.user_messages.length, 0));
|
|
39
|
+
|
|
40
|
+
// Input validation
|
|
41
|
+
if (!userId || !conversations || conversations.length === 0) {
|
|
42
|
+
console.error('❌ [CHATGPT_SERVICE] Invalid input');
|
|
43
|
+
return {
|
|
44
|
+
success: false,
|
|
45
|
+
error: 'Invalid input: userId or conversations missing.'
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
// Get auth token - check all possible storage keys (matches rest of codebase)
|
|
50
|
+
const authToken = (await AsyncStorage.getItem('onairos_jwt_token')) || (await AsyncStorage.getItem('enoch_token')) || (await AsyncStorage.getItem('auth_token'));
|
|
51
|
+
if (!authToken) {
|
|
52
|
+
console.error('❌ [CHATGPT_SERVICE] No auth token found in any storage key');
|
|
53
|
+
return {
|
|
54
|
+
success: false,
|
|
55
|
+
error: 'Authentication token not found. Please log in again.'
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
console.log('🔑 [CHATGPT_SERVICE] Auth token found for conversations');
|
|
59
|
+
|
|
60
|
+
// Mobile metadata (matches iOS mobileMetadata)
|
|
61
|
+
const mobileMetadata = {
|
|
62
|
+
platform: Platform.OS,
|
|
63
|
+
appVersion: '1.0.0',
|
|
64
|
+
osVersion: Platform.OS === 'ios' ? '17.0' : Platform.OS,
|
|
65
|
+
deviceModel: Platform.OS === 'ios' ? 'iPhone' : 'Android',
|
|
66
|
+
isOfflineSync: false
|
|
67
|
+
};
|
|
68
|
+
let successCount = 0;
|
|
69
|
+
let failCount = 0;
|
|
70
|
+
|
|
71
|
+
// MATCH iOS: Send ONE request per conversation
|
|
72
|
+
for (let i = 0; i < conversations.length; i++) {
|
|
73
|
+
const conv = conversations[i];
|
|
74
|
+
const now = Date.now();
|
|
75
|
+
|
|
76
|
+
// Build messages array matching iOS format
|
|
77
|
+
// iOS extracts: { id, role, content, timestamp, metadata }
|
|
78
|
+
const messages = conv.user_messages.map((content, msgIndex) => ({
|
|
79
|
+
id: `${conv.conversation_id}-msg-${msgIndex}`,
|
|
80
|
+
role: 'user',
|
|
81
|
+
content: content,
|
|
82
|
+
timestamp: new Date(now - (conv.user_messages.length - msgIndex) * 1000).toISOString(),
|
|
83
|
+
metadata: {}
|
|
84
|
+
}));
|
|
85
|
+
|
|
86
|
+
// Build conversationData matching iOS format exactly
|
|
87
|
+
// From AppDelegate.swift lines 1397-1405
|
|
88
|
+
const conversationData = {
|
|
89
|
+
conversationId: conv.conversation_id,
|
|
90
|
+
// iOS uses camelCase
|
|
91
|
+
messages: messages,
|
|
92
|
+
context: {
|
|
93
|
+
title: conv.title,
|
|
94
|
+
create_time: Math.floor(now / 1000),
|
|
95
|
+
update_time: Math.floor(now / 1000)
|
|
96
|
+
},
|
|
97
|
+
mobileMetadata: mobileMetadata
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// Request body matching iOS sendToBackend format
|
|
101
|
+
// From AppDelegate.swift lines 376-380
|
|
102
|
+
const requestBody = {
|
|
103
|
+
platform: 'mobile-chatgpt',
|
|
104
|
+
// iOS uses "mobile-chatgpt"
|
|
105
|
+
conversationData: conversationData,
|
|
106
|
+
memoryType: 'conversation'
|
|
107
|
+
};
|
|
108
|
+
console.log(`📡 [CHATGPT_SERVICE] Sending conversation ${i + 1}/${conversations.length}: ${conv.title}`);
|
|
109
|
+
try {
|
|
110
|
+
const response = await fetch(`${API_CONFIG.BASE_URL}/llm-data/store`, {
|
|
111
|
+
method: 'POST',
|
|
112
|
+
headers: {
|
|
113
|
+
'Content-Type': 'application/json',
|
|
114
|
+
'Authorization': `Bearer ${authToken}`,
|
|
115
|
+
'User-Agent': `OnairosSDK/1.0.0 (${Platform.OS})`
|
|
116
|
+
},
|
|
117
|
+
body: JSON.stringify(requestBody)
|
|
118
|
+
});
|
|
119
|
+
const responseData = await response.json();
|
|
120
|
+
if (response.ok) {
|
|
121
|
+
console.log(`✅ [CHATGPT_SERVICE] Sent conversation ${i + 1}/${conversations.length}`);
|
|
122
|
+
successCount++;
|
|
123
|
+
} else {
|
|
124
|
+
console.warn(`⚠️ [CHATGPT_SERVICE] Failed conversation ${i + 1}/${conversations.length}:`, responseData.error || response.status);
|
|
125
|
+
failCount++;
|
|
126
|
+
}
|
|
127
|
+
} catch (convError) {
|
|
128
|
+
console.warn(`⚠️ [CHATGPT_SERVICE] Network error for conversation ${i + 1}:`, convError);
|
|
129
|
+
failCount++;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Small delay between requests (iOS uses 0.3s)
|
|
133
|
+
if (i < conversations.length - 1) {
|
|
134
|
+
await new Promise(resolve => setTimeout(resolve, 300));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
console.log(`📊 [CHATGPT_SERVICE] Complete: ${successCount} success, ${failCount} failed`);
|
|
138
|
+
if (successCount > 0) {
|
|
139
|
+
return {
|
|
140
|
+
success: true,
|
|
141
|
+
message: `Stored ${successCount} of ${conversations.length} conversations`
|
|
142
|
+
};
|
|
143
|
+
} else {
|
|
144
|
+
return {
|
|
145
|
+
success: false,
|
|
146
|
+
error: `Failed to store conversations (${failCount} errors)`
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
} catch (error) {
|
|
150
|
+
console.error('❌ [CHATGPT_SERVICE] Network error:', error);
|
|
151
|
+
return {
|
|
152
|
+
success: false,
|
|
153
|
+
error: error.message || 'Network error. Please check your connection.'
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* ChatGPT Memories Data structure (from ChatGPT API)
|
|
160
|
+
*/
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Response from backend /llm-data/store-memories endpoint
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Store ChatGPT memories on backend
|
|
168
|
+
* MATCHES iOS: OnairosChatGPTConnectorPlugin.swift sendMemoriesToBackend()
|
|
169
|
+
*
|
|
170
|
+
* @param memoriesData - Raw ChatGPT memories JSON
|
|
171
|
+
* @returns Response indicating success/failure with metadata
|
|
172
|
+
*/
|
|
173
|
+
export const storeChatGPTMemories = async memoriesData => {
|
|
174
|
+
var _memoriesData$items, _memoriesData$memory_, _memoriesData$memorie;
|
|
175
|
+
console.log('🧠 [CHATGPT_SERVICE] Storing ChatGPT memories...');
|
|
176
|
+
|
|
177
|
+
// Count memory items for logging (matches iOS and WebView script)
|
|
178
|
+
const itemsCount = (memoriesData === null || memoriesData === void 0 || (_memoriesData$items = memoriesData.items) === null || _memoriesData$items === void 0 ? void 0 : _memoriesData$items.length) || 0;
|
|
179
|
+
const entriesCount = (memoriesData === null || memoriesData === void 0 || (_memoriesData$memory_ = memoriesData.memory_entries) === null || _memoriesData$memory_ === void 0 ? void 0 : _memoriesData$memory_.length) || 0;
|
|
180
|
+
const memoriesCount = (memoriesData === null || memoriesData === void 0 || (_memoriesData$memorie = memoriesData.memories) === null || _memoriesData$memorie === void 0 ? void 0 : _memoriesData$memorie.length) || 0;
|
|
181
|
+
const totalCount = itemsCount + entriesCount + memoriesCount;
|
|
182
|
+
console.log(`📋 [CHATGPT_SERVICE] Found ${itemsCount} items, ${entriesCount} entries, ${memoriesCount} memories (total: ${totalCount})`);
|
|
183
|
+
|
|
184
|
+
// Input validation
|
|
185
|
+
if (!memoriesData) {
|
|
186
|
+
console.error('❌ [CHATGPT_SERVICE] Invalid input: memoriesData missing');
|
|
187
|
+
return {
|
|
188
|
+
success: false,
|
|
189
|
+
error: 'Invalid input: memoriesData missing.'
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
// Get auth token - check all possible storage keys (matches rest of codebase)
|
|
194
|
+
const authToken = (await AsyncStorage.getItem('onairos_jwt_token')) || (await AsyncStorage.getItem('enoch_token')) || (await AsyncStorage.getItem('auth_token'));
|
|
195
|
+
if (!authToken) {
|
|
196
|
+
console.error('❌ [CHATGPT_SERVICE] No auth token found in any storage key');
|
|
197
|
+
return {
|
|
198
|
+
success: false,
|
|
199
|
+
error: 'Authentication token not found. Please log in again.'
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
console.log('🔑 [CHATGPT_SERVICE] Auth token found for memories');
|
|
203
|
+
|
|
204
|
+
// Get app version
|
|
205
|
+
const appVersion = '1.0.0';
|
|
206
|
+
|
|
207
|
+
// Build request body matching iOS format exactly
|
|
208
|
+
// From OnairosChatGPTConnectorPlugin.swift lines 486-494
|
|
209
|
+
// CRITICAL: Send raw ChatGPT API response as-is (no transformation)
|
|
210
|
+
// Backend expects: { platform, memoriesData: { items, memory_entries, ... }, metadata }
|
|
211
|
+
const requestBody = {
|
|
212
|
+
platform: 'mobile-chatgpt',
|
|
213
|
+
memoriesData: memoriesData,
|
|
214
|
+
// Raw ChatGPT API response - sent as-is
|
|
215
|
+
metadata: {
|
|
216
|
+
source: 'react-native-sdk',
|
|
217
|
+
appVersion: appVersion,
|
|
218
|
+
fetchedAt: new Date().toISOString()
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// Log the structure being sent (for debugging)
|
|
223
|
+
const memoriesDataKeys = Object.keys(memoriesData || {});
|
|
224
|
+
console.log(`📡 [CHATGPT_SERVICE] Sending memories to backend...`);
|
|
225
|
+
console.log(`📍 [CHATGPT_SERVICE] URL: ${API_CONFIG.BASE_URL}/llm-data/store-memories`);
|
|
226
|
+
console.log(`📦 [CHATGPT_SERVICE] Raw memoriesData keys: ${memoriesDataKeys.join(', ')}`);
|
|
227
|
+
console.log(`📦 [CHATGPT_SERVICE] Raw response sent as-is (no transformation)`);
|
|
228
|
+
const response = await fetch(`${API_CONFIG.BASE_URL}/llm-data/store-memories`, {
|
|
229
|
+
method: 'POST',
|
|
230
|
+
headers: {
|
|
231
|
+
'Content-Type': 'application/json',
|
|
232
|
+
'Authorization': `Bearer ${authToken}`,
|
|
233
|
+
'User-Agent': `OnairosSDK/${appVersion} (${Platform.OS})`
|
|
234
|
+
},
|
|
235
|
+
body: JSON.stringify(requestBody)
|
|
236
|
+
});
|
|
237
|
+
const responseData = await response.json();
|
|
238
|
+
if (response.ok) {
|
|
239
|
+
var _responseData$data;
|
|
240
|
+
console.log('✅ [CHATGPT_SERVICE] Successfully sent memories to backend');
|
|
241
|
+
if (responseData.message) {
|
|
242
|
+
console.log(`📝 [CHATGPT_SERVICE] Backend response: ${responseData.message}`);
|
|
243
|
+
}
|
|
244
|
+
if ((_responseData$data = responseData.data) !== null && _responseData$data !== void 0 && _responseData$data.memoriesCount) {
|
|
245
|
+
console.log(`📋 [CHATGPT_SERVICE] Stored ${responseData.data.memoriesCount} memory items in database`);
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
success: true,
|
|
249
|
+
message: responseData.message || 'Memories stored successfully',
|
|
250
|
+
data: responseData.data
|
|
251
|
+
};
|
|
252
|
+
} else {
|
|
253
|
+
console.warn(`⚠️ [CHATGPT_SERVICE] Memories backend returned status: ${response.status}`);
|
|
254
|
+
console.warn(`⚠️ [CHATGPT_SERVICE] Error: ${responseData.error || 'Unknown error'}`);
|
|
255
|
+
return {
|
|
256
|
+
success: false,
|
|
257
|
+
error: responseData.error || `HTTP ${response.status}`
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
} catch (error) {
|
|
261
|
+
console.error('❌ [CHATGPT_SERVICE] Memories network error:', error);
|
|
262
|
+
return {
|
|
263
|
+
success: false,
|
|
264
|
+
error: error.message || 'Network error. Please check your connection.'
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
//# sourceMappingURL=chatGPTConversationService.js.map
|
|
@@ -1 +1,97 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Claude Conversation Extractor
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates the Claude conversation export flow:
|
|
5
|
+
* 1. Receives extracted conversations from WebView
|
|
6
|
+
* 2. Validates and formats data
|
|
7
|
+
* 3. Sends to backend via claudeConversationService
|
|
8
|
+
*
|
|
9
|
+
* This acts as the bridge between OAuthWebView and the backend API.
|
|
10
|
+
*
|
|
11
|
+
* @reference Enoch implementation: src/services/claudeConversationExtractor.ts
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { storeClaudeConversations } from './claudeConversationService';
|
|
15
|
+
import { Alert } from 'react-native';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Hook for Claude conversation extraction operations
|
|
19
|
+
*/
|
|
20
|
+
export const useClaudeConversationExtractor = () => {
|
|
21
|
+
/**
|
|
22
|
+
* Initiate conversation export to backend
|
|
23
|
+
*
|
|
24
|
+
* @param username - User identifier
|
|
25
|
+
* @param conversations - Array of conversations with user messages
|
|
26
|
+
* @returns true if successful, false otherwise
|
|
27
|
+
*/
|
|
28
|
+
const initiateConversationExport = async (username, conversations) => {
|
|
29
|
+
console.log('🚀 [CLAUDE_EXTRACTOR] Initiating conversation export');
|
|
30
|
+
console.log('👤 [CLAUDE_EXTRACTOR] Username:', username);
|
|
31
|
+
console.log('📊 [CLAUDE_EXTRACTOR] Conversations to send:', conversations.length);
|
|
32
|
+
|
|
33
|
+
// Validation
|
|
34
|
+
if (!username) {
|
|
35
|
+
console.error('❌ [CLAUDE_EXTRACTOR] Username is required');
|
|
36
|
+
Alert.alert('Error', 'Username is required to export Claude conversations.', [{
|
|
37
|
+
text: 'OK',
|
|
38
|
+
style: 'default'
|
|
39
|
+
}]);
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Handle 0 conversations as success - user might be new or have cleared history
|
|
44
|
+
// This matches iOS behavior where empty conversations still counts as successful connection
|
|
45
|
+
if (!conversations || conversations.length === 0) {
|
|
46
|
+
console.log('ℹ️ [CLAUDE_EXTRACTOR] No conversations to export - treating as success (connected)');
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Validate conversation structure
|
|
51
|
+
const validConversations = conversations.filter(conv => {
|
|
52
|
+
const isValid = conv.conversation_id && conv.title && Array.isArray(conv.user_messages) && conv.user_messages.length > 0;
|
|
53
|
+
if (!isValid) {
|
|
54
|
+
console.warn('⚠️ [CLAUDE_EXTRACTOR] Invalid conversation:', conv);
|
|
55
|
+
}
|
|
56
|
+
return isValid;
|
|
57
|
+
});
|
|
58
|
+
if (validConversations.length === 0) {
|
|
59
|
+
console.error('❌ [CLAUDE_EXTRACTOR] No valid conversations after filtering');
|
|
60
|
+
Alert.alert('Data Error', 'No valid conversations found to export.', [{
|
|
61
|
+
text: 'OK',
|
|
62
|
+
style: 'default'
|
|
63
|
+
}]);
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if (validConversations.length < conversations.length) {
|
|
67
|
+
console.warn(`⚠️ [CLAUDE_EXTRACTOR] Filtered out ${conversations.length - validConversations.length} invalid conversations`);
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
console.log('📡 [CLAUDE_EXTRACTOR] Sending to backend...');
|
|
71
|
+
const result = await storeClaudeConversations(username, validConversations);
|
|
72
|
+
if (result.success) {
|
|
73
|
+
console.log('✅ [CLAUDE_EXTRACTOR] Export completed successfully');
|
|
74
|
+
console.log('📊 [CLAUDE_EXTRACTOR] Backend response:', result.data);
|
|
75
|
+
return true;
|
|
76
|
+
} else {
|
|
77
|
+
console.error('❌ [CLAUDE_EXTRACTOR] Backend storage failed:', result.error);
|
|
78
|
+
Alert.alert('Export Failed', result.error || 'An unknown error occurred during conversation storage.', [{
|
|
79
|
+
text: 'OK',
|
|
80
|
+
style: 'default'
|
|
81
|
+
}]);
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error('❌ [CLAUDE_EXTRACTOR] Unexpected error during export:', error);
|
|
86
|
+
Alert.alert('Export Error', 'Failed to connect to the conversation storage service. Please check your network connection.', [{
|
|
87
|
+
text: 'OK',
|
|
88
|
+
style: 'default'
|
|
89
|
+
}]);
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
return {
|
|
94
|
+
initiateConversationExport
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=claudeConversationExtractor.js.map
|
|
@@ -1 +1,151 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Claude Conversation Service
|
|
3
|
+
*
|
|
4
|
+
* API layer for storing Claude conversation data on backend.
|
|
5
|
+
* Sends extracted user messages to /llm-data/store endpoint.
|
|
6
|
+
*
|
|
7
|
+
* MATCHES Enoch implementation pattern
|
|
8
|
+
* - Sends ONE request per conversation (not all at once)
|
|
9
|
+
* - Uses format: { conversationId, messages[], context }
|
|
10
|
+
* - Platform: "mobile-claude"
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { API_CONFIG } from '../config/api';
|
|
14
|
+
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
15
|
+
import { Platform } from 'react-native';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Structure of conversation messages extracted from Claude
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Response from backend /llm-data/store endpoint
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Store Claude conversations on backend
|
|
27
|
+
* Sends one request per conversation (matches ChatGPT pattern)
|
|
28
|
+
*
|
|
29
|
+
* @param userId - Username or identifier
|
|
30
|
+
* @param conversations - Array of conversations with user messages
|
|
31
|
+
* @returns Response indicating success/failure with metadata
|
|
32
|
+
*/
|
|
33
|
+
export const storeClaudeConversations = async (userId, conversations) => {
|
|
34
|
+
console.log('🚀 [CLAUDE_SERVICE] Storing Claude conversations for:', userId);
|
|
35
|
+
console.log('📊 [CLAUDE_SERVICE] Number of conversations:', conversations.length);
|
|
36
|
+
console.log('📊 [CLAUDE_SERVICE] Total messages:', conversations.reduce((sum, c) => sum + c.user_messages.length, 0));
|
|
37
|
+
|
|
38
|
+
// Input validation
|
|
39
|
+
if (!userId || !conversations || conversations.length === 0) {
|
|
40
|
+
console.error('❌ [CLAUDE_SERVICE] Invalid input');
|
|
41
|
+
return {
|
|
42
|
+
success: false,
|
|
43
|
+
error: 'Invalid input: userId or conversations missing.'
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
// Get auth token - check all possible storage keys (matches rest of codebase)
|
|
48
|
+
const authToken = (await AsyncStorage.getItem('onairos_jwt_token')) || (await AsyncStorage.getItem('enoch_token')) || (await AsyncStorage.getItem('auth_token'));
|
|
49
|
+
if (!authToken) {
|
|
50
|
+
console.error('❌ [CLAUDE_SERVICE] No auth token found in any storage key');
|
|
51
|
+
return {
|
|
52
|
+
success: false,
|
|
53
|
+
error: 'Authentication token not found. Please log in again.'
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
console.log('🔑 [CLAUDE_SERVICE] Auth token found');
|
|
57
|
+
|
|
58
|
+
// Mobile metadata
|
|
59
|
+
const mobileMetadata = {
|
|
60
|
+
platform: Platform.OS,
|
|
61
|
+
appVersion: '1.0.0',
|
|
62
|
+
osVersion: Platform.OS === 'ios' ? '17.0' : Platform.OS,
|
|
63
|
+
deviceModel: Platform.OS === 'ios' ? 'iPhone' : 'Android',
|
|
64
|
+
isOfflineSync: false
|
|
65
|
+
};
|
|
66
|
+
let successCount = 0;
|
|
67
|
+
let failCount = 0;
|
|
68
|
+
|
|
69
|
+
// Send ONE request per conversation (matches ChatGPT pattern)
|
|
70
|
+
for (let i = 0; i < conversations.length; i++) {
|
|
71
|
+
const conv = conversations[i];
|
|
72
|
+
const now = Date.now();
|
|
73
|
+
|
|
74
|
+
// Build messages array matching format
|
|
75
|
+
const messages = conv.user_messages.map((content, msgIndex) => ({
|
|
76
|
+
id: `${conv.conversation_id}-msg-${msgIndex}`,
|
|
77
|
+
role: 'user',
|
|
78
|
+
content: content,
|
|
79
|
+
timestamp: new Date(now - (conv.user_messages.length - msgIndex) * 1000).toISOString(),
|
|
80
|
+
metadata: {}
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
// Build conversationData
|
|
84
|
+
const conversationData = {
|
|
85
|
+
conversationId: conv.conversation_id,
|
|
86
|
+
messages: messages,
|
|
87
|
+
context: {
|
|
88
|
+
title: conv.title,
|
|
89
|
+
create_time: Math.floor(now / 1000),
|
|
90
|
+
update_time: Math.floor(now / 1000)
|
|
91
|
+
},
|
|
92
|
+
mobileMetadata: mobileMetadata
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// Request body
|
|
96
|
+
const requestBody = {
|
|
97
|
+
platform: 'mobile-claude',
|
|
98
|
+
// Claude platform identifier
|
|
99
|
+
conversationData: conversationData,
|
|
100
|
+
memoryType: 'conversation'
|
|
101
|
+
};
|
|
102
|
+
console.log(`📡 [CLAUDE_SERVICE] Sending conversation ${i + 1}/${conversations.length}: ${conv.title}`);
|
|
103
|
+
try {
|
|
104
|
+
const response = await fetch(`${API_CONFIG.BASE_URL}/llm-data/store`, {
|
|
105
|
+
method: 'POST',
|
|
106
|
+
headers: {
|
|
107
|
+
'Content-Type': 'application/json',
|
|
108
|
+
'Authorization': `Bearer ${authToken}`,
|
|
109
|
+
'User-Agent': `OnairosSDK/1.0.0 (${Platform.OS})`
|
|
110
|
+
},
|
|
111
|
+
body: JSON.stringify(requestBody)
|
|
112
|
+
});
|
|
113
|
+
const responseData = await response.json();
|
|
114
|
+
if (response.ok) {
|
|
115
|
+
console.log(`✅ [CLAUDE_SERVICE] Sent conversation ${i + 1}/${conversations.length}`);
|
|
116
|
+
successCount++;
|
|
117
|
+
} else {
|
|
118
|
+
console.warn(`⚠️ [CLAUDE_SERVICE] Failed conversation ${i + 1}/${conversations.length}:`, responseData.error || response.status);
|
|
119
|
+
failCount++;
|
|
120
|
+
}
|
|
121
|
+
} catch (convError) {
|
|
122
|
+
console.warn(`⚠️ [CLAUDE_SERVICE] Network error for conversation ${i + 1}:`, convError);
|
|
123
|
+
failCount++;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Small delay between requests (0.3s like ChatGPT)
|
|
127
|
+
if (i < conversations.length - 1) {
|
|
128
|
+
await new Promise(resolve => setTimeout(resolve, 300));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
console.log(`📊 [CLAUDE_SERVICE] Complete: ${successCount} success, ${failCount} failed`);
|
|
132
|
+
if (successCount > 0) {
|
|
133
|
+
return {
|
|
134
|
+
success: true,
|
|
135
|
+
message: `Stored ${successCount} of ${conversations.length} conversations`
|
|
136
|
+
};
|
|
137
|
+
} else {
|
|
138
|
+
return {
|
|
139
|
+
success: false,
|
|
140
|
+
error: `Failed to store conversations (${failCount} errors)`
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
} catch (error) {
|
|
144
|
+
console.error('❌ [CLAUDE_SERVICE] Network error:', error);
|
|
145
|
+
return {
|
|
146
|
+
success: false,
|
|
147
|
+
error: error.message || 'Network error. Please check your connection.'
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=claudeConversationService.js.map
|