@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,8 +1,155 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object[_0x11ab(0x0)](exports,_0x11ab(0x1),{'value':!![]}),exports[_0x11ab(0x2)]=void 0x0;function _0x286e(){const _0x70a81d=['defineProperty','__esModule','useChatGPTConversationExtractor','default','⚠️\x20[CHATGPT_EXTRACTOR]\x20Invalid\x20conversation:','❌\x20[CHATGPT_EXTRACTOR]\x20No\x20valid\x20conversations\x20after\x20filtering','👤\x20[CHATGPT_EXTRACTOR]\x20Username:','📊\x20[CHATGPT_EXTRACTOR]\x20Conversations\x20to\x20send:','❌\x20[CHATGPT_EXTRACTOR]\x20Username\x20is\x20required','Username\x20is\x20required\x20to\x20export\x20ChatGPT\x20conversations.','KEjxW','cCMMP','ℹ️\x20[CHATGPT_EXTRACTOR]\x20No\x20conversations\x20to\x20export\x20-\x20treating\x20as\x20success\x20(connected)','Data\x20Error','No\x20valid\x20conversations\x20found\x20to\x20export.','aqDEo','📡\x20[CHATGPT_EXTRACTOR]\x20Sending\x20to\x20backend...','gKzvw','BOBXK','Export\x20Failed','HdAEl','eysoA','❌\x20[CHATGPT_EXTRACTOR]\x20Unexpected\x20error\x20during\x20export:','📊\x20[CHATGPT_EXTRACTOR]\x20Backend\x20response:','❌\x20[CHATGPT_EXTRACTOR]\x20Memories\x20storage\x20failed:','⚠️\x20[CHATGPT_EXTRACTOR]\x20No\x20memories\x20data\x20provided','ℹ️\x20[CHATGPT_EXTRACTOR]\x20No\x20memories\x20to\x20store\x20-\x20treating\x20as\x20success','📡\x20[CHATGPT_EXTRACTOR]\x20Sending\x20memories\x20to\x20backend...','UxGjg','JPGyW','❌\x20[CHATGPT_EXTRACTOR]\x20Unexpected\x20error\x20storing\x20memories:','yBiyq','aWYQZ','JYODp','log','🚀\x20[CHATGPT_EXTRACTOR]\x20Initiating\x20conversation\x20export','XCKxZ','hxeeP','length','error','MuFFY','Alert','alert','VWAtm','RhgoU','kSkxE','ZYyNS','Export\x20Error','rDgyf','oxTic','filter','BSScN','DMOKJ','conversation_id','title','isArray','user_messages','warn','AfeWo','KegtK','gQxwC','oIqIt','⚠️\x20[CHATGPT_EXTRACTOR]\x20Filtered\x20out\x20','zHiNv','SNuWx','oivkx','zMRGB','IqhnH','storeChatGPTConversations','success','ldOlI','data','hlXKl','txqEw','❌\x20[CHATGPT_EXTRACTOR]\x20Backend\x20storage\x20failed:','bAdAB','An\x20unknown\x20error\x20occurred\x20during\x20conversation\x20storage.','CvBtd','📋\x20[CHATGPT_EXTRACTOR]\x20Backend\x20stored\x20','\x20memories','LLqKY','ccKIh','DGpKp','vdXJd','DqwVL','🧠\x20[CHATGPT_EXTRACTOR]\x20Storing\x20ChatGPT\x20memories...','fTxQd','huEYJ','ePTZx','kEGCX','memories','📋\x20[CHATGPT_EXTRACTOR]\x20Found\x20','\x20memory\x20items,\x20','coTvT','WHHrB','DDodR','UkMrk','ONCdz','✅\x20[CHATGPT_EXTRACTOR]\x20Memories\x20stored\x20successfully','memoriesCount','HmghN'];_0x286e=function(){return _0x70a81d;};return _0x286e();}var _chatGPTConversationService=__ONAIROS_REQ_FUNC__(0x0),_reactNative=__ONAIROS_REQ_FUNC__(0x1);const useChatGPTConversationExtractor=()=>{const _0x21e175={'vdXJd':'Failed\x20to\x20connect\x20to\x20the\x20conversation\x20storage\x20service.\x20Please\x20check\x20your\x20network\x20connection.','rDgyf':_0x11ab(0x3),'CvBtd':function(_0x232f72,_0x242a04){return _0x232f72-_0x242a04;},'vTMZz':function(_0xf169aa,_0x5a9780){return _0xf169aa>_0x5a9780;},'JYODp':_0x11ab(0x4),'yBiyq':_0x11ab(0x5),'aWYQZ':'FBWKz','XCKxZ':_0x11ab(0x6),'hxeeP':_0x11ab(0x7),'MuFFY':_0x11ab(0x8),'VWAtm':'Error','UpXys':_0x11ab(0x9),'RhgoU':function(_0x3ecfd4,_0x4cc29e){return _0x3ecfd4===_0x4cc29e;},'kSkxE':_0x11ab(0xa),'ZYyNS':_0x11ab(0xb),'oxTic':_0x11ab(0xc),'oIqIt':_0x11ab(0xd),'SAFfN':_0x11ab(0xe),'RYPUi':function(_0x170119,_0x44ec7f){return _0x170119<_0x44ec7f;},'zHiNv':function(_0x255922,_0x4c033d){return _0x255922-_0x4c033d;},'SNuWx':function(_0x11e4fd,_0x35df3d){return _0x11e4fd!==_0x35df3d;},'oivkx':_0x11ab(0xf),'IqhnH':_0x11ab(0x10),'ldOlI':'✅\x20[CHATGPT_EXTRACTOR]\x20Export\x20completed\x20successfully','hlXKl':_0x11ab(0x11),'txqEw':_0x11ab(0x12),'bAdAB':_0x11ab(0x13),'LLqKY':_0x11ab(0x14),'ccKIh':_0x11ab(0x15),'DGpKp':_0x11ab(0x16),'VIBOx':_0x11ab(0x17),'DqwVL':_0x11ab(0x18),'fTxQd':_0x11ab(0x19),'ZSlQZ':function(_0x30b186,_0x1b9ccc){return _0x30b186===_0x1b9ccc;},'huEYJ':function(_0xf670fb,_0x2b1046){return _0xf670fb===_0x2b1046;},'ePTZx':function(_0x36d537,_0x355f7e){return _0x36d537===_0x355f7e;},'wkUuR':function(_0x119b87,_0x44e68f){return _0x119b87===_0x44e68f;},'kEGCX':function(_0x4c39f6,_0xf320ef){return _0x4c39f6===_0xf320ef;},'qxoHZ':function(_0x41ad54,_0x4766db){return _0x41ad54===_0x4766db;},'coTvT':_0x11ab(0x1a),'WHHrB':_0x11ab(0x1b),'UkMrk':_0x11ab(0x1c),'HmghN':_0x11ab(0x1d),'SrGqw':_0x11ab(0x1e)},_0x27fe07=async(_0x5d7b23,_0x2269c8)=>{const _0x41c1da={'BSScN':_0x21e175[_0x11ab(0x1f)],'DMOKJ':_0x21e175[_0x11ab(0x20)],'AfeWo':_0x21e175[_0x11ab(0x21)]};console[_0x11ab(0x22)](_0x11ab(0x23)),console[_0x11ab(0x22)](_0x21e175[_0x11ab(0x24)],_0x5d7b23),console[_0x11ab(0x22)](_0x21e175[_0x11ab(0x25)],_0x2269c8[_0x11ab(0x26)]);if(!_0x5d7b23)return console[_0x11ab(0x27)](_0x21e175[_0x11ab(0x28)]),_reactNative[_0x11ab(0x29)][_0x11ab(0x2a)](_0x21e175[_0x11ab(0x2b)],_0x21e175['UpXys'],[{'text':'OK','style':_0x21e175['rDgyf']}]),![];if(!_0x2269c8||_0x2269c8['length']===0x0)return _0x21e175[_0x11ab(0x2c)](_0x21e175[_0x11ab(0x2d)],_0x21e175[_0x11ab(0x2e)])?(_0x1fd2e9[_0x11ab(0x27)](_0x11ab(0x16),_0x36ce1c),_0x1093cf[_0x11ab(0x29)][_0x11ab(0x2a)](_0x11ab(0x2f),_0x21e175['vdXJd'],[{'text':'OK','style':_0x21e175[_0x11ab(0x30)]}]),![]):(console['log'](_0x21e175[_0x11ab(0x31)]),!![]);const _0x8a0e46=_0x2269c8[_0x11ab(0x32)](_0x4a87a5=>{const _0xc103c1={'KegtK':_0x41c1da[_0x11ab(0x33)],'gQxwC':_0x11ab(0x3)};if('FBWKz'===_0x41c1da[_0x11ab(0x34)]){const _0x5d74ee=_0x4a87a5[_0x11ab(0x35)]&&_0x4a87a5[_0x11ab(0x36)]&&Array[_0x11ab(0x37)](_0x4a87a5[_0x11ab(0x38)])&&_0x4a87a5['user_messages'][_0x11ab(0x26)]>0x0;return!_0x5d74ee&&console[_0x11ab(0x39)](_0x41c1da[_0x11ab(0x3a)],_0x4a87a5),_0x5d74ee;}else return _0x485189['error'](_0xc103c1[_0x11ab(0x3b)]),_0x1221f4[_0x11ab(0x29)][_0x11ab(0x2a)]('Data\x20Error','No\x20valid\x20conversations\x20found\x20to\x20export.',[{'text':'OK','style':_0xc103c1[_0x11ab(0x3c)]}]),![];});if(_0x21e175['RhgoU'](_0x8a0e46['length'],0x0))return console['error'](_0x21e175[_0x11ab(0x1f)]),_reactNative[_0x11ab(0x29)][_0x11ab(0x2a)](_0x21e175[_0x11ab(0x3d)],_0x21e175['SAFfN'],[{'text':'OK','style':'default'}]),![];_0x21e175['RYPUi'](_0x8a0e46[_0x11ab(0x26)],_0x2269c8['length'])&&console[_0x11ab(0x39)](_0x11ab(0x3e)+_0x21e175[_0x11ab(0x3f)](_0x2269c8[_0x11ab(0x26)],_0x8a0e46[_0x11ab(0x26)])+'\x20invalid\x20conversations');try{if(_0x21e175[_0x11ab(0x40)](_0x21e175[_0x11ab(0x41)],_0x11ab(0x42))){console[_0x11ab(0x22)](_0x21e175[_0x11ab(0x43)]);const _0x4c861d=await(0x0,_chatGPTConversationService[_0x11ab(0x44)])(_0x5d7b23,_0x8a0e46);if(_0x4c861d[_0x11ab(0x45)])return console['log'](_0x21e175[_0x11ab(0x46)]),console[_0x11ab(0x22)]('📊\x20[CHATGPT_EXTRACTOR]\x20Backend\x20response:',_0x4c861d[_0x11ab(0x47)]),!![];else{if(_0x21e175[_0x11ab(0x48)]!==_0x21e175[_0x11ab(0x49)])return console[_0x11ab(0x27)](_0x11ab(0x4a),_0x4c861d[_0x11ab(0x27)]),_reactNative[_0x11ab(0x29)]['alert'](_0x21e175[_0x11ab(0x4b)],_0x4c861d['error']||_0x11ab(0x4c),[{'text':'OK','style':_0x21e175['rDgyf']}]),![];else _0x3c2165[_0x11ab(0x39)](_0x11ab(0x3e)+_0x21e175[_0x11ab(0x4d)](_0x2e7da9[_0x11ab(0x26)],_0x2a3065[_0x11ab(0x26)])+'\x20invalid\x20conversations');}}else _0x10a32c[_0x11ab(0x22)](_0x11ab(0x4e)+_0x221d98['data']['memoriesCount']+_0x11ab(0x4f));}catch(_0x377e4e){if(_0x21e175['SNuWx'](_0x21e175[_0x11ab(0x50)],_0x21e175[_0x11ab(0x51)]))return console[_0x11ab(0x27)](_0x21e175[_0x11ab(0x52)],_0x377e4e),_reactNative[_0x11ab(0x29)][_0x11ab(0x2a)]('Export\x20Error',_0x21e175[_0x11ab(0x53)],[{'text':'OK','style':_0x21e175[_0x11ab(0x30)]}]),![];else{const _0x355d06=_0x3fd3e0[_0x11ab(0x35)]&&_0x4e7e26[_0x11ab(0x36)]&&_0x987a99['isArray'](_0x2f396a[_0x11ab(0x38)])&&_0x21e175['vTMZz'](_0x361717['user_messages']['length'],0x0);return!_0x355d06&&_0x3965a8[_0x11ab(0x39)](_0x21e175[_0x11ab(0x21)],_0x4f346e),_0x355d06;}}},_0x1152ee=async _0x8fe9fb=>{const _0x416cf4={'ONCdz':_0x21e175[_0x11ab(0x54)]};var _0x535f3d,_0x1f516e,_0x112b13;console[_0x11ab(0x22)](_0x11ab(0x55));if(!_0x8fe9fb)return console[_0x11ab(0x39)](_0x21e175[_0x11ab(0x56)]),![];const _0x320084=(_0x21e175['RhgoU'](_0x8fe9fb,null)||_0x21e175['ZSlQZ'](_0x8fe9fb,void 0x0)||_0x21e175[_0x11ab(0x57)](_0x535f3d=_0x8fe9fb['items'],null)||_0x535f3d===void 0x0?void 0x0:_0x535f3d['length'])||0x0,_0x4f116d=(_0x21e175[_0x11ab(0x58)](_0x8fe9fb,null)||_0x21e175['wkUuR'](_0x8fe9fb,void 0x0)||_0x21e175[_0x11ab(0x59)](_0x1f516e=_0x8fe9fb['memory_entries'],null)||_0x1f516e===void 0x0?void 0x0:_0x1f516e['length'])||0x0,_0x756f24=(_0x8fe9fb===null||_0x21e175[_0x11ab(0x2c)](_0x8fe9fb,void 0x0)||_0x21e175['qxoHZ'](_0x112b13=_0x8fe9fb[_0x11ab(0x5a)],null)||_0x112b13===void 0x0?void 0x0:_0x112b13[_0x11ab(0x26)])||0x0;console[_0x11ab(0x22)](_0x11ab(0x5b)+_0x320084+_0x11ab(0x5c)+_0x4f116d+'\x20memory\x20entries,\x20'+_0x756f24+_0x11ab(0x4f));if(_0x320084===0x0&&_0x21e175[_0x11ab(0x2c)](_0x4f116d,0x0)&&_0x756f24===0x0)return console['log'](_0x21e175[_0x11ab(0x5d)]),!![];try{console['log'](_0x21e175[_0x11ab(0x5e)]);const _0x33537e=await(0x0,_chatGPTConversationService['storeChatGPTMemories'])(_0x8fe9fb);if(_0x33537e[_0x11ab(0x45)]){if(_0x21e175['RhgoU'](_0x11ab(0x5f),_0x21e175[_0x11ab(0x60)]))return _0x2cba13[_0x11ab(0x27)](_0x416cf4[_0x11ab(0x61)],_0x5b3133['error']),![];else{var _0x3ed255;return console[_0x11ab(0x22)](_0x11ab(0x62)),(_0x3ed255=_0x33537e[_0x11ab(0x47)])!==null&&_0x3ed255!==void 0x0&&_0x3ed255[_0x11ab(0x63)]&&console['log'](_0x11ab(0x4e)+_0x33537e['data'][_0x11ab(0x63)]+_0x11ab(0x4f)),!![];}}else return console[_0x11ab(0x27)](_0x21e175[_0x11ab(0x54)],_0x33537e[_0x11ab(0x27)]),![];}catch(_0x3f9e92){return _0x21e175['SNuWx'](_0x21e175[_0x11ab(0x64)],_0x21e175[_0x11ab(0x64)])?(_0x3f4ef4['log'](_0x21e175[_0x11ab(0x46)]),_0x4708a2[_0x11ab(0x22)](_0x21e175['VIBOx'],_0x208b0d[_0x11ab(0x47)]),!![]):(console[_0x11ab(0x27)](_0x21e175['SrGqw'],_0x3f9e92),![]);}};return{'initiateConversationExport':_0x27fe07,'storeMemories':_0x1152ee};};function _0x11ab(_0x286e85,_0x11ab33){_0x286e85=_0x286e85-0x0;const _0x3c13fa=_0x286e();let _0x21666d=_0x3c13fa[_0x286e85];return _0x21666d;}exports[_0x11ab(0x2)]=useChatGPTConversationExtractor;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useChatGPTConversationExtractor = void 0;
|
|
7
|
+
var _chatGPTConversationService = require("./chatGPTConversationService");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
/**
|
|
10
|
+
* ChatGPT Conversation Extractor
|
|
11
|
+
*
|
|
12
|
+
* Orchestrates the ChatGPT conversation export flow:
|
|
13
|
+
* 1. Receives extracted conversations from WebView
|
|
14
|
+
* 2. Validates and formats data
|
|
15
|
+
* 3. Sends to backend via chatGPTConversationService
|
|
16
|
+
* 4. Also handles ChatGPT memories export
|
|
17
|
+
*
|
|
18
|
+
* This acts as the bridge between OAuthWebView and the backend API.
|
|
19
|
+
*
|
|
20
|
+
* @reference iOS implementation: onairos-flutter/ios/Classes/OnairosChatGPTConnectorPlugin.swift
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Hook for ChatGPT conversation extraction operations
|
|
25
|
+
*/
|
|
26
|
+
const useChatGPTConversationExtractor = () => {
|
|
27
|
+
/**
|
|
28
|
+
* Initiate conversation export to backend
|
|
29
|
+
*
|
|
30
|
+
* @param username - User identifier
|
|
31
|
+
* @param conversations - Array of conversations with user messages
|
|
32
|
+
* @returns true if successful, false otherwise
|
|
33
|
+
*/
|
|
34
|
+
const initiateConversationExport = async (username, conversations) => {
|
|
35
|
+
console.log('🚀 [CHATGPT_EXTRACTOR] Initiating conversation export');
|
|
36
|
+
console.log('👤 [CHATGPT_EXTRACTOR] Username:', username);
|
|
37
|
+
console.log('📊 [CHATGPT_EXTRACTOR] Conversations to send:', conversations.length);
|
|
38
|
+
|
|
39
|
+
// Validation
|
|
40
|
+
if (!username) {
|
|
41
|
+
console.error('❌ [CHATGPT_EXTRACTOR] Username is required');
|
|
42
|
+
_reactNative.Alert.alert('Error', 'Username is required to export ChatGPT conversations.', [{
|
|
43
|
+
text: 'OK',
|
|
44
|
+
style: 'default'
|
|
45
|
+
}]);
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Handle 0 conversations as success - user might be new or have cleared history
|
|
50
|
+
// This matches iOS behavior where empty conversations still counts as successful connection
|
|
51
|
+
if (!conversations || conversations.length === 0) {
|
|
52
|
+
console.log('ℹ️ [CHATGPT_EXTRACTOR] No conversations to export - treating as success (connected)');
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Validate conversation structure
|
|
57
|
+
const validConversations = conversations.filter(conv => {
|
|
58
|
+
const isValid = conv.conversation_id && conv.title && Array.isArray(conv.user_messages) && conv.user_messages.length > 0;
|
|
59
|
+
if (!isValid) {
|
|
60
|
+
console.warn('⚠️ [CHATGPT_EXTRACTOR] Invalid conversation:', conv);
|
|
61
|
+
}
|
|
62
|
+
return isValid;
|
|
63
|
+
});
|
|
64
|
+
if (validConversations.length === 0) {
|
|
65
|
+
console.error('❌ [CHATGPT_EXTRACTOR] No valid conversations after filtering');
|
|
66
|
+
_reactNative.Alert.alert('Data Error', 'No valid conversations found to export.', [{
|
|
67
|
+
text: 'OK',
|
|
68
|
+
style: 'default'
|
|
69
|
+
}]);
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
if (validConversations.length < conversations.length) {
|
|
73
|
+
console.warn(`⚠️ [CHATGPT_EXTRACTOR] Filtered out ${conversations.length - validConversations.length} invalid conversations`);
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
console.log('📡 [CHATGPT_EXTRACTOR] Sending to backend...');
|
|
77
|
+
const result = await (0, _chatGPTConversationService.storeChatGPTConversations)(username, validConversations);
|
|
78
|
+
if (result.success) {
|
|
79
|
+
console.log('✅ [CHATGPT_EXTRACTOR] Export completed successfully');
|
|
80
|
+
console.log('📊 [CHATGPT_EXTRACTOR] Backend response:', result.data);
|
|
81
|
+
return true;
|
|
82
|
+
} else {
|
|
83
|
+
console.error('❌ [CHATGPT_EXTRACTOR] Backend storage failed:', result.error);
|
|
84
|
+
_reactNative.Alert.alert('Export Failed', result.error || 'An unknown error occurred during conversation storage.', [{
|
|
85
|
+
text: 'OK',
|
|
86
|
+
style: 'default'
|
|
87
|
+
}]);
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error('❌ [CHATGPT_EXTRACTOR] Unexpected error during export:', error);
|
|
92
|
+
_reactNative.Alert.alert('Export Error', 'Failed to connect to the conversation storage service. Please check your network connection.', [{
|
|
93
|
+
text: 'OK',
|
|
94
|
+
style: 'default'
|
|
95
|
+
}]);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Store ChatGPT memories on backend
|
|
102
|
+
* MATCHES iOS: OnairosChatGPTConnectorPlugin.swift saveMemories() + sendMemoriesToBackend()
|
|
103
|
+
*
|
|
104
|
+
* @param memoriesData - Raw ChatGPT memories JSON from WebView
|
|
105
|
+
* @returns true if successful, false otherwise
|
|
106
|
+
*/
|
|
107
|
+
const storeMemories = async memoriesData => {
|
|
108
|
+
var _memoriesData$items, _memoriesData$memory_, _memoriesData$memorie;
|
|
109
|
+
console.log('🧠 [CHATGPT_EXTRACTOR] Storing ChatGPT memories...');
|
|
110
|
+
|
|
111
|
+
// Validation
|
|
112
|
+
if (!memoriesData) {
|
|
113
|
+
console.warn('⚠️ [CHATGPT_EXTRACTOR] No memories data provided');
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Count items (matches iOS logging)
|
|
118
|
+
const itemsCount = (memoriesData === null || memoriesData === void 0 || (_memoriesData$items = memoriesData.items) === null || _memoriesData$items === void 0 ? void 0 : _memoriesData$items.length) || 0;
|
|
119
|
+
const entriesCount = (memoriesData === null || memoriesData === void 0 || (_memoriesData$memory_ = memoriesData.memory_entries) === null || _memoriesData$memory_ === void 0 ? void 0 : _memoriesData$memory_.length) || 0;
|
|
120
|
+
const memoriesCount = (memoriesData === null || memoriesData === void 0 || (_memoriesData$memorie = memoriesData.memories) === null || _memoriesData$memorie === void 0 ? void 0 : _memoriesData$memorie.length) || 0;
|
|
121
|
+
console.log(`📋 [CHATGPT_EXTRACTOR] Found ${itemsCount} memory items, ${entriesCount} memory entries, ${memoriesCount} memories`);
|
|
122
|
+
|
|
123
|
+
// If no memories, still treat as success (user might not have any memories)
|
|
124
|
+
if (itemsCount === 0 && entriesCount === 0 && memoriesCount === 0) {
|
|
125
|
+
console.log('ℹ️ [CHATGPT_EXTRACTOR] No memories to store - treating as success');
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
console.log('📡 [CHATGPT_EXTRACTOR] Sending memories to backend...');
|
|
130
|
+
const result = await (0, _chatGPTConversationService.storeChatGPTMemories)(memoriesData);
|
|
131
|
+
if (result.success) {
|
|
132
|
+
var _result$data;
|
|
133
|
+
console.log('✅ [CHATGPT_EXTRACTOR] Memories stored successfully');
|
|
134
|
+
if ((_result$data = result.data) !== null && _result$data !== void 0 && _result$data.memoriesCount) {
|
|
135
|
+
console.log(`📋 [CHATGPT_EXTRACTOR] Backend stored ${result.data.memoriesCount} memories`);
|
|
136
|
+
}
|
|
137
|
+
return true;
|
|
138
|
+
} else {
|
|
139
|
+
console.error('❌ [CHATGPT_EXTRACTOR] Memories storage failed:', result.error);
|
|
140
|
+
// Don't show alert for memories failure - it's secondary data
|
|
141
|
+
// The main conversation export is what matters
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
} catch (error) {
|
|
145
|
+
console.error('❌ [CHATGPT_EXTRACTOR] Unexpected error storing memories:', error);
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
return {
|
|
150
|
+
initiateConversationExport,
|
|
151
|
+
storeMemories
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
exports.useChatGPTConversationExtractor = useChatGPTConversationExtractor;
|
|
155
|
+
//# sourceMappingURL=chatGPTConversationExtractor.js.map
|
|
@@ -1,9 +1,275 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function _0x4812(){const _0xe2db40=['storeChatGPTMemories','Unknown\x20error','❌\x20[CHATGPT_SERVICE]\x20Memories\x20network\x20error:','Network\x20error.\x20Please\x20check\x20your\x20connection.','🚀\x20[CHATGPT_SERVICE]\x20Storing\x20ChatGPT\x20conversations\x20for:','Invalid\x20input:\x20userId\x20or\x20conversations\x20missing.','onairos_jwt_token','Authentication\x20token\x20not\x20found.\x20Please\x20log\x20in\x20again.','1.0.0','ios','mobile-chatgpt','conversation','HWVfq','WvLzm','❌\x20[CHATGPT_SERVICE]\x20Network\x20error:','nywXZ','📊\x20[CHATGPT_SERVICE]\x20Number\x20of\x20conversations:','log','reduce','length','wlmxN','LDaLP','Agxez','default','BOCnS','enoch_token','getItem','lnbiv','WlFnB','EtOGr','Platform','Kzuuh','BkCfL','17.0','Android','nszOT','now','user_messages','map','conversation_id','-msg-','toISOString','title','floor','ucpdT','bGuGr','📡\x20[CHATGPT_SERVICE]\x20Sending\x20conversation\x20','jMOGl','rXWBT','API_CONFIG','BASE_URL','/llm-data/store','Bearer\x20','OnairosSDK/1.0.0\x20(','json','✅\x20[CHATGPT_SERVICE]\x20Sent\x20conversation\x20','QJlYU','⚠️\x20[CHATGPT_SERVICE]\x20Failed\x20conversation\x20','OSWFY','error','status','warn','⚠️\x20[CHATGPT_SERVICE]\x20Network\x20error\x20for\x20conversation\x20','SDDOJ','XaAsl','⚠️\x20[CHATGPT_SERVICE]\x20Memories\x20backend\x20returned\x20status:\x20','⚠️\x20[CHATGPT_SERVICE]\x20Error:\x20','uddLM','HTTP\x20','📊\x20[CHATGPT_SERVICE]\x20Complete:\x20','\x20success,\x20','ZuAgT','Hzrcr','KnIfP','lUIYF','Stored\x20','\x20of\x20','\x20conversations','message','PLQeY','\x20errors)','🧠\x20[CHATGPT_SERVICE]\x20Storing\x20ChatGPT\x20memories...','auth_token','❌\x20[CHATGPT_SERVICE]\x20No\x20auth\x20token\x20found\x20in\x20any\x20storage\x20key','🔑\x20[CHATGPT_SERVICE]\x20Auth\x20token\x20found\x20for\x20memories','fEOMD','zyvvA','LrtaC','UPfwc','UmDeH','PiSQz','items','memory_entries','LjGrV','yRVEh','\x20items,\x20','\x20entries,\x20','\x20memories\x20(total:\x20','BlaSI','Invalid\x20input:\x20memoriesData\x20missing.','iGwRi','HgtTF','HhSRI','keys','LaTnX','📡\x20[CHATGPT_SERVICE]\x20Sending\x20memories\x20to\x20backend...','📦\x20[CHATGPT_SERVICE]\x20Raw\x20memoriesData\x20keys:\x20','join','📦\x20[CHATGPT_SERVICE]\x20Raw\x20response\x20sent\x20as-is\x20(no\x20transformation)','/llm-data/store-memories','stringify','MVYbw','fVItD','✅\x20[CHATGPT_SERVICE]\x20Successfully\x20sent\x20memories\x20to\x20backend','📝\x20[CHATGPT_SERVICE]\x20Backend\x20response:\x20','ZsOft','memoriesCount','📋\x20[CHATGPT_SERVICE]\x20Stored\x20','data','KRryI','GbTMd','jSiSo','ggKWz','AhdAC'];_0x4812=function(){return _0xe2db40;};return _0x4812();}Object['defineProperty'](exports,'__esModule',{'value':!![]}),exports[_0x2f1d(0x0)]=exports['storeChatGPTConversations']=void 0x0;var _api=__ONAIROS_REQ_FUNC__(0x0),_asyncStorage=_interopRequireDefault(__ONAIROS_REQ_FUNC__(0x1)),_reactNative=__ONAIROS_REQ_FUNC__(0x2);function _interopRequireDefault(_0x12100c){return _0x12100c&&_0x12100c['__esModule']?_0x12100c:{'default':_0x12100c};}const storeChatGPTConversations=async(_0x362537,_0x4c555e)=>{const _0x5c3681={'jMOGl':function(_0x5a6135,_0x5c7111){return _0x5a6135+_0x5c7111;},'uddLM':_0x2f1d(0x1),'kQxhH':_0x2f1d(0x2),'PLQeY':_0x2f1d(0x3),'nywXZ':_0x2f1d(0x4),'qusMG':function(_0x5abc81,_0x7c1435){return _0x5abc81||_0x7c1435;},'wlmxN':function(_0x89236,_0x449b95){return _0x89236===_0x449b95;},'LDaLP':'❌\x20[CHATGPT_SERVICE]\x20Invalid\x20input','Agxez':_0x2f1d(0x5),'BOCnS':_0x2f1d(0x6),'Fzagc':'auth_token','lnbiv':'❌\x20[CHATGPT_SERVICE]\x20No\x20auth\x20token\x20found\x20in\x20any\x20storage\x20key','WlFnB':_0x2f1d(0x7),'EtOGr':'🔑\x20[CHATGPT_SERVICE]\x20Auth\x20token\x20found\x20for\x20conversations','Kzuuh':_0x2f1d(0x8),'BkCfL':_0x2f1d(0x9),'nszOT':function(_0x5c34f2,_0x1e375b){return _0x5c34f2<_0x1e375b;},'ucpdT':_0x2f1d(0xa),'bGuGr':_0x2f1d(0xb),'rXWBT':function(_0x344ab0,_0x585ace,_0x9b566e){return _0x344ab0(_0x585ace,_0x9b566e);},'Oaydv':function(_0x2ce4d5,_0x330302){return _0x2ce4d5+_0x330302;},'QJlYU':_0x2f1d(0xc),'OSWFY':function(_0x4cbfa7,_0x3d6857){return _0x4cbfa7+_0x3d6857;},'SDDOJ':function(_0x25b0a2,_0x522a6b){return _0x25b0a2-_0x522a6b;},'XaAsl':_0x2f1d(0xd),'ZuAgT':function(_0x1dceea,_0x374249){return _0x1dceea>_0x374249;},'Hzrcr':function(_0x540201,_0x7100a){return _0x540201===_0x7100a;},'KnIfP':'lUIYF','hmyqq':_0x2f1d(0xe)};console['log'](_0x5c3681[_0x2f1d(0xf)],_0x362537),console['log'](_0x2f1d(0x10),_0x4c555e['length']),console[_0x2f1d(0x11)]('📊\x20[CHATGPT_SERVICE]\x20Total\x20messages:',_0x4c555e[_0x2f1d(0x12)]((_0x3a48ce,_0x5842df)=>_0x3a48ce+_0x5842df['user_messages'][_0x2f1d(0x13)],0x0));if(_0x5c3681['qusMG'](!_0x362537,!_0x4c555e)||_0x5c3681[_0x2f1d(0x14)](_0x4c555e[_0x2f1d(0x13)],0x0))return console['error'](_0x5c3681[_0x2f1d(0x15)]),{'success':![],'error':_0x5c3681[_0x2f1d(0x16)]};try{const _0x59d913=await _asyncStorage[_0x2f1d(0x17)]['getItem'](_0x5c3681[_0x2f1d(0x18)])||await _asyncStorage['default']['getItem'](_0x2f1d(0x19))||await _asyncStorage[_0x2f1d(0x17)][_0x2f1d(0x1a)](_0x5c3681['Fzagc']);if(!_0x59d913)return console['error'](_0x5c3681[_0x2f1d(0x1b)]),{'success':![],'error':_0x5c3681[_0x2f1d(0x1c)]};console[_0x2f1d(0x11)](_0x5c3681[_0x2f1d(0x1d)]);const _0xa6febf={'platform':_reactNative[_0x2f1d(0x1e)]['OS'],'appVersion':_0x5c3681[_0x2f1d(0x1f)],'osVersion':_reactNative['Platform']['OS']===_0x5c3681[_0x2f1d(0x20)]?_0x2f1d(0x21):_reactNative[_0x2f1d(0x1e)]['OS'],'deviceModel':_0x5c3681['wlmxN'](_reactNative[_0x2f1d(0x1e)]['OS'],_0x2f1d(0x9))?'iPhone':_0x2f1d(0x22),'isOfflineSync':![]};let _0x285d1e=0x0,_0x5f0cb1=0x0;for(let _0x1c916d=0x0;_0x5c3681[_0x2f1d(0x23)](_0x1c916d,_0x4c555e[_0x2f1d(0x13)]);_0x1c916d++){const _0xf57fd6=_0x4c555e[_0x1c916d],_0x464dfd=Date[_0x2f1d(0x24)](),_0x196c20=_0xf57fd6[_0x2f1d(0x25)][_0x2f1d(0x26)]((_0x1f990d,_0x27c14d)=>({'id':_0xf57fd6[_0x2f1d(0x27)]+_0x2f1d(0x28)+_0x27c14d,'role':'user','content':_0x1f990d,'timestamp':new Date(_0x464dfd-(_0xf57fd6['user_messages'][_0x2f1d(0x13)]-_0x27c14d)*0x3e8)[_0x2f1d(0x29)](),'metadata':{}})),_0x361410={'conversationId':_0xf57fd6[_0x2f1d(0x27)],'messages':_0x196c20,'context':{'title':_0xf57fd6[_0x2f1d(0x2a)],'create_time':Math['floor'](_0x464dfd/0x3e8),'update_time':Math[_0x2f1d(0x2b)](_0x464dfd/0x3e8)},'mobileMetadata':_0xa6febf},_0x204763={'platform':_0x5c3681[_0x2f1d(0x2c)],'conversationData':_0x361410,'memoryType':_0x5c3681[_0x2f1d(0x2d)]};console['log'](_0x2f1d(0x2e)+_0x5c3681[_0x2f1d(0x2f)](_0x1c916d,0x1)+'/'+_0x4c555e['length']+':\x20'+_0xf57fd6['title']);try{const _0x3be384=await _0x5c3681[_0x2f1d(0x30)](fetch,_api[_0x2f1d(0x31)][_0x2f1d(0x32)]+_0x2f1d(0x33),{'method':'POST','headers':{'Content-Type':'application/json','Authorization':_0x2f1d(0x34)+_0x59d913,'User-Agent':_0x2f1d(0x35)+_reactNative['Platform']['OS']+')'},'body':JSON['stringify'](_0x204763)}),_0x265d79=await _0x3be384[_0x2f1d(0x36)]();_0x3be384['ok']?(console[_0x2f1d(0x11)](_0x2f1d(0x37)+_0x5c3681['Oaydv'](_0x1c916d,0x1)+'/'+_0x4c555e[_0x2f1d(0x13)]),_0x285d1e++):_0x5c3681[_0x2f1d(0x14)](_0x5c3681[_0x2f1d(0x38)],_0x5c3681[_0x2f1d(0x38)])?(console['warn'](_0x2f1d(0x39)+_0x5c3681[_0x2f1d(0x3a)](_0x1c916d,0x1)+'/'+_0x4c555e[_0x2f1d(0x13)]+':',_0x265d79[_0x2f1d(0x3b)]||_0x3be384[_0x2f1d(0x3c)]),_0x5f0cb1++):(_0x5a30ad[_0x2f1d(0x3d)](_0x2f1d(0x39)+_0x5c3681[_0x2f1d(0x2f)](_0x233d07,0x1)+'/'+_0x5b5c36['length']+':',_0x362eb1['error']||_0x18bd4f[_0x2f1d(0x3c)]),_0x1e7083++);}catch(_0x2835ef){console[_0x2f1d(0x3d)](_0x2f1d(0x3e)+(_0x1c916d+0x1)+':',_0x2835ef),_0x5f0cb1++;}if(_0x1c916d<_0x5c3681[_0x2f1d(0x3f)](_0x4c555e[_0x2f1d(0x13)],0x1)){if(_0x5c3681[_0x2f1d(0x14)](_0x2f1d(0xd),_0x5c3681[_0x2f1d(0x40)]))await new Promise(_0x36d368=>setTimeout(_0x36d368,0x12c));else return _0x527574['warn'](_0x2f1d(0x41)+_0x33fc36['status']),_0x51eaf0[_0x2f1d(0x3d)](_0x2f1d(0x42)+(_0x425e7e[_0x2f1d(0x3b)]||_0x5c3681[_0x2f1d(0x43)])),{'success':![],'error':_0x368c6b[_0x2f1d(0x3b)]||_0x2f1d(0x44)+_0xa973fb[_0x2f1d(0x3c)]};}}return console[_0x2f1d(0x11)](_0x2f1d(0x45)+_0x285d1e+_0x2f1d(0x46)+_0x5f0cb1+'\x20failed'),_0x5c3681[_0x2f1d(0x47)](_0x285d1e,0x0)?_0x5c3681[_0x2f1d(0x48)](_0x5c3681[_0x2f1d(0x49)],_0x2f1d(0x4a))?{'success':!![],'message':_0x2f1d(0x4b)+_0x285d1e+_0x2f1d(0x4c)+_0x4c555e[_0x2f1d(0x13)]+_0x2f1d(0x4d)}:(_0x1226d9[_0x2f1d(0x3b)](_0x5c3681['kQxhH'],_0x11b083),{'success':![],'error':_0x11741c[_0x2f1d(0x4e)]||_0x5c3681[_0x2f1d(0x4f)]}):{'success':![],'error':'Failed\x20to\x20store\x20conversations\x20('+_0x5f0cb1+_0x2f1d(0x50)};}catch(_0x56fece){return console['error'](_0x5c3681['hmyqq'],_0x56fece),{'success':![],'error':_0x56fece[_0x2f1d(0x4e)]||_0x2f1d(0x3)};}};function _0x2f1d(_0x48121c,_0x2f1de7){_0x48121c=_0x48121c-0x0;const _0x1a9e01=_0x4812();let _0x30d503=_0x1a9e01[_0x48121c];return _0x30d503;}exports['storeChatGPTConversations']=storeChatGPTConversations;const storeChatGPTMemories=async _0x3d2f8f=>{const _0x4a5e1c={'GbTMd':_0x2f1d(0x3),'UPfwc':_0x2f1d(0x51),'UmDeH':function(_0x276ddf,_0xb4db26){return _0x276ddf===_0xb4db26;},'PiSQz':function(_0x1d49f7,_0x3b5ec9){return _0x1d49f7===_0x3b5ec9;},'CtxIE':function(_0x4abb60,_0x45e815){return _0x4abb60===_0x45e815;},'LjGrV':function(_0x20fb8d,_0x500989){return _0x20fb8d===_0x500989;},'yRVEh':function(_0x4c8479,_0x4639ae){return _0x4c8479+_0x4639ae;},'BlaSI':'❌\x20[CHATGPT_SERVICE]\x20Invalid\x20input:\x20memoriesData\x20missing','iGwRi':_0x2f1d(0x6),'HgtTF':_0x2f1d(0x52),'HhSRI':_0x2f1d(0x53),'cvxHH':_0x2f1d(0x54),'LaTnX':function(_0x1f9141,_0x3cd2e1){return _0x1f9141||_0x3cd2e1;},'MVYbw':function(_0x4cd967,_0x22d1ed){return _0x4cd967!==_0x22d1ed;},'FVvcu':_0x2f1d(0x55),'ZsOft':function(_0x306f2a,_0x5be3ed){return _0x306f2a!==_0x5be3ed;},'PpLPJ':'Memories\x20stored\x20successfully','KRryI':_0x2f1d(0x56),'jSiSo':_0x2f1d(0x1),'ggKWz':_0x2f1d(0x57),'AhdAC':'❌\x20[CHATGPT_SERVICE]\x20Memories\x20network\x20error:'};var _0x5a9017,_0x12b866,_0x5d3f7f;console['log'](_0x4a5e1c[_0x2f1d(0x58)]);const _0x387ceb=(_0x4a5e1c['UmDeH'](_0x3d2f8f,null)||_0x4a5e1c[_0x2f1d(0x59)](_0x3d2f8f,void 0x0)||_0x4a5e1c[_0x2f1d(0x5a)](_0x5a9017=_0x3d2f8f[_0x2f1d(0x5b)],null)||_0x4a5e1c[_0x2f1d(0x5a)](_0x5a9017,void 0x0)?void 0x0:_0x5a9017[_0x2f1d(0x13)])||0x0,_0x48b67d=(_0x4a5e1c[_0x2f1d(0x59)](_0x3d2f8f,null)||_0x4a5e1c['CtxIE'](_0x3d2f8f,void 0x0)||_0x4a5e1c['PiSQz'](_0x12b866=_0x3d2f8f[_0x2f1d(0x5c)],null)||_0x12b866===void 0x0?void 0x0:_0x12b866[_0x2f1d(0x13)])||0x0,_0x27d695=(_0x4a5e1c[_0x2f1d(0x5d)](_0x3d2f8f,null)||_0x3d2f8f===void 0x0||_0x4a5e1c[_0x2f1d(0x5a)](_0x5d3f7f=_0x3d2f8f['memories'],null)||_0x4a5e1c[_0x2f1d(0x5d)](_0x5d3f7f,void 0x0)?void 0x0:_0x5d3f7f[_0x2f1d(0x13)])||0x0,_0x1436a5=_0x4a5e1c[_0x2f1d(0x5e)](_0x387ceb+_0x48b67d,_0x27d695);console[_0x2f1d(0x11)]('📋\x20[CHATGPT_SERVICE]\x20Found\x20'+_0x387ceb+_0x2f1d(0x5f)+_0x48b67d+_0x2f1d(0x60)+_0x27d695+_0x2f1d(0x61)+_0x1436a5+')');if(!_0x3d2f8f)return console[_0x2f1d(0x3b)](_0x4a5e1c[_0x2f1d(0x62)]),{'success':![],'error':_0x2f1d(0x63)};try{const _0x3b7553=await _asyncStorage[_0x2f1d(0x17)][_0x2f1d(0x1a)](_0x4a5e1c[_0x2f1d(0x64)])||await _asyncStorage[_0x2f1d(0x17)][_0x2f1d(0x1a)]('enoch_token')||await _asyncStorage[_0x2f1d(0x17)][_0x2f1d(0x1a)](_0x4a5e1c[_0x2f1d(0x65)]);if(!_0x3b7553)return console['error'](_0x4a5e1c[_0x2f1d(0x66)]),{'success':![],'error':_0x2f1d(0x7)};console[_0x2f1d(0x11)](_0x4a5e1c['cvxHH']);const _0x479ed6=_0x2f1d(0x8),_0x3ecf46={'platform':_0x2f1d(0xa),'memoriesData':_0x3d2f8f,'metadata':{'source':'react-native-sdk','appVersion':_0x479ed6,'fetchedAt':new Date()[_0x2f1d(0x29)]()}},_0x4b6cb6=Object[_0x2f1d(0x67)](_0x4a5e1c[_0x2f1d(0x68)](_0x3d2f8f,{}));console[_0x2f1d(0x11)](_0x2f1d(0x69)),console['log']('📍\x20[CHATGPT_SERVICE]\x20URL:\x20'+_api['API_CONFIG']['BASE_URL']+'/llm-data/store-memories'),console[_0x2f1d(0x11)](_0x2f1d(0x6a)+_0x4b6cb6[_0x2f1d(0x6b)](',\x20')),console[_0x2f1d(0x11)](_0x2f1d(0x6c));const _0x2ceacd=await fetch(_api[_0x2f1d(0x31)][_0x2f1d(0x32)]+_0x2f1d(0x6d),{'method':'POST','headers':{'Content-Type':'application/json','Authorization':_0x2f1d(0x34)+_0x3b7553,'User-Agent':'OnairosSDK/'+_0x479ed6+'\x20('+_reactNative['Platform']['OS']+')'},'body':JSON[_0x2f1d(0x6e)](_0x3ecf46)}),_0x3ad255=await _0x2ceacd[_0x2f1d(0x36)]();if(_0x2ceacd['ok']){if(_0x4a5e1c[_0x2f1d(0x6f)](_0x2f1d(0x70),_0x4a5e1c['FVvcu'])){var _0x486dc9;return console['log'](_0x2f1d(0x71)),_0x3ad255[_0x2f1d(0x4e)]&&console[_0x2f1d(0x11)](_0x2f1d(0x72)+_0x3ad255[_0x2f1d(0x4e)]),(_0x486dc9=_0x3ad255['data'])!==null&&_0x4a5e1c[_0x2f1d(0x73)](_0x486dc9,void 0x0)&&_0x486dc9[_0x2f1d(0x74)]&&console[_0x2f1d(0x11)](_0x2f1d(0x75)+_0x3ad255[_0x2f1d(0x76)][_0x2f1d(0x74)]+'\x20memory\x20items\x20in\x20database'),{'success':!![],'message':_0x3ad255[_0x2f1d(0x4e)]||_0x4a5e1c['PpLPJ'],'data':_0x3ad255['data']};}else _0x4533cf[_0x2f1d(0x11)](_0x2f1d(0x72)+_0x49dd1b[_0x2f1d(0x4e)]);}else return _0x2f1d(0x56)!==_0x4a5e1c[_0x2f1d(0x77)]?(_0xf34adb['error'](_0x2f1d(0xe),_0x1279b4),{'success':![],'error':_0x3c7a07[_0x2f1d(0x4e)]||_0x4a5e1c[_0x2f1d(0x78)]}):(console[_0x2f1d(0x3d)](_0x2f1d(0x41)+_0x2ceacd[_0x2f1d(0x3c)]),console['warn'](_0x2f1d(0x42)+(_0x3ad255[_0x2f1d(0x3b)]||_0x4a5e1c[_0x2f1d(0x79)])),{'success':![],'error':_0x3ad255[_0x2f1d(0x3b)]||'HTTP\x20'+_0x2ceacd[_0x2f1d(0x3c)]});}catch(_0x3ae8c5){return _0x4a5e1c[_0x2f1d(0x73)](_0x4a5e1c[_0x2f1d(0x7a)],'QKcyX')?(console[_0x2f1d(0x3b)](_0x4a5e1c[_0x2f1d(0x7b)],_0x3ae8c5),{'success':![],'error':_0x3ae8c5['message']||_0x4a5e1c['GbTMd']}):{'success':![],'error':'Failed\x20to\x20store\x20conversations\x20('+_0x50f965+_0x2f1d(0x50)};}};exports['storeChatGPTMemories']=storeChatGPTMemories;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.storeChatGPTMemories = exports.storeChatGPTConversations = void 0;
|
|
7
|
+
var _api = require("../config/api");
|
|
8
|
+
var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
/**
|
|
12
|
+
* ChatGPT Conversation Service
|
|
13
|
+
*
|
|
14
|
+
* API layer for storing ChatGPT conversation data on backend.
|
|
15
|
+
* Sends extracted user messages to /llm-data/store endpoint.
|
|
16
|
+
* Also handles ChatGPT memories via /llm-data/store-memories endpoint.
|
|
17
|
+
*
|
|
18
|
+
* MATCHES iOS: onairos-flutter/ios/Classes/OnairosChatGPTConnectorPlugin.swift
|
|
19
|
+
* - Sends ONE request per conversation (not all at once)
|
|
20
|
+
* - Uses format: { conversationId, messages[], context }
|
|
21
|
+
* - Platform: "mobile-chatgpt"
|
|
22
|
+
* - Memories sent to /llm-data/store-memories
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Structure of conversation messages extracted from ChatGPT
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Response from backend /llm-data/store endpoint
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Store ChatGPT conversations on backend
|
|
35
|
+
* MATCHES iOS: Sends one request per conversation
|
|
36
|
+
*
|
|
37
|
+
* @param userId - Username or identifier
|
|
38
|
+
* @param conversations - Array of conversations with user messages
|
|
39
|
+
* @returns Response indicating success/failure with metadata
|
|
40
|
+
*/
|
|
41
|
+
const storeChatGPTConversations = async (userId, conversations) => {
|
|
42
|
+
console.log('🚀 [CHATGPT_SERVICE] Storing ChatGPT conversations for:', userId);
|
|
43
|
+
console.log('📊 [CHATGPT_SERVICE] Number of conversations:', conversations.length);
|
|
44
|
+
console.log('📊 [CHATGPT_SERVICE] Total messages:', conversations.reduce((sum, c) => sum + c.user_messages.length, 0));
|
|
45
|
+
|
|
46
|
+
// Input validation
|
|
47
|
+
if (!userId || !conversations || conversations.length === 0) {
|
|
48
|
+
console.error('❌ [CHATGPT_SERVICE] Invalid input');
|
|
49
|
+
return {
|
|
50
|
+
success: false,
|
|
51
|
+
error: 'Invalid input: userId or conversations missing.'
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
// Get auth token - check all possible storage keys (matches rest of codebase)
|
|
56
|
+
const authToken = (await _asyncStorage.default.getItem('onairos_jwt_token')) || (await _asyncStorage.default.getItem('enoch_token')) || (await _asyncStorage.default.getItem('auth_token'));
|
|
57
|
+
if (!authToken) {
|
|
58
|
+
console.error('❌ [CHATGPT_SERVICE] No auth token found in any storage key');
|
|
59
|
+
return {
|
|
60
|
+
success: false,
|
|
61
|
+
error: 'Authentication token not found. Please log in again.'
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
console.log('🔑 [CHATGPT_SERVICE] Auth token found for conversations');
|
|
65
|
+
|
|
66
|
+
// Mobile metadata (matches iOS mobileMetadata)
|
|
67
|
+
const mobileMetadata = {
|
|
68
|
+
platform: _reactNative.Platform.OS,
|
|
69
|
+
appVersion: '1.0.0',
|
|
70
|
+
osVersion: _reactNative.Platform.OS === 'ios' ? '17.0' : _reactNative.Platform.OS,
|
|
71
|
+
deviceModel: _reactNative.Platform.OS === 'ios' ? 'iPhone' : 'Android',
|
|
72
|
+
isOfflineSync: false
|
|
73
|
+
};
|
|
74
|
+
let successCount = 0;
|
|
75
|
+
let failCount = 0;
|
|
76
|
+
|
|
77
|
+
// MATCH iOS: Send ONE request per conversation
|
|
78
|
+
for (let i = 0; i < conversations.length; i++) {
|
|
79
|
+
const conv = conversations[i];
|
|
80
|
+
const now = Date.now();
|
|
81
|
+
|
|
82
|
+
// Build messages array matching iOS format
|
|
83
|
+
// iOS extracts: { id, role, content, timestamp, metadata }
|
|
84
|
+
const messages = conv.user_messages.map((content, msgIndex) => ({
|
|
85
|
+
id: `${conv.conversation_id}-msg-${msgIndex}`,
|
|
86
|
+
role: 'user',
|
|
87
|
+
content: content,
|
|
88
|
+
timestamp: new Date(now - (conv.user_messages.length - msgIndex) * 1000).toISOString(),
|
|
89
|
+
metadata: {}
|
|
90
|
+
}));
|
|
91
|
+
|
|
92
|
+
// Build conversationData matching iOS format exactly
|
|
93
|
+
// From AppDelegate.swift lines 1397-1405
|
|
94
|
+
const conversationData = {
|
|
95
|
+
conversationId: conv.conversation_id,
|
|
96
|
+
// iOS uses camelCase
|
|
97
|
+
messages: messages,
|
|
98
|
+
context: {
|
|
99
|
+
title: conv.title,
|
|
100
|
+
create_time: Math.floor(now / 1000),
|
|
101
|
+
update_time: Math.floor(now / 1000)
|
|
102
|
+
},
|
|
103
|
+
mobileMetadata: mobileMetadata
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// Request body matching iOS sendToBackend format
|
|
107
|
+
// From AppDelegate.swift lines 376-380
|
|
108
|
+
const requestBody = {
|
|
109
|
+
platform: 'mobile-chatgpt',
|
|
110
|
+
// iOS uses "mobile-chatgpt"
|
|
111
|
+
conversationData: conversationData,
|
|
112
|
+
memoryType: 'conversation'
|
|
113
|
+
};
|
|
114
|
+
console.log(`📡 [CHATGPT_SERVICE] Sending conversation ${i + 1}/${conversations.length}: ${conv.title}`);
|
|
115
|
+
try {
|
|
116
|
+
const response = await fetch(`${_api.API_CONFIG.BASE_URL}/llm-data/store`, {
|
|
117
|
+
method: 'POST',
|
|
118
|
+
headers: {
|
|
119
|
+
'Content-Type': 'application/json',
|
|
120
|
+
'Authorization': `Bearer ${authToken}`,
|
|
121
|
+
'User-Agent': `OnairosSDK/1.0.0 (${_reactNative.Platform.OS})`
|
|
122
|
+
},
|
|
123
|
+
body: JSON.stringify(requestBody)
|
|
124
|
+
});
|
|
125
|
+
const responseData = await response.json();
|
|
126
|
+
if (response.ok) {
|
|
127
|
+
console.log(`✅ [CHATGPT_SERVICE] Sent conversation ${i + 1}/${conversations.length}`);
|
|
128
|
+
successCount++;
|
|
129
|
+
} else {
|
|
130
|
+
console.warn(`⚠️ [CHATGPT_SERVICE] Failed conversation ${i + 1}/${conversations.length}:`, responseData.error || response.status);
|
|
131
|
+
failCount++;
|
|
132
|
+
}
|
|
133
|
+
} catch (convError) {
|
|
134
|
+
console.warn(`⚠️ [CHATGPT_SERVICE] Network error for conversation ${i + 1}:`, convError);
|
|
135
|
+
failCount++;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Small delay between requests (iOS uses 0.3s)
|
|
139
|
+
if (i < conversations.length - 1) {
|
|
140
|
+
await new Promise(resolve => setTimeout(resolve, 300));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
console.log(`📊 [CHATGPT_SERVICE] Complete: ${successCount} success, ${failCount} failed`);
|
|
144
|
+
if (successCount > 0) {
|
|
145
|
+
return {
|
|
146
|
+
success: true,
|
|
147
|
+
message: `Stored ${successCount} of ${conversations.length} conversations`
|
|
148
|
+
};
|
|
149
|
+
} else {
|
|
150
|
+
return {
|
|
151
|
+
success: false,
|
|
152
|
+
error: `Failed to store conversations (${failCount} errors)`
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.error('❌ [CHATGPT_SERVICE] Network error:', error);
|
|
157
|
+
return {
|
|
158
|
+
success: false,
|
|
159
|
+
error: error.message || 'Network error. Please check your connection.'
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* ChatGPT Memories Data structure (from ChatGPT API)
|
|
166
|
+
*/
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Response from backend /llm-data/store-memories endpoint
|
|
170
|
+
*/
|
|
171
|
+
exports.storeChatGPTConversations = storeChatGPTConversations;
|
|
172
|
+
/**
|
|
173
|
+
* Store ChatGPT memories on backend
|
|
174
|
+
* MATCHES iOS: OnairosChatGPTConnectorPlugin.swift sendMemoriesToBackend()
|
|
175
|
+
*
|
|
176
|
+
* @param memoriesData - Raw ChatGPT memories JSON
|
|
177
|
+
* @returns Response indicating success/failure with metadata
|
|
178
|
+
*/
|
|
179
|
+
const storeChatGPTMemories = async memoriesData => {
|
|
180
|
+
var _memoriesData$items, _memoriesData$memory_, _memoriesData$memorie;
|
|
181
|
+
console.log('🧠 [CHATGPT_SERVICE] Storing ChatGPT memories...');
|
|
182
|
+
|
|
183
|
+
// Count memory items for logging (matches iOS and WebView script)
|
|
184
|
+
const itemsCount = (memoriesData === null || memoriesData === void 0 || (_memoriesData$items = memoriesData.items) === null || _memoriesData$items === void 0 ? void 0 : _memoriesData$items.length) || 0;
|
|
185
|
+
const entriesCount = (memoriesData === null || memoriesData === void 0 || (_memoriesData$memory_ = memoriesData.memory_entries) === null || _memoriesData$memory_ === void 0 ? void 0 : _memoriesData$memory_.length) || 0;
|
|
186
|
+
const memoriesCount = (memoriesData === null || memoriesData === void 0 || (_memoriesData$memorie = memoriesData.memories) === null || _memoriesData$memorie === void 0 ? void 0 : _memoriesData$memorie.length) || 0;
|
|
187
|
+
const totalCount = itemsCount + entriesCount + memoriesCount;
|
|
188
|
+
console.log(`📋 [CHATGPT_SERVICE] Found ${itemsCount} items, ${entriesCount} entries, ${memoriesCount} memories (total: ${totalCount})`);
|
|
189
|
+
|
|
190
|
+
// Input validation
|
|
191
|
+
if (!memoriesData) {
|
|
192
|
+
console.error('❌ [CHATGPT_SERVICE] Invalid input: memoriesData missing');
|
|
193
|
+
return {
|
|
194
|
+
success: false,
|
|
195
|
+
error: 'Invalid input: memoriesData missing.'
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
// Get auth token - check all possible storage keys (matches rest of codebase)
|
|
200
|
+
const authToken = (await _asyncStorage.default.getItem('onairos_jwt_token')) || (await _asyncStorage.default.getItem('enoch_token')) || (await _asyncStorage.default.getItem('auth_token'));
|
|
201
|
+
if (!authToken) {
|
|
202
|
+
console.error('❌ [CHATGPT_SERVICE] No auth token found in any storage key');
|
|
203
|
+
return {
|
|
204
|
+
success: false,
|
|
205
|
+
error: 'Authentication token not found. Please log in again.'
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
console.log('🔑 [CHATGPT_SERVICE] Auth token found for memories');
|
|
209
|
+
|
|
210
|
+
// Get app version
|
|
211
|
+
const appVersion = '1.0.0';
|
|
212
|
+
|
|
213
|
+
// Build request body matching iOS format exactly
|
|
214
|
+
// From OnairosChatGPTConnectorPlugin.swift lines 486-494
|
|
215
|
+
// CRITICAL: Send raw ChatGPT API response as-is (no transformation)
|
|
216
|
+
// Backend expects: { platform, memoriesData: { items, memory_entries, ... }, metadata }
|
|
217
|
+
const requestBody = {
|
|
218
|
+
platform: 'mobile-chatgpt',
|
|
219
|
+
memoriesData: memoriesData,
|
|
220
|
+
// Raw ChatGPT API response - sent as-is
|
|
221
|
+
metadata: {
|
|
222
|
+
source: 'react-native-sdk',
|
|
223
|
+
appVersion: appVersion,
|
|
224
|
+
fetchedAt: new Date().toISOString()
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// Log the structure being sent (for debugging)
|
|
229
|
+
const memoriesDataKeys = Object.keys(memoriesData || {});
|
|
230
|
+
console.log(`📡 [CHATGPT_SERVICE] Sending memories to backend...`);
|
|
231
|
+
console.log(`📍 [CHATGPT_SERVICE] URL: ${_api.API_CONFIG.BASE_URL}/llm-data/store-memories`);
|
|
232
|
+
console.log(`📦 [CHATGPT_SERVICE] Raw memoriesData keys: ${memoriesDataKeys.join(', ')}`);
|
|
233
|
+
console.log(`📦 [CHATGPT_SERVICE] Raw response sent as-is (no transformation)`);
|
|
234
|
+
const response = await fetch(`${_api.API_CONFIG.BASE_URL}/llm-data/store-memories`, {
|
|
235
|
+
method: 'POST',
|
|
236
|
+
headers: {
|
|
237
|
+
'Content-Type': 'application/json',
|
|
238
|
+
'Authorization': `Bearer ${authToken}`,
|
|
239
|
+
'User-Agent': `OnairosSDK/${appVersion} (${_reactNative.Platform.OS})`
|
|
240
|
+
},
|
|
241
|
+
body: JSON.stringify(requestBody)
|
|
242
|
+
});
|
|
243
|
+
const responseData = await response.json();
|
|
244
|
+
if (response.ok) {
|
|
245
|
+
var _responseData$data;
|
|
246
|
+
console.log('✅ [CHATGPT_SERVICE] Successfully sent memories to backend');
|
|
247
|
+
if (responseData.message) {
|
|
248
|
+
console.log(`📝 [CHATGPT_SERVICE] Backend response: ${responseData.message}`);
|
|
249
|
+
}
|
|
250
|
+
if ((_responseData$data = responseData.data) !== null && _responseData$data !== void 0 && _responseData$data.memoriesCount) {
|
|
251
|
+
console.log(`📋 [CHATGPT_SERVICE] Stored ${responseData.data.memoriesCount} memory items in database`);
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
success: true,
|
|
255
|
+
message: responseData.message || 'Memories stored successfully',
|
|
256
|
+
data: responseData.data
|
|
257
|
+
};
|
|
258
|
+
} else {
|
|
259
|
+
console.warn(`⚠️ [CHATGPT_SERVICE] Memories backend returned status: ${response.status}`);
|
|
260
|
+
console.warn(`⚠️ [CHATGPT_SERVICE] Error: ${responseData.error || 'Unknown error'}`);
|
|
261
|
+
return {
|
|
262
|
+
success: false,
|
|
263
|
+
error: responseData.error || `HTTP ${response.status}`
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
} catch (error) {
|
|
267
|
+
console.error('❌ [CHATGPT_SERVICE] Memories network error:', error);
|
|
268
|
+
return {
|
|
269
|
+
success: false,
|
|
270
|
+
error: error.message || 'Network error. Please check your connection.'
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
exports.storeChatGPTMemories = storeChatGPTMemories;
|
|
275
|
+
//# sourceMappingURL=chatGPTConversationService.js.map
|
|
@@ -1,8 +1,103 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useClaudeConversationExtractor = void 0;
|
|
7
|
+
var _claudeConversationService = require("./claudeConversationService");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
/**
|
|
10
|
+
* Claude Conversation Extractor
|
|
11
|
+
*
|
|
12
|
+
* Orchestrates the Claude conversation export flow:
|
|
13
|
+
* 1. Receives extracted conversations from WebView
|
|
14
|
+
* 2. Validates and formats data
|
|
15
|
+
* 3. Sends to backend via claudeConversationService
|
|
16
|
+
*
|
|
17
|
+
* This acts as the bridge between OAuthWebView and the backend API.
|
|
18
|
+
*
|
|
19
|
+
* @reference Enoch implementation: src/services/claudeConversationExtractor.ts
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Hook for Claude conversation extraction operations
|
|
24
|
+
*/
|
|
25
|
+
const useClaudeConversationExtractor = () => {
|
|
26
|
+
/**
|
|
27
|
+
* Initiate conversation export to backend
|
|
28
|
+
*
|
|
29
|
+
* @param username - User identifier
|
|
30
|
+
* @param conversations - Array of conversations with user messages
|
|
31
|
+
* @returns true if successful, false otherwise
|
|
32
|
+
*/
|
|
33
|
+
const initiateConversationExport = async (username, conversations) => {
|
|
34
|
+
console.log('🚀 [CLAUDE_EXTRACTOR] Initiating conversation export');
|
|
35
|
+
console.log('👤 [CLAUDE_EXTRACTOR] Username:', username);
|
|
36
|
+
console.log('📊 [CLAUDE_EXTRACTOR] Conversations to send:', conversations.length);
|
|
37
|
+
|
|
38
|
+
// Validation
|
|
39
|
+
if (!username) {
|
|
40
|
+
console.error('❌ [CLAUDE_EXTRACTOR] Username is required');
|
|
41
|
+
_reactNative.Alert.alert('Error', 'Username is required to export Claude conversations.', [{
|
|
42
|
+
text: 'OK',
|
|
43
|
+
style: 'default'
|
|
44
|
+
}]);
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Handle 0 conversations as success - user might be new or have cleared history
|
|
49
|
+
// This matches iOS behavior where empty conversations still counts as successful connection
|
|
50
|
+
if (!conversations || conversations.length === 0) {
|
|
51
|
+
console.log('ℹ️ [CLAUDE_EXTRACTOR] No conversations to export - treating as success (connected)');
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Validate conversation structure
|
|
56
|
+
const validConversations = conversations.filter(conv => {
|
|
57
|
+
const isValid = conv.conversation_id && conv.title && Array.isArray(conv.user_messages) && conv.user_messages.length > 0;
|
|
58
|
+
if (!isValid) {
|
|
59
|
+
console.warn('⚠️ [CLAUDE_EXTRACTOR] Invalid conversation:', conv);
|
|
60
|
+
}
|
|
61
|
+
return isValid;
|
|
62
|
+
});
|
|
63
|
+
if (validConversations.length === 0) {
|
|
64
|
+
console.error('❌ [CLAUDE_EXTRACTOR] No valid conversations after filtering');
|
|
65
|
+
_reactNative.Alert.alert('Data Error', 'No valid conversations found to export.', [{
|
|
66
|
+
text: 'OK',
|
|
67
|
+
style: 'default'
|
|
68
|
+
}]);
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
if (validConversations.length < conversations.length) {
|
|
72
|
+
console.warn(`⚠️ [CLAUDE_EXTRACTOR] Filtered out ${conversations.length - validConversations.length} invalid conversations`);
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
console.log('📡 [CLAUDE_EXTRACTOR] Sending to backend...');
|
|
76
|
+
const result = await (0, _claudeConversationService.storeClaudeConversations)(username, validConversations);
|
|
77
|
+
if (result.success) {
|
|
78
|
+
console.log('✅ [CLAUDE_EXTRACTOR] Export completed successfully');
|
|
79
|
+
console.log('📊 [CLAUDE_EXTRACTOR] Backend response:', result.data);
|
|
80
|
+
return true;
|
|
81
|
+
} else {
|
|
82
|
+
console.error('❌ [CLAUDE_EXTRACTOR] Backend storage failed:', result.error);
|
|
83
|
+
_reactNative.Alert.alert('Export Failed', result.error || 'An unknown error occurred during conversation storage.', [{
|
|
84
|
+
text: 'OK',
|
|
85
|
+
style: 'default'
|
|
86
|
+
}]);
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
} catch (error) {
|
|
90
|
+
console.error('❌ [CLAUDE_EXTRACTOR] Unexpected error during export:', error);
|
|
91
|
+
_reactNative.Alert.alert('Export Error', 'Failed to connect to the conversation storage service. Please check your network connection.', [{
|
|
92
|
+
text: 'OK',
|
|
93
|
+
style: 'default'
|
|
94
|
+
}]);
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
initiateConversationExport
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
exports.useClaudeConversationExtractor = useClaudeConversationExtractor;
|
|
103
|
+
//# sourceMappingURL=claudeConversationExtractor.js.map
|