@onairos/react-native 3.7.2 → 3.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/lib/commonjs/api/index.js +219 -9
  2. package/lib/commonjs/components/BodyText.js +27 -9
  3. package/lib/commonjs/components/BrandMark.js +111 -10
  4. package/lib/commonjs/components/CodeInput.js +120 -9
  5. package/lib/commonjs/components/EmailInput.js +30 -8
  6. package/lib/commonjs/components/GoogleButton.js +56 -9
  7. package/lib/commonjs/components/HeadingGroup.js +43 -9
  8. package/lib/commonjs/components/LLMDataInputModal.js +664 -14
  9. package/lib/commonjs/components/ModalHeader.js +99 -9
  10. package/lib/commonjs/components/ModalSheet.js +47 -9
  11. package/lib/commonjs/components/Onairos.js +380 -14
  12. package/lib/commonjs/components/OnairosButton.js +313 -13
  13. package/lib/commonjs/components/OnairosSignInButton.js +130 -12
  14. package/lib/commonjs/components/Overlay.js +465 -13
  15. package/lib/commonjs/components/PersonaImage.js +137 -10
  16. package/lib/commonjs/components/PersonaLoadingScreen.js +318 -12
  17. package/lib/commonjs/components/PersonalizationConsentScreen.js +467 -13
  18. package/lib/commonjs/components/PinCreationScreen.js +403 -12
  19. package/lib/commonjs/components/PinInput.js +464 -9
  20. package/lib/commonjs/components/PlatformConnectorsStep.js +1311 -23
  21. package/lib/commonjs/components/PlatformList.js +137 -10
  22. package/lib/commonjs/components/PlatformToggle.js +180 -9
  23. package/lib/commonjs/components/PrimaryButton.js +180 -10
  24. package/lib/commonjs/components/SignInMatchAnimation.js +197 -9
  25. package/lib/commonjs/components/SignInStep.js +345 -12
  26. package/lib/commonjs/components/UniversalOnboarding.js +2780 -30
  27. package/lib/commonjs/components/VerificationStep.js +176 -11
  28. package/lib/commonjs/components/WelcomeScreen.js +461 -22
  29. package/lib/commonjs/components/icons/Basicproficon.js +37 -8
  30. package/lib/commonjs/components/icons/Basicprofile.js +21 -8
  31. package/lib/commonjs/components/icons/Checkbox.js +21 -8
  32. package/lib/commonjs/components/icons/Checkmark.js +27 -8
  33. package/lib/commonjs/components/icons/Contentanalysis.js +21 -8
  34. package/lib/commonjs/components/icons/Contenticon.js +39 -8
  35. package/lib/commonjs/components/icons/EnochE.js +41 -8
  36. package/lib/commonjs/components/icons/Personalityicon.js +30 -8
  37. package/lib/commonjs/components/icons/Personalityprofile.js +21 -8
  38. package/lib/commonjs/components/icons/Personalitytraits.js +21 -8
  39. package/lib/commonjs/components/icons/Userpreferences.js +21 -8
  40. package/lib/commonjs/components/icons/index.js +84 -17
  41. package/lib/commonjs/components/onboarding/OAuthWebView.js +1754 -18
  42. package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -10
  43. package/lib/commonjs/components/onboarding/PinInput.js +283 -10
  44. package/lib/commonjs/components/onboarding/PlatformConnector.js +249 -11
  45. package/lib/commonjs/config/PLATFORM_APIS.md +849 -0
  46. package/lib/commonjs/config/api.js +56 -7
  47. package/lib/commonjs/constants/index.js +120 -7
  48. package/lib/commonjs/context/AuthContext.js +345 -10
  49. package/lib/commonjs/hooks/useConnectedAccounts.js +111 -9
  50. package/lib/commonjs/hooks/useConnections.js +102 -8
  51. package/lib/commonjs/hooks/useCredentials.js +178 -10
  52. package/lib/commonjs/hooks/useUserConnections.js +148 -10
  53. package/lib/commonjs/index.js +439 -34
  54. package/lib/commonjs/services/apiClient.js +298 -8
  55. package/lib/commonjs/services/biometricPinService.js +180 -8
  56. package/lib/commonjs/services/chatGPTConversationExtractor.js +155 -8
  57. package/lib/commonjs/services/chatGPTConversationService.js +275 -9
  58. package/lib/commonjs/services/claudeConversationExtractor.js +103 -8
  59. package/lib/commonjs/services/claudeConversationService.js +158 -9
  60. package/lib/commonjs/services/connectedAccountsService.js +310 -10
  61. package/lib/commonjs/services/googleAuthService.js +252 -11
  62. package/lib/commonjs/services/hingeDataExtractor.js +105 -8
  63. package/lib/commonjs/services/hingeDataService.js +150 -9
  64. package/lib/commonjs/services/imageCompressionService.js +260 -7
  65. package/lib/commonjs/services/instagramDataExtractor.js +126 -8
  66. package/lib/commonjs/services/instagramDataService.js +163 -9
  67. package/lib/commonjs/services/jwtStorageService.js +276 -7
  68. package/lib/commonjs/services/linkedinDOMExtractor.js +245 -7
  69. package/lib/commonjs/services/linkedinProfileService.js +222 -9
  70. package/lib/commonjs/services/linkedinScrapingService.js +230 -8
  71. package/lib/commonjs/services/llmDataStorage.js +294 -8
  72. package/lib/commonjs/services/mobileTrainingService.js +186 -8
  73. package/lib/commonjs/services/netflixDataExtractor.js +120 -8
  74. package/lib/commonjs/services/netflixDataService.js +198 -9
  75. package/lib/commonjs/services/pinEncryptionService.js +84 -8
  76. package/lib/commonjs/services/pinStorageUtils.js +105 -7
  77. package/lib/commonjs/services/platformAuthService.js +1484 -12
  78. package/lib/commonjs/services/sephoraDataExtractor.js +140 -8
  79. package/lib/commonjs/services/sephoraDataService.js +200 -9
  80. package/lib/commonjs/services/spotifyDataExtractor.js +148 -8
  81. package/lib/commonjs/services/spotifyDataService.js +241 -9
  82. package/lib/commonjs/services/storageService.js +404 -8
  83. package/lib/commonjs/services/telegramDataExtractor.js +115 -8
  84. package/lib/commonjs/services/telegramDataService.js +499 -9
  85. package/lib/commonjs/services/trainingApiHelpers.js +73 -7
  86. package/lib/commonjs/services/userConnectionsService.js +340 -10
  87. package/lib/commonjs/services/youtubeMigrationService.js +416 -10
  88. package/lib/commonjs/theme/index.js +250 -7
  89. package/lib/commonjs/types/ambient.d.js +2 -1
  90. package/lib/commonjs/types/declarations.d.js +2 -1
  91. package/lib/commonjs/types/index.js +6 -1
  92. package/lib/commonjs/types/node-fix.d.js +2 -1
  93. package/lib/commonjs/types/node-override.d.js +2 -1
  94. package/lib/commonjs/types/opacity.d.js +2 -1
  95. package/lib/commonjs/types.js +14 -1
  96. package/lib/commonjs/utils/Portal.js +98 -8
  97. package/lib/commonjs/utils/api.js +130 -9
  98. package/lib/commonjs/utils/assetRegistry.js +210 -35
  99. package/lib/commonjs/utils/auth.js +112 -9
  100. package/lib/commonjs/utils/connectorTests.js +613 -29
  101. package/lib/commonjs/utils/crypto.js +62 -8
  102. package/lib/commonjs/utils/debugHelper.js +64 -1
  103. package/lib/commonjs/utils/encryption.js +76 -7
  104. package/lib/commonjs/utils/eventUtils.js +288 -1
  105. package/lib/commonjs/utils/haptics.js +66 -9
  106. package/lib/commonjs/utils/imagePreloader.js +6 -1
  107. package/lib/commonjs/utils/networkDiagnostics.js +226 -8
  108. package/lib/commonjs/utils/onairosApi.js +350 -9
  109. package/lib/commonjs/utils/programmaticFlow.js +117 -9
  110. package/lib/commonjs/utils/retryHelper.js +220 -1
  111. package/lib/commonjs/utils/secureStorage.js +349 -10
  112. package/lib/commonjs/utils/webviewScripts/chatgpt.js +551 -1
  113. package/lib/commonjs/utils/webviewScripts/claude.js +376 -1
  114. package/lib/commonjs/utils/webviewScripts/hinge.js +411 -1
  115. package/lib/commonjs/utils/webviewScripts/index.js +698 -15
  116. package/lib/commonjs/utils/webviewScripts/instagram.js +454 -1
  117. package/lib/commonjs/utils/webviewScripts/linkedin.js +880 -1
  118. package/lib/commonjs/utils/webviewScripts/netflix.js +382 -1
  119. package/lib/commonjs/utils/webviewScripts/sephora.js +516 -1
  120. package/lib/commonjs/utils/webviewScripts/spotify.js +419 -1
  121. package/lib/commonjs/utils/webviewScripts/telegram.js +678 -1
  122. package/lib/module/api/index.js +211 -1
  123. package/lib/module/components/BodyText.js +20 -1
  124. package/lib/module/components/BrandMark.js +104 -1
  125. package/lib/module/components/CodeInput.js +113 -1
  126. package/lib/module/components/EmailInput.js +23 -1
  127. package/lib/module/components/GoogleButton.js +49 -1
  128. package/lib/module/components/HeadingGroup.js +36 -1
  129. package/lib/module/components/LLMDataInputModal.js +656 -7
  130. package/lib/module/components/ModalHeader.js +92 -1
  131. package/lib/module/components/ModalSheet.js +39 -1
  132. package/lib/module/components/Onairos.js +373 -1
  133. package/lib/module/components/OnairosButton.js +305 -1
  134. package/lib/module/components/OnairosSignInButton.js +121 -1
  135. package/lib/module/components/Overlay.js +456 -1
  136. package/lib/module/components/PersonaImage.js +129 -1
  137. package/lib/module/components/PersonaLoadingScreen.js +310 -1
  138. package/lib/module/components/PersonalizationConsentScreen.js +460 -1
  139. package/lib/module/components/PinCreationScreen.js +396 -1
  140. package/lib/module/components/PinInput.js +456 -1
  141. package/lib/module/components/PlatformConnectorsStep.js +1302 -6
  142. package/lib/module/components/PlatformList.js +129 -1
  143. package/lib/module/components/PlatformToggle.js +173 -1
  144. package/lib/module/components/PrimaryButton.js +172 -1
  145. package/lib/module/components/SignInMatchAnimation.js +189 -1
  146. package/lib/module/components/SignInStep.js +338 -1
  147. package/lib/module/components/UniversalOnboarding.js +2770 -1
  148. package/lib/module/components/VerificationStep.js +168 -1
  149. package/lib/module/components/WelcomeScreen.js +453 -1
  150. package/lib/module/components/icons/Basicproficon.js +30 -1
  151. package/lib/module/components/icons/Basicprofile.js +14 -1
  152. package/lib/module/components/icons/Checkbox.js +14 -1
  153. package/lib/module/components/icons/Checkmark.js +20 -1
  154. package/lib/module/components/icons/Contentanalysis.js +14 -1
  155. package/lib/module/components/icons/Contenticon.js +32 -1
  156. package/lib/module/components/icons/EnochE.js +34 -1
  157. package/lib/module/components/icons/Personalityicon.js +23 -1
  158. package/lib/module/components/icons/Personalityprofile.js +14 -1
  159. package/lib/module/components/icons/Personalitytraits.js +14 -1
  160. package/lib/module/components/icons/Userpreferences.js +14 -1
  161. package/lib/module/components/icons/index.js +13 -1
  162. package/lib/module/components/onboarding/OAuthWebView.js +1746 -1
  163. package/lib/module/components/onboarding/OnboardingHeader.js +66 -1
  164. package/lib/module/components/onboarding/PinInput.js +274 -1
  165. package/lib/module/components/onboarding/PlatformConnector.js +240 -1
  166. package/lib/module/config/PLATFORM_APIS.md +849 -0
  167. package/lib/module/config/api.js +47 -1
  168. package/lib/module/constants/index.js +114 -1
  169. package/lib/module/context/AuthContext.js +335 -1
  170. package/lib/module/hooks/useConnectedAccounts.js +106 -1
  171. package/lib/module/hooks/useConnections.js +95 -1
  172. package/lib/module/hooks/useCredentials.js +171 -6
  173. package/lib/module/hooks/useUserConnections.js +140 -1
  174. package/lib/module/index.js +172 -1
  175. package/lib/module/services/apiClient.js +295 -1
  176. package/lib/module/services/biometricPinService.js +169 -1
  177. package/lib/module/services/chatGPTConversationExtractor.js +149 -1
  178. package/lib/module/services/chatGPTConversationService.js +268 -1
  179. package/lib/module/services/claudeConversationExtractor.js +97 -1
  180. package/lib/module/services/claudeConversationService.js +151 -1
  181. package/lib/module/services/connectedAccountsService.js +293 -1
  182. package/lib/module/services/googleAuthService.js +241 -1
  183. package/lib/module/services/hingeDataExtractor.js +99 -1
  184. package/lib/module/services/hingeDataService.js +143 -1
  185. package/lib/module/services/imageCompressionService.js +250 -1
  186. package/lib/module/services/instagramDataExtractor.js +120 -1
  187. package/lib/module/services/instagramDataService.js +156 -1
  188. package/lib/module/services/jwtStorageService.js +257 -1
  189. package/lib/module/services/linkedinDOMExtractor.js +234 -1
  190. package/lib/module/services/linkedinProfileService.js +210 -1
  191. package/lib/module/services/linkedinScrapingService.js +219 -1
  192. package/lib/module/services/llmDataStorage.js +277 -1
  193. package/lib/module/services/mobileTrainingService.js +173 -1
  194. package/lib/module/services/netflixDataExtractor.js +114 -1
  195. package/lib/module/services/netflixDataService.js +191 -1
  196. package/lib/module/services/pinEncryptionService.js +74 -6
  197. package/lib/module/services/pinStorageUtils.js +93 -1
  198. package/lib/module/services/platformAuthService.js +1461 -1
  199. package/lib/module/services/sephoraDataExtractor.js +134 -1
  200. package/lib/module/services/sephoraDataService.js +193 -1
  201. package/lib/module/services/spotifyDataExtractor.js +142 -1
  202. package/lib/module/services/spotifyDataService.js +234 -1
  203. package/lib/module/services/storageService.js +383 -1
  204. package/lib/module/services/telegramDataExtractor.js +109 -1
  205. package/lib/module/services/telegramDataService.js +493 -1
  206. package/lib/module/services/trainingApiHelpers.js +67 -1
  207. package/lib/module/services/userConnectionsService.js +329 -1
  208. package/lib/module/services/youtubeMigrationService.js +405 -1
  209. package/lib/module/theme/index.js +245 -1
  210. package/lib/module/types.js +10 -1
  211. package/lib/module/utils/Portal.js +90 -1
  212. package/lib/module/utils/api.js +118 -1
  213. package/lib/module/utils/assetRegistry.js +200 -34
  214. package/lib/module/utils/auth.js +100 -1
  215. package/lib/module/utils/connectorTests.js +600 -27
  216. package/lib/module/utils/crypto.js +54 -1
  217. package/lib/module/utils/debugHelper.js +54 -1
  218. package/lib/module/utils/encryption.js +67 -1
  219. package/lib/module/utils/eventUtils.js +270 -1
  220. package/lib/module/utils/haptics.js +59 -8
  221. package/lib/module/utils/imagePreloader.js +3 -1
  222. package/lib/module/utils/networkDiagnostics.js +217 -1
  223. package/lib/module/utils/onairosApi.js +333 -1
  224. package/lib/module/utils/programmaticFlow.js +111 -1
  225. package/lib/module/utils/retryHelper.js +211 -1
  226. package/lib/module/utils/secureStorage.js +330 -6
  227. package/lib/module/utils/webviewScripts/chatgpt.js +545 -1
  228. package/lib/module/utils/webviewScripts/claude.js +370 -1
  229. package/lib/module/utils/webviewScripts/hinge.js +405 -1
  230. package/lib/module/utils/webviewScripts/index.js +434 -1
  231. package/lib/module/utils/webviewScripts/instagram.js +448 -1
  232. package/lib/module/utils/webviewScripts/linkedin.js +874 -1
  233. package/lib/module/utils/webviewScripts/netflix.js +376 -1
  234. package/lib/module/utils/webviewScripts/sephora.js +510 -1
  235. package/lib/module/utils/webviewScripts/spotify.js +413 -1
  236. package/lib/module/utils/webviewScripts/telegram.js +672 -1
  237. 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
- function _0x49b7(_0xfaa3cc,_0x49b7ca){_0xfaa3cc=_0xfaa3cc-0x0;const _0x37a545=_0xfaa3();let _0x54ac96=_0x37a545[_0xfaa3cc];return _0x54ac96;}import{storeClaudeConversations}from'./claudeConversationService';import{Alert}from'react-native';function _0xfaa3(){const _0x3b867b=['❌\x20[CLAUDE_EXTRACTOR]\x20No\x20valid\x20conversations\x20after\x20filtering','No\x20valid\x20conversations\x20found\x20to\x20export.','🚀\x20[CLAUDE_EXTRACTOR]\x20Initiating\x20conversation\x20export','👤\x20[CLAUDE_EXTRACTOR]\x20Username:','❌\x20[CLAUDE_EXTRACTOR]\x20Username\x20is\x20required','Error','default','ℹ️\x20[CLAUDE_EXTRACTOR]\x20No\x20conversations\x20to\x20export\x20-\x20treating\x20as\x20success\x20(connected)','Data\x20Error','✅\x20[CLAUDE_EXTRACTOR]\x20Export\x20completed\x20successfully','❌\x20[CLAUDE_EXTRACTOR]\x20Backend\x20storage\x20failed:','Export\x20Failed','An\x20unknown\x20error\x20occurred\x20during\x20conversation\x20storage.','Export\x20Error','Failed\x20to\x20connect\x20to\x20the\x20conversation\x20storage\x20service.\x20Please\x20check\x20your\x20network\x20connection.','ESPoo','vefWh','rTqQG','vJWoz','log','eQiTV','ArWiV','length','error','biGRz','alert','wpEnO','oMOke','filter','UxRBO','rcNhf','title','isArray','user_messages','Mbiph','ACECI','YUGyK','warn','foStm','WMOcm','ceviz','zxxJu','JNgEU','⚠️\x20[CLAUDE_EXTRACTOR]\x20Filtered\x20out\x20','dEEiB','\x20invalid\x20conversations','📡\x20[CLAUDE_EXTRACTOR]\x20Sending\x20to\x20backend...','success','uuGoN','📊\x20[CLAUDE_EXTRACTOR]\x20Backend\x20response:','data','zbMoU','gGRMZ','nvVhA','kUjAc','gLLuC'];_0xfaa3=function(){return _0x3b867b;};return _0xfaa3();}export const useClaudeConversationExtractor=()=>{const _0x161e97={'ESPoo':_0x49b7(0x0),'vefWh':_0x49b7(0x1),'rTqQG':function(_0x35012d,_0x1c001c){return _0x35012d>_0x1c001c;},'hCMBh':function(_0x5c680b,_0x31f57c){return _0x5c680b!==_0x31f57c;},'eQiTV':_0x49b7(0x2),'ArWiV':_0x49b7(0x3),'vOKEq':'📊\x20[CLAUDE_EXTRACTOR]\x20Conversations\x20to\x20send:','biGRz':_0x49b7(0x4),'wpEnO':_0x49b7(0x5),'dwZUx':_0x49b7(0x6),'oMOke':_0x49b7(0x7),'zxxJu':function(_0x314281,_0x36ae77){return _0x314281===_0x36ae77;},'JNgEU':_0x49b7(0x8),'dEEiB':function(_0x4493de,_0x3ae5e1){return _0x4493de-_0x3ae5e1;},'uuGoN':_0x49b7(0x9),'hhRrk':_0x49b7(0xa),'zbMoU':_0x49b7(0xb),'gGRMZ':_0x49b7(0xc),'nvVhA':'❌\x20[CLAUDE_EXTRACTOR]\x20Unexpected\x20error\x20during\x20export:','kUjAc':_0x49b7(0xd),'gLLuC':_0x49b7(0xe)},_0xc54e6f=async(_0xe07820,_0x133e96)=>{const _0x5aa149={'UxRBO':_0x161e97[_0x49b7(0xf)],'ZFEqg':_0x161e97[_0x49b7(0x10)],'rcNhf':_0x49b7(0x6),'Mbiph':function(_0x14b99d,_0x3697cd){return _0x161e97[_0x49b7(0x11)](_0x14b99d,_0x3697cd);},'ACECI':function(_0xfc5613,_0x2025b5){return _0x161e97['hCMBh'](_0xfc5613,_0x2025b5);},'YUGyK':_0x49b7(0x12)};console[_0x49b7(0x13)](_0x161e97[_0x49b7(0x14)]),console[_0x49b7(0x13)](_0x161e97[_0x49b7(0x15)],_0xe07820),console[_0x49b7(0x13)](_0x161e97['vOKEq'],_0x133e96[_0x49b7(0x16)]);if(!_0xe07820)return console[_0x49b7(0x17)](_0x161e97[_0x49b7(0x18)]),Alert[_0x49b7(0x19)](_0x161e97[_0x49b7(0x1a)],'Username\x20is\x20required\x20to\x20export\x20Claude\x20conversations.',[{'text':'OK','style':_0x161e97['dwZUx']}]),![];if(!_0x133e96||_0x133e96['length']===0x0)return console[_0x49b7(0x13)](_0x161e97[_0x49b7(0x1b)]),!![];const _0x4d7833=_0x133e96[_0x49b7(0x1c)](_0x1ca380=>{const _0x36793d={'foStm':_0x5aa149[_0x49b7(0x1d)],'WMOcm':_0x5aa149['ZFEqg'],'ceviz':_0x5aa149[_0x49b7(0x1e)]},_0x44330e=_0x1ca380['conversation_id']&&_0x1ca380[_0x49b7(0x1f)]&&Array[_0x49b7(0x20)](_0x1ca380[_0x49b7(0x21)])&&_0x5aa149[_0x49b7(0x22)](_0x1ca380[_0x49b7(0x21)]['length'],0x0);if(!_0x44330e){if(_0x5aa149[_0x49b7(0x23)]('KPCNo',_0x5aa149[_0x49b7(0x24)]))console[_0x49b7(0x25)]('⚠️\x20[CLAUDE_EXTRACTOR]\x20Invalid\x20conversation:',_0x1ca380);else return _0x4b1434[_0x49b7(0x17)](_0x36793d[_0x49b7(0x26)]),Alert['alert']('Data\x20Error',_0x36793d[_0x49b7(0x27)],[{'text':'OK','style':_0x36793d[_0x49b7(0x28)]}]),![];}return _0x44330e;});if(_0x161e97[_0x49b7(0x29)](_0x4d7833[_0x49b7(0x16)],0x0))return console['error'](_0x49b7(0x0)),Alert[_0x49b7(0x19)](_0x161e97[_0x49b7(0x2a)],'No\x20valid\x20conversations\x20found\x20to\x20export.',[{'text':'OK','style':_0x161e97['dwZUx']}]),![];_0x4d7833[_0x49b7(0x16)]<_0x133e96[_0x49b7(0x16)]&&console[_0x49b7(0x25)](_0x49b7(0x2b)+_0x161e97[_0x49b7(0x2c)](_0x133e96['length'],_0x4d7833[_0x49b7(0x16)])+_0x49b7(0x2d));try{console['log'](_0x49b7(0x2e));const _0x5e8718=await storeClaudeConversations(_0xe07820,_0x4d7833);return _0x5e8718[_0x49b7(0x2f)]?(console['log'](_0x161e97[_0x49b7(0x30)]),console[_0x49b7(0x13)](_0x49b7(0x31),_0x5e8718[_0x49b7(0x32)]),!![]):(console['error'](_0x161e97['hhRrk'],_0x5e8718['error']),Alert[_0x49b7(0x19)](_0x161e97[_0x49b7(0x33)],_0x5e8718[_0x49b7(0x17)]||_0x161e97[_0x49b7(0x34)],[{'text':'OK','style':_0x161e97['dwZUx']}]),![]);}catch(_0x35e23a){return console[_0x49b7(0x17)](_0x161e97[_0x49b7(0x35)],_0x35e23a),Alert['alert'](_0x161e97[_0x49b7(0x36)],_0x161e97[_0x49b7(0x37)],[{'text':'OK','style':_0x161e97['dwZUx']}]),![];}};return{'initiateConversationExport':_0xc54e6f};};
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
- function _0x4090(){const _0x504198=['❌\x20[CLAUDE_SERVICE]\x20Invalid\x20input','Authentication\x20token\x20not\x20found.\x20Please\x20log\x20in\x20again.','📊\x20[CLAUDE_SERVICE]\x20Number\x20of\x20conversations:','📊\x20[CLAUDE_SERVICE]\x20Total\x20messages:','qzHhu','onairos_jwt_token','auth_token','1.0.0','ios','17.0','mobile-claude','FcRpR','Pxbso','ahJvg','sujtR','Network\x20error.\x20Please\x20check\x20your\x20connection.','log','SIXQI','length','utYSI','reduce','user_messages','Euobe','skdKo','qMNBC','Failed\x20to\x20store\x20conversations\x20(','\x20errors)','getItem','szxhb','error','RZCHR','fGadJ','AiEno','yiRzX','iPhone','Android','kljOX','now','conversation_id','user','floor','PdTdT','fflPH','yddqE','conversation','📡\x20[CLAUDE_SERVICE]\x20Sending\x20conversation\x20','PDAtx','title','BASE_URL','/llm-data/store','Bearer\x20','stringify','KDpiO','hiUUU','✅\x20[CLAUDE_SERVICE]\x20Sent\x20conversation\x20','BXpiF','warn','⚠️\x20[CLAUDE_SERVICE]\x20Network\x20error\x20for\x20conversation\x20','⚠️\x20[CLAUDE_SERVICE]\x20Failed\x20conversation\x20','BstTG','status','OMcRr','ASfkf','ybKxt','📊\x20[CLAUDE_SERVICE]\x20Complete:\x20','\x20success,\x20','\x20failed','NFCYC','Stored\x20','\x20of\x20','\x20conversations','KXBdA','❌\x20[CLAUDE_SERVICE]\x20No\x20auth\x20token\x20found\x20in\x20any\x20storage\x20key','❌\x20[CLAUDE_SERVICE]\x20Network\x20error:','tDJOj'];_0x4090=function(){return _0x504198;};return _0x4090();}import{API_CONFIG}from'../config/api';function _0xa0be(_0x409092,_0xa0bed5){_0x409092=_0x409092-0x0;const _0x2ccd38=_0x4090();let _0x29d0fa=_0x2ccd38[_0x409092];return _0x29d0fa;}import AsyncStorage from'@react-native-async-storage/async-storage';import{Platform}from'react-native';export const storeClaudeConversations=async(_0x47375d,_0x1a75b9)=>{const _0x28a291={'PDAtx':function(_0x209060,_0x14d7ec){return _0x209060+_0x14d7ec;},'skdKo':_0xa0be(0x0),'qMNBC':'Invalid\x20input:\x20userId\x20or\x20conversations\x20missing.','FOmEj':_0xa0be(0x1),'upmhs':'🚀\x20[CLAUDE_SERVICE]\x20Storing\x20Claude\x20conversations\x20for:','SIXQI':_0xa0be(0x2),'utYSI':_0xa0be(0x3),'YoLSy':function(_0x15691c,_0x3b2367){return _0x15691c||_0x3b2367;},'kTdiG':'arPbw','Euobe':_0xa0be(0x4),'szxhb':_0xa0be(0x5),'opJSt':'enoch_token','UFoWd':_0xa0be(0x6),'RZCHR':'❌\x20[CLAUDE_SERVICE]\x20No\x20auth\x20token\x20found\x20in\x20any\x20storage\x20key','fGadJ':'🔑\x20[CLAUDE_SERVICE]\x20Auth\x20token\x20found','AiEno':_0xa0be(0x7),'OMcRr':function(_0x4de0c5,_0x229e92){return _0x4de0c5===_0x229e92;},'yiRzX':_0xa0be(0x8),'ONZEs':_0xa0be(0x9),'kljOX':function(_0x23e853,_0x2298b5){return _0x23e853<_0x2298b5;},'PdTdT':function(_0x274b7e,_0x14d57b){return _0x274b7e/_0x14d57b;},'fflPH':function(_0x398c2b,_0x1b347d){return _0x398c2b/_0x1b347d;},'yddqE':_0xa0be(0xa),'hjZzU':function(_0xe38de2,_0x31934e,_0x4219e6){return _0xe38de2(_0x31934e,_0x4219e6);},'KDpiO':function(_0x9c7ce8,_0x14410b){return _0x9c7ce8===_0x14410b;},'hiUUU':_0xa0be(0xb),'BXpiF':function(_0x27ef2f,_0x71c942){return _0x27ef2f+_0x71c942;},'BstTG':function(_0x186e8f,_0x2ebf20){return _0x186e8f+_0x2ebf20;},'ASfkf':_0xa0be(0xc),'NFCYC':function(_0xa9d382,_0x2d594b){return _0xa9d382>_0x2d594b;},'KXBdA':function(_0x4cdad6,_0x4694ae){return _0x4cdad6!==_0x4694ae;},'EsrXN':_0xa0be(0xd),'PmtGm':function(_0x581948,_0x28f9ac){return _0x581948!==_0x28f9ac;},'FuQEn':_0xa0be(0xe),'tDJOj':_0xa0be(0xf)};console[_0xa0be(0x10)](_0x28a291['upmhs'],_0x47375d),console[_0xa0be(0x10)](_0x28a291[_0xa0be(0x11)],_0x1a75b9[_0xa0be(0x12)]),console[_0xa0be(0x10)](_0x28a291[_0xa0be(0x13)],_0x1a75b9[_0xa0be(0x14)]((_0x187a26,_0x4556dc)=>_0x187a26+_0x4556dc[_0xa0be(0x15)][_0xa0be(0x12)],0x0));if(_0x28a291['YoLSy'](!_0x47375d,!_0x1a75b9)||_0x1a75b9['length']===0x0)return _0x28a291['kTdiG']!==_0x28a291[_0xa0be(0x16)]?(console['error'](_0x28a291[_0xa0be(0x17)]),{'success':![],'error':_0x28a291[_0xa0be(0x18)]}):{'success':![],'error':_0xa0be(0x19)+_0x4fce22+_0xa0be(0x1a)};try{const _0x5c5ff5=await AsyncStorage[_0xa0be(0x1b)](_0x28a291[_0xa0be(0x1c)])||await AsyncStorage[_0xa0be(0x1b)](_0x28a291['opJSt'])||await AsyncStorage[_0xa0be(0x1b)](_0x28a291['UFoWd']);if(!_0x5c5ff5)return console[_0xa0be(0x1d)](_0x28a291[_0xa0be(0x1e)]),{'success':![],'error':'Authentication\x20token\x20not\x20found.\x20Please\x20log\x20in\x20again.'};console['log'](_0x28a291[_0xa0be(0x1f)]);const _0x3a978a={'platform':Platform['OS'],'appVersion':_0x28a291[_0xa0be(0x20)],'osVersion':_0x28a291['OMcRr'](Platform['OS'],_0x28a291[_0xa0be(0x21)])?_0x28a291['ONZEs']:Platform['OS'],'deviceModel':_0x28a291['OMcRr'](Platform['OS'],_0x28a291[_0xa0be(0x21)])?_0xa0be(0x22):_0xa0be(0x23),'isOfflineSync':![]};let _0x192b10=0x0,_0x40bb8b=0x0;for(let _0x1206ee=0x0;_0x28a291[_0xa0be(0x24)](_0x1206ee,_0x1a75b9['length']);_0x1206ee++){const _0x389531=_0x1a75b9[_0x1206ee],_0x400641=Date[_0xa0be(0x25)](),_0x4b06f6=_0x389531[_0xa0be(0x15)]['map']((_0x2ccba8,_0x4c0653)=>({'id':_0x389531[_0xa0be(0x26)]+'-msg-'+_0x4c0653,'role':_0xa0be(0x27),'content':_0x2ccba8,'timestamp':new Date(_0x400641-(_0x389531[_0xa0be(0x15)]['length']-_0x4c0653)*0x3e8)['toISOString'](),'metadata':{}})),_0x2effc2={'conversationId':_0x389531[_0xa0be(0x26)],'messages':_0x4b06f6,'context':{'title':_0x389531['title'],'create_time':Math[_0xa0be(0x28)](_0x28a291[_0xa0be(0x29)](_0x400641,0x3e8)),'update_time':Math['floor'](_0x28a291[_0xa0be(0x2a)](_0x400641,0x3e8))},'mobileMetadata':_0x3a978a},_0x501679={'platform':_0x28a291[_0xa0be(0x2b)],'conversationData':_0x2effc2,'memoryType':_0xa0be(0x2c)};console[_0xa0be(0x10)](_0xa0be(0x2d)+_0x28a291[_0xa0be(0x2e)](_0x1206ee,0x1)+'/'+_0x1a75b9[_0xa0be(0x12)]+':\x20'+_0x389531[_0xa0be(0x2f)]);try{const _0x84aa0=await _0x28a291['hjZzU'](fetch,API_CONFIG[_0xa0be(0x30)]+_0xa0be(0x31),{'method':'POST','headers':{'Content-Type':'application/json','Authorization':_0xa0be(0x32)+_0x5c5ff5,'User-Agent':'OnairosSDK/1.0.0\x20('+Platform['OS']+')'},'body':JSON[_0xa0be(0x33)](_0x501679)}),_0x1c6460=await _0x84aa0['json']();_0x84aa0['ok']?_0x28a291[_0xa0be(0x34)](_0x28a291[_0xa0be(0x35)],_0x28a291[_0xa0be(0x35)])?(console[_0xa0be(0x10)](_0xa0be(0x36)+_0x28a291[_0xa0be(0x37)](_0x1206ee,0x1)+'/'+_0x1a75b9['length']),_0x192b10++):(_0x2b74cf[_0xa0be(0x38)](_0xa0be(0x39)+_0x28a291[_0xa0be(0x2e)](_0x5cb7ce,0x1)+':',_0x3ac5ce),_0x505182++):(console[_0xa0be(0x38)](_0xa0be(0x3a)+_0x28a291[_0xa0be(0x3b)](_0x1206ee,0x1)+'/'+_0x1a75b9[_0xa0be(0x12)]+':',_0x1c6460[_0xa0be(0x1d)]||_0x84aa0[_0xa0be(0x3c)]),_0x40bb8b++);}catch(_0xf11332){_0x28a291[_0xa0be(0x3d)](_0x28a291[_0xa0be(0x3e)],_0xa0be(0x3f))?(_0x5e0734[_0xa0be(0x38)](_0xa0be(0x3a)+(_0x53450c+0x1)+'/'+_0x3d51f5[_0xa0be(0x12)]+':',_0x3ddf98['error']||_0x554b6f[_0xa0be(0x3c)]),_0x5b0605++):(console[_0xa0be(0x38)](_0xa0be(0x39)+_0x28a291['BstTG'](_0x1206ee,0x1)+':',_0xf11332),_0x40bb8b++);}_0x28a291[_0xa0be(0x24)](_0x1206ee,_0x1a75b9['length']-0x1)&&await new Promise(_0x310866=>setTimeout(_0x310866,0x12c));}return console[_0xa0be(0x10)](_0xa0be(0x40)+_0x192b10+_0xa0be(0x41)+_0x40bb8b+_0xa0be(0x42)),_0x28a291[_0xa0be(0x43)](_0x192b10,0x0)?{'success':!![],'message':_0xa0be(0x44)+_0x192b10+_0xa0be(0x45)+_0x1a75b9['length']+_0xa0be(0x46)}:_0x28a291[_0xa0be(0x47)](_0xa0be(0xd),_0x28a291['EsrXN'])?(_0x41e065[_0xa0be(0x1d)](_0x28a291['skdKo']),{'success':![],'error':_0x28a291[_0xa0be(0x18)]}):{'success':![],'error':_0xa0be(0x19)+_0x40bb8b+_0xa0be(0x1a)};}catch(_0x5c2ed2){return _0x28a291['PmtGm'](_0x28a291['FuQEn'],_0xa0be(0xe))?(_0x2552d3[_0xa0be(0x1d)](_0xa0be(0x48)),{'success':![],'error':_0x28a291['FOmEj']}):(console[_0xa0be(0x1d)](_0xa0be(0x49),_0x5c2ed2),{'success':![],'error':_0x5c2ed2['message']||_0x28a291[_0xa0be(0x4a)]});}};
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