@onairos/react-native 3.7.2 → 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/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/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';import AsyncStorage from'@react-native-async-storage/async-storage';import{Platform}from'react-native';function _0x2c19(_0xf9aea0,_0x2c199b){_0xf9aea0=_0xf9aea0-0x0;const _0x630de0=_0xf9ae();let _0x388c33=_0x630de0[_0xf9aea0];return _0x388c33;}export const storeChatGPTConversations=async(_0x3dda83,_0x14e235)=>{const _0x33f41b={'pOmMC':'Authentication\x20token\x20not\x20found.\x20Please\x20log\x20in\x20again.','BnqHd':'Network\x20error.\x20Please\x20check\x20your\x20connection.','qzjbi':_0x2c19(0x0),'dBono':_0x2c19(0x1),'EZbJb':_0x2c19(0x2),'Mugbl':function(_0x14a79a,_0x3fb4ae){return _0x14a79a+_0x3fb4ae;},'GyQyl':'📊\x20[CHATGPT_SERVICE]\x20Number\x20of\x20conversations:','enLtC':_0x2c19(0x3),'AcKeJ':function(_0x233f1e,_0x229b77){return _0x233f1e||_0x229b77;},'HdOZU':function(_0x35bd35,_0x48b9bb){return _0x35bd35===_0x48b9bb;},'ZVoHN':_0x2c19(0x4),'EYspR':_0x2c19(0x5),'lrNAb':_0x2c19(0x6),'RlLfR':_0x2c19(0x7),'FoyfX':'🔑\x20[CHATGPT_SERVICE]\x20Auth\x20token\x20found\x20for\x20conversations','AcWxf':_0x2c19(0x8),'ISelC':function(_0x15383a,_0xe6b5d8){return _0x15383a===_0xe6b5d8;},'yaQlA':'17.0','SQvQP':_0x2c19(0x9),'elwGc':_0x2c19(0xa),'aVkaK':_0x2c19(0xb),'WRSQN':_0x2c19(0xc),'kJNCu':function(_0x1f55b1,_0x4c256e){return _0x1f55b1/_0x4c256e;},'ajbYY':function(_0x894703,_0x3d6f7f){return _0x894703/_0x3d6f7f;},'qqhYp':_0x2c19(0xd),'SXUKq':function(_0x4b6c14,_0x21242e){return _0x4b6c14===_0x21242e;},'FrTix':_0x2c19(0xe),'bJNdq':'wBgQZ','bLUKl':function(_0x3d95e5,_0x552c54,_0x34d032){return _0x3d95e5(_0x552c54,_0x34d032);},'QREGO':function(_0xc1432d,_0x9e7189){return _0xc1432d===_0x9e7189;},'PrwUh':_0x2c19(0xf),'KiEqS':_0x2c19(0x10),'PEyrO':function(_0x335d58,_0x5cac24){return _0x335d58<_0x5cac24;},'izEfU':function(_0x455de4,_0x1c048c){return _0x455de4-_0x1c048c;},'NXChi':function(_0x2bd349,_0x46052b){return _0x2bd349!==_0x46052b;},'yXomO':_0x2c19(0x11),'ZJAma':_0x2c19(0x12),'uBPAb':function(_0x281b2e,_0x5084fd){return _0x281b2e>_0x5084fd;},'UdiEb':'vxPrr','TLroY':function(_0x2dfe4f,_0x2d4334){return _0x2dfe4f===_0x2d4334;},'EYCkE':_0x2c19(0x13),'vXcVh':_0x2c19(0x14)};console[_0x2c19(0x15)](_0x2c19(0x16),_0x3dda83),console[_0x2c19(0x15)](_0x33f41b['GyQyl'],_0x14e235[_0x2c19(0x17)]),console['log'](_0x33f41b['enLtC'],_0x14e235[_0x2c19(0x18)]((_0x149c9f,_0x5737fb)=>_0x149c9f+_0x5737fb[_0x2c19(0x19)][_0x2c19(0x17)],0x0));if(_0x33f41b['AcKeJ'](!_0x3dda83,!_0x14e235)||_0x33f41b[_0x2c19(0x1a)](_0x14e235[_0x2c19(0x17)],0x0))return console[_0x2c19(0x1b)](_0x33f41b['qzjbi']),{'success':![],'error':_0x33f41b[_0x2c19(0x1c)]};try{const _0xd3cde6=await AsyncStorage[_0x2c19(0x1d)](_0x33f41b[_0x2c19(0x1e)])||await AsyncStorage[_0x2c19(0x1d)](_0x33f41b['EYspR'])||await AsyncStorage[_0x2c19(0x1d)](_0x2c19(0x1f));if(!_0xd3cde6)return _0x33f41b['lrNAb']!==_0x33f41b[_0x2c19(0x20)]?(_0x47df86[_0x2c19(0x1b)](_0x2c19(0x7)),{'success':![],'error':_0x33f41b[_0x2c19(0x21)]}):(console[_0x2c19(0x1b)](_0x33f41b[_0x2c19(0x22)]),{'success':![],'error':'Authentication\x20token\x20not\x20found.\x20Please\x20log\x20in\x20again.'});console[_0x2c19(0x15)](_0x33f41b['FoyfX']);const _0x109b78={'platform':Platform['OS'],'appVersion':_0x33f41b[_0x2c19(0x23)],'osVersion':_0x33f41b[_0x2c19(0x24)](Platform['OS'],_0x2c19(0x25))?_0x33f41b[_0x2c19(0x26)]:Platform['OS'],'deviceModel':_0x33f41b[_0x2c19(0x24)](Platform['OS'],_0x2c19(0x25))?_0x33f41b[_0x2c19(0x27)]:_0x33f41b[_0x2c19(0x28)],'isOfflineSync':![]};let _0x3332f4=0x0,_0x57d2dc=0x0;for(let _0x2f379d=0x0;_0x2f379d<_0x14e235[_0x2c19(0x17)];_0x2f379d++){if(_0x33f41b[_0x2c19(0x1a)](_0x33f41b[_0x2c19(0x29)],_0x33f41b[_0x2c19(0x2a)]))return _0x3400be[_0x2c19(0x1b)](_0x2c19(0x14),_0x1aa6f9),{'success':![],'error':_0x40afff['message']||_0x33f41b[_0x2c19(0x2b)]};else{const _0x3adcee=_0x14e235[_0x2f379d],_0x4599e3=Date['now'](),_0x173234=_0x3adcee[_0x2c19(0x19)][_0x2c19(0x2c)]((_0x4483a8,_0x5b60a4)=>({'id':_0x3adcee[_0x2c19(0x2d)]+_0x2c19(0x2e)+_0x5b60a4,'role':_0x2c19(0x2f),'content':_0x4483a8,'timestamp':new Date(_0x4599e3-(_0x3adcee[_0x2c19(0x19)][_0x2c19(0x17)]-_0x5b60a4)*0x3e8)[_0x2c19(0x30)](),'metadata':{}})),_0xbc7b4a={'conversationId':_0x3adcee['conversation_id'],'messages':_0x173234,'context':{'title':_0x3adcee[_0x2c19(0x31)],'create_time':Math['floor'](_0x33f41b[_0x2c19(0x32)](_0x4599e3,0x3e8)),'update_time':Math[_0x2c19(0x33)](_0x33f41b[_0x2c19(0x34)](_0x4599e3,0x3e8))},'mobileMetadata':_0x109b78},_0x1e849a={'platform':_0x2c19(0x35),'conversationData':_0xbc7b4a,'memoryType':_0x33f41b[_0x2c19(0x36)]};console[_0x2c19(0x15)](_0x2c19(0x37)+(_0x2f379d+0x1)+'/'+_0x14e235['length']+':\x20'+_0x3adcee['title']);try{if(_0x33f41b['SXUKq'](_0x33f41b['FrTix'],_0x33f41b[_0x2c19(0x38)]))return{'success':![],'error':_0x2c19(0x39)+_0xe8bb33+_0x2c19(0x3a)};else{const _0x531622=await _0x33f41b[_0x2c19(0x3b)](fetch,API_CONFIG['BASE_URL']+_0x2c19(0x3c),{'method':'POST','headers':{'Content-Type':'application/json','Authorization':_0x2c19(0x3d)+_0xd3cde6,'User-Agent':_0x2c19(0x3e)+Platform['OS']+')'},'body':JSON[_0x2c19(0x3f)](_0x1e849a)}),_0x3e3dd1=await _0x531622[_0x2c19(0x40)]();if(_0x531622['ok']){if(_0x33f41b[_0x2c19(0x41)](_0x33f41b[_0x2c19(0x42)],_0x33f41b[_0x2c19(0x43)]))return _0x424494[_0x2c19(0x1b)](_0x33f41b[_0x2c19(0x44)]),{'success':![],'error':_0x33f41b['dBono']};else console[_0x2c19(0x15)]('✅\x20[CHATGPT_SERVICE]\x20Sent\x20conversation\x20'+_0x33f41b[_0x2c19(0x45)](_0x2f379d,0x1)+'/'+_0x14e235[_0x2c19(0x17)]),_0x3332f4++;}else console[_0x2c19(0x46)](_0x2c19(0x47)+(_0x2f379d+0x1)+'/'+_0x14e235['length']+':',_0x3e3dd1[_0x2c19(0x1b)]||_0x531622[_0x2c19(0x48)]),_0x57d2dc++;}}catch(_0x538766){console['warn'](_0x2c19(0x49)+_0x33f41b[_0x2c19(0x45)](_0x2f379d,0x1)+':',_0x538766),_0x57d2dc++;}if(_0x33f41b['PEyrO'](_0x2f379d,_0x33f41b[_0x2c19(0x4a)](_0x14e235[_0x2c19(0x17)],0x1))){if(_0x33f41b['NXChi'](_0x33f41b[_0x2c19(0x4b)],_0x33f41b[_0x2c19(0x4c)]))await new Promise(_0x2da631=>setTimeout(_0x2da631,0x12c));else return _0x108b21[_0x2c19(0x46)](_0x2c19(0x4d)+_0x5d9bf5[_0x2c19(0x48)]),_0x23ac82[_0x2c19(0x46)](_0x2c19(0x4e)+(_0x36d91c[_0x2c19(0x1b)]||_0x33f41b[_0x2c19(0x4f)])),{'success':![],'error':_0xf7e473[_0x2c19(0x1b)]||_0x2c19(0x50)+_0x29ce86[_0x2c19(0x48)]};}}}console[_0x2c19(0x15)](_0x2c19(0x51)+_0x3332f4+_0x2c19(0x52)+_0x57d2dc+_0x2c19(0x53));if(_0x33f41b[_0x2c19(0x54)](_0x3332f4,0x0))return _0x33f41b['ISelC'](_0x2c19(0x55),_0x33f41b[_0x2c19(0x56)])?(_0x900928[_0x2c19(0x1b)](_0x2c19(0x57)),{'success':![],'error':'Invalid\x20input:\x20memoriesData\x20missing.'}):{'success':!![],'message':_0x2c19(0x58)+_0x3332f4+_0x2c19(0x59)+_0x14e235['length']+_0x2c19(0x5a)};else{if(_0x33f41b[_0x2c19(0x5b)](_0x33f41b['EYCkE'],_0x33f41b[_0x2c19(0x5c)]))return{'success':![],'error':_0x2c19(0x39)+_0x57d2dc+_0x2c19(0x3a)};else _0x3684fe['log'](_0x2c19(0x5d)+_0x33f41b[_0x2c19(0x45)](_0x77e931,0x1)+'/'+_0x25e248[_0x2c19(0x17)]),_0x59f9f3++;}}catch(_0xcd9a0c){return console[_0x2c19(0x1b)](_0x33f41b[_0x2c19(0x5e)],_0xcd9a0c),{'success':![],'error':_0xcd9a0c[_0x2c19(0x5f)]||_0x2c19(0x60)};}};function _0xf9ae(){const _0x474f99=['❌\x20[CHATGPT_SERVICE]\x20Invalid\x20input','Invalid\x20input:\x20userId\x20or\x20conversations\x20missing.','Unknown\x20error','📊\x20[CHATGPT_SERVICE]\x20Total\x20messages:','onairos_jwt_token','enoch_token','LgCom','❌\x20[CHATGPT_SERVICE]\x20No\x20auth\x20token\x20found\x20in\x20any\x20storage\x20key','1.0.0','iPhone','Android','iYEZj','CniDe','conversation','xpjAf','uiMKG','cNSpz','qVlro','qNyaN','GyhgH','❌\x20[CHATGPT_SERVICE]\x20Network\x20error:','log','🚀\x20[CHATGPT_SERVICE]\x20Storing\x20ChatGPT\x20conversations\x20for:','length','reduce','user_messages','HdOZU','error','dBono','getItem','ZVoHN','auth_token','lrNAb','pOmMC','RlLfR','AcWxf','ISelC','ios','yaQlA','SQvQP','elwGc','aVkaK','WRSQN','BnqHd','map','conversation_id','-msg-','user','toISOString','title','kJNCu','floor','ajbYY','mobile-chatgpt','qqhYp','📡\x20[CHATGPT_SERVICE]\x20Sending\x20conversation\x20','bJNdq','Failed\x20to\x20store\x20conversations\x20(','\x20errors)','bLUKl','/llm-data/store','Bearer\x20','OnairosSDK/1.0.0\x20(','stringify','json','QREGO','PrwUh','KiEqS','qzjbi','Mugbl','warn','⚠️\x20[CHATGPT_SERVICE]\x20Failed\x20conversation\x20','status','⚠️\x20[CHATGPT_SERVICE]\x20Network\x20error\x20for\x20conversation\x20','izEfU','yXomO','ZJAma','⚠️\x20[CHATGPT_SERVICE]\x20Memories\x20backend\x20returned\x20status:\x20','⚠️\x20[CHATGPT_SERVICE]\x20Error:\x20','EZbJb','HTTP\x20','📊\x20[CHATGPT_SERVICE]\x20Complete:\x20','\x20success,\x20','\x20failed','uBPAb','UkZvQ','UdiEb','❌\x20[CHATGPT_SERVICE]\x20Invalid\x20input:\x20memoriesData\x20missing','Stored\x20','\x20of\x20','\x20conversations','TLroY','EYCkE','✅\x20[CHATGPT_SERVICE]\x20Sent\x20conversation\x20','vXcVh','message','Network\x20error.\x20Please\x20check\x20your\x20connection.','❌\x20[CHATGPT_SERVICE]\x20Memories\x20network\x20error:','🔑\x20[CHATGPT_SERVICE]\x20Auth\x20token\x20found\x20for\x20memories','UDkDj','4|1|0|2|3','✅\x20[CHATGPT_SERVICE]\x20Successfully\x20sent\x20memories\x20to\x20backend','Memories\x20stored\x20successfully','EApqm','Seype','hLuay','DQQXO','zisAF','CBXQg','items','VQgFf','memory_entries','memories','BAJUC','\x20items,\x20','\x20memories\x20(total:\x20','GxLFY','AUorN','xoato','RADhL','oELNV','SQdVM','NgMPW','keys','📡\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)','DxWiv','OnairosSDK/','PUPCM','NoNtp','📝\x20[CHATGPT_SERVICE]\x20Backend\x20response:\x20','yJbjj','wLemG','memoriesCount','📋\x20[CHATGPT_SERVICE]\x20Stored\x20','\x20memory\x20items\x20in\x20database','ycJku','AjcbR','Emfwm','Mdioz','YURlh'];_0xf9ae=function(){return _0x474f99;};return _0xf9ae();}export const storeChatGPTMemories=async _0xeab75=>{const _0x1876b0={'AjcbR':_0x2c19(0x61),'Emfwm':_0x2c19(0x60),'DQQXO':'🧠\x20[CHATGPT_SERVICE]\x20Storing\x20ChatGPT\x20memories...','zisAF':function(_0x4bc182,_0x38cc35){return _0x4bc182===_0x38cc35;},'CBXQg':function(_0x30c16d,_0x567d6c){return _0x30c16d===_0x567d6c;},'VQgFf':function(_0x1e91f2,_0x110495){return _0x1e91f2===_0x110495;},'BAJUC':function(_0x15e2a4,_0x46f635){return _0x15e2a4===_0x46f635;},'Qlldw':function(_0x47392c,_0xcec45c){return _0x47392c+_0xcec45c;},'aiXbx':function(_0x493f24,_0x58bffd){return _0x493f24+_0x58bffd;},'GxLFY':_0x2c19(0x57),'AUorN':'Invalid\x20input:\x20memoriesData\x20missing.','cXhsm':_0x2c19(0x4),'xoato':_0x2c19(0x5),'RADhL':_0x2c19(0x1f),'oELNV':_0x2c19(0x7),'SQdVM':_0x2c19(0x62),'NgMPW':_0x2c19(0x35),'DxWiv':function(_0x41af9c,_0x394b9d,_0x3cd29d){return _0x41af9c(_0x394b9d,_0x3cd29d);},'PUPCM':_0x2c19(0x63),'NoNtp':_0x2c19(0x64),'zAQGe':_0x2c19(0x65),'yJbjj':function(_0x40d657,_0x503a45){return _0x40d657!==_0x503a45;},'wLemG':function(_0x31ca60,_0x5f6103){return _0x31ca60!==_0x5f6103;},'ycJku':_0x2c19(0x66),'TgrsL':function(_0x4d54ea,_0x1eb7cf){return _0x4d54ea===_0x1eb7cf;},'Gvief':_0x2c19(0x67),'Mdioz':_0x2c19(0x68),'lNWIn':_0x2c19(0x2),'YURlh':_0x2c19(0x69)};var _0x3a7640,_0x36602d,_0x4ed1f3;console[_0x2c19(0x15)](_0x1876b0[_0x2c19(0x6a)]);const _0x28772b=(_0x1876b0[_0x2c19(0x6b)](_0xeab75,null)||_0xeab75===void 0x0||_0x1876b0[_0x2c19(0x6c)](_0x3a7640=_0xeab75[_0x2c19(0x6d)],null)||_0x1876b0[_0x2c19(0x6b)](_0x3a7640,void 0x0)?void 0x0:_0x3a7640[_0x2c19(0x17)])||0x0,_0x28295e=(_0xeab75===null||_0x1876b0[_0x2c19(0x6e)](_0xeab75,void 0x0)||_0x1876b0[_0x2c19(0x6c)](_0x36602d=_0xeab75[_0x2c19(0x6f)],null)||_0x1876b0[_0x2c19(0x6b)](_0x36602d,void 0x0)?void 0x0:_0x36602d[_0x2c19(0x17)])||0x0,_0x200577=(_0x1876b0['VQgFf'](_0xeab75,null)||_0xeab75===void 0x0||_0x1876b0[_0x2c19(0x6e)](_0x4ed1f3=_0xeab75[_0x2c19(0x70)],null)||_0x1876b0[_0x2c19(0x71)](_0x4ed1f3,void 0x0)?void 0x0:_0x4ed1f3[_0x2c19(0x17)])||0x0,_0x3c9249=_0x1876b0['Qlldw'](_0x1876b0['aiXbx'](_0x28772b,_0x28295e),_0x200577);console[_0x2c19(0x15)]('📋\x20[CHATGPT_SERVICE]\x20Found\x20'+_0x28772b+_0x2c19(0x72)+_0x28295e+'\x20entries,\x20'+_0x200577+_0x2c19(0x73)+_0x3c9249+')');if(!_0xeab75)return console[_0x2c19(0x1b)](_0x1876b0[_0x2c19(0x74)]),{'success':![],'error':_0x1876b0[_0x2c19(0x75)]};try{const _0x27216f=await AsyncStorage[_0x2c19(0x1d)](_0x1876b0['cXhsm'])||await AsyncStorage[_0x2c19(0x1d)](_0x1876b0[_0x2c19(0x76)])||await AsyncStorage[_0x2c19(0x1d)](_0x1876b0[_0x2c19(0x77)]);if(!_0x27216f)return console[_0x2c19(0x1b)](_0x1876b0[_0x2c19(0x78)]),{'success':![],'error':'Authentication\x20token\x20not\x20found.\x20Please\x20log\x20in\x20again.'};console['log'](_0x1876b0[_0x2c19(0x79)]);const _0x5cfc65=_0x2c19(0x8),_0x32b68d={'platform':_0x1876b0[_0x2c19(0x7a)],'memoriesData':_0xeab75,'metadata':{'source':'react-native-sdk','appVersion':_0x5cfc65,'fetchedAt':new Date()['toISOString']()}},_0x12d947=Object[_0x2c19(0x7b)](_0xeab75||{});console[_0x2c19(0x15)](_0x2c19(0x7c)),console[_0x2c19(0x15)](_0x2c19(0x7d)+API_CONFIG[_0x2c19(0x7e)]+_0x2c19(0x7f)),console['log'](_0x2c19(0x80)+_0x12d947[_0x2c19(0x81)](',\x20')),console[_0x2c19(0x15)](_0x2c19(0x82));const _0x4734bd=await _0x1876b0[_0x2c19(0x83)](fetch,API_CONFIG['BASE_URL']+'/llm-data/store-memories',{'method':'POST','headers':{'Content-Type':'application/json','Authorization':_0x2c19(0x3d)+_0x27216f,'User-Agent':_0x2c19(0x84)+_0x5cfc65+'\x20('+Platform['OS']+')'},'body':JSON['stringify'](_0x32b68d)}),_0x2fe27c=await _0x4734bd['json']();if(_0x4734bd['ok']){if(_0x1876b0[_0x2c19(0x71)](_0x2c19(0x63),_0x1876b0[_0x2c19(0x85)])){const _0x4ae77e=_0x1876b0[_0x2c19(0x86)]['split']('|');let _0x500b1e=0x0;while(!![]){switch(_0x4ae77e[_0x500b1e++]){case'0':_0x2fe27c['message']&&console[_0x2c19(0x15)](_0x2c19(0x87)+_0x2fe27c[_0x2c19(0x5f)]);continue;case'1':console['log'](_0x1876b0['zAQGe']);continue;case'2':_0x1876b0[_0x2c19(0x88)](_0x56ac46=_0x2fe27c['data'],null)&&_0x1876b0[_0x2c19(0x89)](_0x56ac46,void 0x0)&&_0x56ac46[_0x2c19(0x8a)]&&console['log'](_0x2c19(0x8b)+_0x2fe27c['data'][_0x2c19(0x8a)]+_0x2c19(0x8c));continue;case'3':return{'success':!![],'message':_0x2fe27c[_0x2c19(0x5f)]||_0x1876b0[_0x2c19(0x8d)],'data':_0x2fe27c['data']};case'4':var _0x56ac46;continue;}break;}}else return _0x545445[_0x2c19(0x1b)](_0x1876b0[_0x2c19(0x8e)],_0xe8ca78),{'success':![],'error':_0xc75d87[_0x2c19(0x5f)]||_0x1876b0[_0x2c19(0x8f)]};}else return _0x1876b0['TgrsL'](_0x1876b0['Gvief'],_0x1876b0[_0x2c19(0x90)])?{'success':!![],'message':_0x2c19(0x58)+_0x517f07+_0x2c19(0x59)+_0x34def0[_0x2c19(0x17)]+_0x2c19(0x5a)}:(console[_0x2c19(0x46)]('⚠️\x20[CHATGPT_SERVICE]\x20Memories\x20backend\x20returned\x20status:\x20'+_0x4734bd[_0x2c19(0x48)]),console[_0x2c19(0x46)](_0x2c19(0x4e)+(_0x2fe27c[_0x2c19(0x1b)]||_0x1876b0['lNWIn'])),{'success':![],'error':_0x2fe27c['error']||_0x2c19(0x50)+_0x4734bd[_0x2c19(0x48)]});}catch(_0x40ecae){if(_0x1876b0[_0x2c19(0x71)](_0x1876b0[_0x2c19(0x91)],_0x1876b0['YURlh']))return console[_0x2c19(0x1b)](_0x1876b0['AjcbR'],_0x40ecae),{'success':![],'error':_0x40ecae[_0x2c19(0x5f)]||_0x2c19(0x60)};else _0x4b3d15[_0x2c19(0x46)](_0x2c19(0x47)+(_0x3401de+0x1)+'/'+_0x55d255['length']+':',_0x10d05d[_0x2c19(0x1b)]||_0x4c0be4[_0x2c19(0x48)]),_0x5d56f9++;}};
|
|
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
|