@bytexbyte/nxtlinq-ai-agent-sdk 1.5.9 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ChatBot.d.ts.map +1 -1
- package/dist/components/ChatBot.js +0 -1
- package/dist/components/context/ChatBotContext.d.ts.map +1 -1
- package/dist/components/context/ChatBotContext.js +42 -82
- package/dist/components/ui/BerifyMeModal.d.ts +1 -0
- package/dist/components/ui/BerifyMeModal.d.ts.map +1 -1
- package/dist/components/ui/BerifyMeModal.js +8 -10
- package/dist/components/ui/ChatBotUI.d.ts +1 -0
- package/dist/components/ui/ChatBotUI.d.ts.map +1 -1
- package/dist/components/ui/ChatBotUI.js +58 -222
- package/dist/components/ui/MessageInput.d.ts.map +1 -1
- package/dist/components/ui/MessageInput.js +41 -38
- package/dist/components/ui/MessageList.d.ts +1 -0
- package/dist/components/ui/MessageList.d.ts.map +1 -1
- package/dist/components/ui/MessageList.js +16 -79
- package/dist/components/ui/ModelSelector.d.ts +1 -0
- package/dist/components/ui/ModelSelector.d.ts.map +1 -1
- package/dist/components/ui/ModelSelector.js +51 -45
- package/dist/components/ui/NotificationModal.d.ts +1 -0
- package/dist/components/ui/NotificationModal.d.ts.map +1 -1
- package/dist/components/ui/NotificationModal.js +48 -74
- package/dist/components/ui/PermissionForm.d.ts +1 -1
- package/dist/components/ui/PermissionForm.d.ts.map +1 -1
- package/dist/components/ui/PermissionForm.js +302 -293
- package/dist/components/ui/PresetMessages.d.ts +1 -0
- package/dist/components/ui/PresetMessages.d.ts.map +1 -1
- package/dist/components/ui/PresetMessages.js +26 -27
- package/dist/components/ui/styles/isolatedStyles.d.ts +34 -0
- package/dist/components/ui/styles/isolatedStyles.d.ts.map +1 -0
- package/dist/components/ui/styles/isolatedStyles.js +449 -0
- package/dist/core/lib/useSpeechToTextFromMic/helper.d.ts.map +1 -1
- package/dist/core/lib/useSpeechToTextFromMic/helper.js +0 -4
- package/dist/core/lib/useSpeechToTextFromMic/index.js +1 -1
- package/dist/core/metakeepClient.d.ts.map +1 -1
- package/dist/core/metakeepClient.js +0 -1
- package/package.json +1 -1
- package/umd/nxtlinq-ai-agent.umd.js +882 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBot.d.ts","sourceRoot":"","sources":["../../src/components/ChatBot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"ChatBot.d.ts","sourceRoot":"","sources":["../../src/components/ChatBot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAoD1C,CAAC;AAEF,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -11,7 +11,6 @@ export const ChatBot = (props) => {
|
|
|
11
11
|
const urlParams = new URLSearchParams(window.location.search);
|
|
12
12
|
const token = urlParams.get('token');
|
|
13
13
|
if (token) {
|
|
14
|
-
console.log('Token found in URL, returning it');
|
|
15
14
|
return Promise.resolve({ token });
|
|
16
15
|
}
|
|
17
16
|
// Use external onVerifyWallet if provided and in external mode
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBotContext.d.ts","sourceRoot":"","sources":["../../../src/components/context/ChatBotContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,OAAO,EACL,kBAAkB,EAClB,YAAY,EAGb,MAAM,uBAAuB,CAAC;AAI/B,eAAO,MAAM,UAAU,0BAMtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"ChatBotContext.d.ts","sourceRoot":"","sources":["../../../src/components/context/ChatBotContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,OAAO,EACL,kBAAkB,EAClB,YAAY,EAGb,MAAM,uBAAuB,CAAC;AAI/B,eAAO,MAAM,UAAU,0BAMtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA21DlD,CAAC"}
|
|
@@ -38,7 +38,6 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
38
38
|
apiKey,
|
|
39
39
|
apiSecret
|
|
40
40
|
});
|
|
41
|
-
// State
|
|
42
41
|
// Session-level data (always use sessionStorage when useSessionStorageMode is true)
|
|
43
42
|
const [messages, setMessages] = useSessionStorageMode
|
|
44
43
|
? useSessionStorage('chatbot-messages', [])
|
|
@@ -46,7 +45,6 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
46
45
|
const [isOpen, setIsOpen] = useSessionStorageMode
|
|
47
46
|
? useSessionStorage('chatbot-is-open', false)
|
|
48
47
|
: React.useState(false);
|
|
49
|
-
// Non-stored state
|
|
50
48
|
const [inputValue, setInputValue] = React.useState('');
|
|
51
49
|
const [isLoading, setIsLoading] = React.useState(false);
|
|
52
50
|
const [hitAddress, setHitAddress] = React.useState(null);
|
|
@@ -61,12 +59,13 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
61
59
|
const [walletInfo, setWalletInfo] = React.useState(null);
|
|
62
60
|
const [isWalletLoading, setIsWalletLoading] = React.useState(false);
|
|
63
61
|
const [isAutoConnecting, setIsAutoConnecting] = React.useState(false);
|
|
64
|
-
const [justAutoConnected, setJustAutoConnected] = React.useState(false);
|
|
65
62
|
// Persistent data (always use localStorage)
|
|
66
63
|
const [nxtlinqAITServiceAccessToken, setNxtlinqAITServiceAccessToken] = useLocalStorage('nxtlinqAITServiceAccessToken', '');
|
|
67
64
|
const [pseudoId, setPseudoId] = useLocalStorage('pseudoId', uuidv4());
|
|
68
|
-
// UI state (
|
|
69
|
-
const [suggestions, setSuggestions] =
|
|
65
|
+
// UI state (use session storage when useSessionStorageMode is true)
|
|
66
|
+
const [suggestions, setSuggestions] = useSessionStorageMode
|
|
67
|
+
? useSessionStorage('chatbot-suggestions', presetMessages)
|
|
68
|
+
: React.useState(presetMessages);
|
|
70
69
|
const [isAITEnabling, setIsAITEnabling] = React.useState(false);
|
|
71
70
|
// Use refs to get latest state values in hasPermission function
|
|
72
71
|
const hitAddressRef = React.useRef(hitAddress);
|
|
@@ -77,6 +76,16 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
77
76
|
// Refs for input value and recording state
|
|
78
77
|
const isRecordingRef = React.useRef(false);
|
|
79
78
|
const textInputRef = React.useRef(null);
|
|
79
|
+
// Simple token cleanup function
|
|
80
|
+
const clearExpiredToken = React.useCallback(() => {
|
|
81
|
+
try {
|
|
82
|
+
localStorage.removeItem('nxtlinqAITServiceAccessToken');
|
|
83
|
+
setNxtlinqAITServiceAccessToken('');
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
console.error('Error clearing expired token:', error);
|
|
87
|
+
}
|
|
88
|
+
}, []);
|
|
80
89
|
// Update refs when state changes
|
|
81
90
|
React.useEffect(() => {
|
|
82
91
|
hitAddressRef.current = hitAddress;
|
|
@@ -191,14 +200,12 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
191
200
|
const walletResponse = await nxtlinqApi.wallet.getWallet({ address: hitAddress }, nxtlinqAITServiceAccessToken);
|
|
192
201
|
if (!('error' in walletResponse)) {
|
|
193
202
|
setWalletInfo(walletResponse);
|
|
194
|
-
console.log('Wallet info updated:', walletResponse);
|
|
195
203
|
}
|
|
196
204
|
else {
|
|
197
|
-
console.log('Failed to get wallet info:', walletResponse.error);
|
|
198
205
|
// Check if the error is due to invalid/expired token
|
|
199
206
|
if (walletResponse.error.includes('Invalid or expired token')) {
|
|
200
207
|
console.log('Token appears to be invalid during wallet info fetch, clearing it');
|
|
201
|
-
|
|
208
|
+
clearExpiredToken();
|
|
202
209
|
}
|
|
203
210
|
}
|
|
204
211
|
}
|
|
@@ -206,23 +213,28 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
206
213
|
console.error('Failed to fetch wallet info:', error);
|
|
207
214
|
}
|
|
208
215
|
}
|
|
209
|
-
|
|
210
|
-
|
|
216
|
+
// Only try to fetch AIT if we have a token
|
|
217
|
+
if (nxtlinqAITServiceAccessToken) {
|
|
218
|
+
const response = await nxtlinqApi.ait.getAITByServiceIdAndController({
|
|
219
|
+
serviceId,
|
|
220
|
+
controller: hitAddress
|
|
221
|
+
}, nxtlinqAITServiceAccessToken);
|
|
222
|
+
if ('error' in response) {
|
|
223
|
+
console.error('Failed to fetch AIT:', response.error);
|
|
224
|
+
setAit(null);
|
|
225
|
+
setPermissions([]);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
setAit(response);
|
|
229
|
+
if (!isPermissionFormOpen || forceUpdatePermissions) {
|
|
230
|
+
const newPermissions = response.metadata?.permissions || [];
|
|
231
|
+
setPermissions(newPermissions);
|
|
232
|
+
}
|
|
211
233
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
controller: hitAddress
|
|
215
|
-
}, nxtlinqAITServiceAccessToken || '');
|
|
216
|
-
if ('error' in response) {
|
|
217
|
-
console.error('Failed to fetch AIT:', response.error);
|
|
234
|
+
else {
|
|
235
|
+
// No token available, clear AIT data
|
|
218
236
|
setAit(null);
|
|
219
237
|
setPermissions([]);
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
setAit(response);
|
|
223
|
-
if (!isPermissionFormOpen || forceUpdatePermissions) {
|
|
224
|
-
const newPermissions = response.metadata?.permissions || [];
|
|
225
|
-
setPermissions(newPermissions);
|
|
226
238
|
}
|
|
227
239
|
}
|
|
228
240
|
catch (error) {
|
|
@@ -287,7 +299,7 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
287
299
|
// Check if token is expired or address mismatch
|
|
288
300
|
if (exp < now || address !== userAddress) {
|
|
289
301
|
console.log('Token is expired or address mismatch, clearing token');
|
|
290
|
-
|
|
302
|
+
clearExpiredToken();
|
|
291
303
|
// Don't call refreshAIT with invalid token
|
|
292
304
|
}
|
|
293
305
|
else {
|
|
@@ -298,7 +310,7 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
298
310
|
}
|
|
299
311
|
catch (error) {
|
|
300
312
|
console.error('Error parsing token during wallet connection:', error);
|
|
301
|
-
|
|
313
|
+
clearExpiredToken();
|
|
302
314
|
}
|
|
303
315
|
}
|
|
304
316
|
// If requireIDV is false and we have customUsername, check if wallet exists in AIT Service
|
|
@@ -319,12 +331,6 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
319
331
|
if ('error' in verifyResponse) {
|
|
320
332
|
console.error('Failed to create wallet with custom method:', verifyResponse.error);
|
|
321
333
|
}
|
|
322
|
-
else {
|
|
323
|
-
console.log('Successfully created wallet with custom method');
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
console.log('Wallet already exists in AIT Service');
|
|
328
334
|
}
|
|
329
335
|
}
|
|
330
336
|
catch (error) {
|
|
@@ -355,15 +361,13 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
355
361
|
if (autoShowSignInMessage) {
|
|
356
362
|
throw error;
|
|
357
363
|
}
|
|
358
|
-
return false;
|
|
364
|
+
return false;
|
|
359
365
|
}
|
|
360
366
|
}, [nxtlinqAITServiceAccessToken, refreshAIT, isNeedSignInWithWallet, requireWalletIDVVerification, customUsername, nxtlinqApi]);
|
|
361
|
-
// Sign in wallet
|
|
362
367
|
const signInWallet = async (autoShowSuccessMessage = true) => {
|
|
363
368
|
// Use refs to get latest state values for consistency with hasPermission
|
|
364
369
|
const currentHitAddress = hitAddressRef.current;
|
|
365
370
|
const currentSigner = signerRef.current;
|
|
366
|
-
console.log('signInWallet called: currentHitAddress =', currentHitAddress, 'currentSigner =', !!currentSigner);
|
|
367
371
|
// If refs don't have the values, try using current state values
|
|
368
372
|
const addressToUse = currentHitAddress || hitAddress;
|
|
369
373
|
const signerToUse = currentSigner || signer;
|
|
@@ -410,7 +414,6 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
410
414
|
setNxtlinqAITServiceAccessToken(accessToken);
|
|
411
415
|
// Wait for state to update before refreshing AIT
|
|
412
416
|
await new Promise(resolve => setTimeout(resolve, 100));
|
|
413
|
-
// Wait for AIT to be loaded before showing success message
|
|
414
417
|
await refreshAIT();
|
|
415
418
|
if (autoShowSuccessMessage) {
|
|
416
419
|
showSuccess('Successfully signed in with your HIT wallet. You can now use the AI agent.');
|
|
@@ -444,16 +447,9 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
444
447
|
setIsAutoConnecting(true); // Mark as auto-connecting
|
|
445
448
|
await connectWallet(false); // Don't show sign-in message yet
|
|
446
449
|
setIsAutoConnecting(false); // Clear auto-connecting state
|
|
447
|
-
setJustAutoConnected(true); // Mark that we just auto-connected
|
|
448
|
-
console.log('Set justAutoConnected to true after auto-connect');
|
|
449
450
|
// Show brief success message for auto-connect
|
|
450
451
|
showSuccess('Auto wallet connection successful');
|
|
451
|
-
// Clear the flag after a longer delay to allow for AIT loading
|
|
452
|
-
setTimeout(() => {
|
|
453
|
-
setJustAutoConnected(false);
|
|
454
|
-
}, 15000); // 15 seconds to allow for full AIT loading process
|
|
455
452
|
onAutoConnect?.(); // Call callback if provided
|
|
456
|
-
// Wait a bit for state to update
|
|
457
453
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
458
454
|
// After auto connect, if not signed in, then auto sign-in
|
|
459
455
|
const tokenAfterConnect = nxtlinqAITServiceAccessTokenRef.current;
|
|
@@ -487,7 +483,6 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
487
483
|
}
|
|
488
484
|
if (!currentToken) {
|
|
489
485
|
if (autoRetry) {
|
|
490
|
-
console.log('Auto sign-in triggered: currentHitAddress =', currentHitAddress, 'currentToken =', currentToken);
|
|
491
486
|
setIsLoading(false); // Stop thinking before showing message
|
|
492
487
|
setMessages(prev => [...prev, {
|
|
493
488
|
id: Date.now().toString(),
|
|
@@ -498,10 +493,8 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
498
493
|
}]);
|
|
499
494
|
try {
|
|
500
495
|
setIsAutoConnecting(true); // Mark as auto-signing
|
|
501
|
-
console.log('Starting auto sign-in...');
|
|
502
496
|
await signInWallet(false); // Don't show success message yet
|
|
503
497
|
onAutoSignIn?.(); // Call callback if provided
|
|
504
|
-
console.log('Auto sign-in completed');
|
|
505
498
|
setIsAutoConnecting(false); // Clear auto-signing state
|
|
506
499
|
// Show brief success message for auto-sign-in
|
|
507
500
|
showSuccess('Auto sign-in successful');
|
|
@@ -516,7 +509,6 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
516
509
|
}
|
|
517
510
|
// Only continue if AIT is actually loaded
|
|
518
511
|
if (aitRef.current) {
|
|
519
|
-
console.log('AIT loaded successfully after sign-in, continuing permission check');
|
|
520
512
|
// Wait a bit more to ensure permissions are also loaded
|
|
521
513
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
522
514
|
// If sign-in successful, continue with permission check
|
|
@@ -524,7 +516,6 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
524
516
|
return result;
|
|
525
517
|
}
|
|
526
518
|
else {
|
|
527
|
-
console.log('AIT failed to load after sign-in, returning false');
|
|
528
519
|
return false;
|
|
529
520
|
}
|
|
530
521
|
}
|
|
@@ -570,7 +561,6 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
570
561
|
}
|
|
571
562
|
// Only continue if AIT is actually loaded
|
|
572
563
|
if (aitRef.current) {
|
|
573
|
-
console.log('AIT loaded successfully after session expiry, continuing permission check');
|
|
574
564
|
// Wait a bit more to ensure permissions are also loaded
|
|
575
565
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
576
566
|
// If sign-in successful, continue with permission check
|
|
@@ -578,7 +568,6 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
578
568
|
return result;
|
|
579
569
|
}
|
|
580
570
|
else {
|
|
581
|
-
console.log('AIT failed to load after session expiry, returning false');
|
|
582
571
|
return false;
|
|
583
572
|
}
|
|
584
573
|
}
|
|
@@ -621,7 +610,6 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
621
610
|
}
|
|
622
611
|
// Only continue if AIT is actually loaded
|
|
623
612
|
if (aitRef.current) {
|
|
624
|
-
console.log('AIT loaded successfully after address mismatch, continuing permission check');
|
|
625
613
|
// Wait a bit more to ensure permissions are also loaded
|
|
626
614
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
627
615
|
// If sign-in successful, continue with permission check
|
|
@@ -629,7 +617,6 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
629
617
|
return result;
|
|
630
618
|
}
|
|
631
619
|
else {
|
|
632
|
-
console.log('AIT failed to load after address mismatch, returning false');
|
|
633
620
|
return false;
|
|
634
621
|
}
|
|
635
622
|
}
|
|
@@ -673,7 +660,6 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
673
660
|
}
|
|
674
661
|
// Only continue if AIT is actually loaded
|
|
675
662
|
if (aitRef.current) {
|
|
676
|
-
console.log('AIT loaded successfully after token error, continuing permission check');
|
|
677
663
|
// Wait a bit more to ensure permissions are also loaded
|
|
678
664
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
679
665
|
// If sign-in successful, continue with permission check
|
|
@@ -681,7 +667,6 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
681
667
|
return result;
|
|
682
668
|
}
|
|
683
669
|
else {
|
|
684
|
-
console.log('AIT failed to load after token error, returning false');
|
|
685
670
|
return false;
|
|
686
671
|
}
|
|
687
672
|
}
|
|
@@ -891,16 +876,13 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
891
876
|
const errorResponse = response;
|
|
892
877
|
if (errorResponse.requiresWalletConnection) {
|
|
893
878
|
// Case where wallet connection is required - trigger auto-connect logic
|
|
894
|
-
console.log('API requires wallet connection, triggering auto-connect...');
|
|
895
879
|
// Try to auto-connect wallet first
|
|
896
880
|
const autoConnectResult = await connectWallet(false); // Don't show sign-in message yet
|
|
897
881
|
if (autoConnectResult) {
|
|
898
882
|
// If auto-connect successful, try to sign in and then retry
|
|
899
|
-
console.log('Auto-connect successful, trying to sign in...');
|
|
900
883
|
try {
|
|
901
884
|
// Try to sign in wallet
|
|
902
885
|
await signInWallet(false); // Don't show success message yet
|
|
903
|
-
console.log('Auto sign-in successful, retrying message...');
|
|
904
886
|
if (isSemiAutomaticMode) {
|
|
905
887
|
setIsLoading(false);
|
|
906
888
|
setMessages(prev => [...prev, {
|
|
@@ -920,7 +902,6 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
920
902
|
}
|
|
921
903
|
}
|
|
922
904
|
catch (signInError) {
|
|
923
|
-
console.log('Auto sign-in failed, showing error message');
|
|
924
905
|
setIsLoading(false);
|
|
925
906
|
setMessages(prev => [...prev, {
|
|
926
907
|
id: Date.now().toString(),
|
|
@@ -955,7 +936,6 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
955
936
|
}
|
|
956
937
|
else if (errorResponse.requiresPermissionUpdate) {
|
|
957
938
|
// Case where permission update is required - show manual enable option
|
|
958
|
-
console.log('API requires permission update, showing manual enable option...');
|
|
959
939
|
setIsLoading(false);
|
|
960
940
|
setMessages(prev => [...prev, {
|
|
961
941
|
id: Date.now().toString(),
|
|
@@ -1013,14 +993,12 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
1013
993
|
else {
|
|
1014
994
|
// Only retry for auto-connect/auto-sign-in scenarios
|
|
1015
995
|
if (wasAutoConnected && retryCount < 1) {
|
|
1016
|
-
console.log('Auto-connected, retrying message...');
|
|
1017
996
|
// Clear loading state and retry immediately
|
|
1018
997
|
setIsLoading(false);
|
|
1019
998
|
// Check if wallet is already signed in
|
|
1020
999
|
const currentToken = nxtlinqAITServiceAccessTokenRef.current;
|
|
1021
1000
|
if (!currentToken) {
|
|
1022
1001
|
// If not signed in, directly retry the message without waiting for AIT
|
|
1023
|
-
console.log('Wallet connected but not signed in, retrying message directly');
|
|
1024
1002
|
setTimeout(() => {
|
|
1025
1003
|
sendMessage(content, retryCount + 1, isPresetMessage);
|
|
1026
1004
|
}, 2000);
|
|
@@ -1041,20 +1019,13 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
1041
1019
|
}
|
|
1042
1020
|
// Only retry if AIT is actually loaded
|
|
1043
1021
|
if (aitRef.current) {
|
|
1044
|
-
console.log('AIT loaded successfully, retrying message');
|
|
1045
1022
|
// Wait a bit more to ensure permissions are also loaded
|
|
1046
1023
|
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
1047
1024
|
sendMessage(content, retryCount + 1, isPresetMessage);
|
|
1048
1025
|
}
|
|
1049
|
-
else {
|
|
1050
|
-
console.log('AIT failed to load, not retrying');
|
|
1051
|
-
}
|
|
1052
1026
|
}, 2000);
|
|
1053
1027
|
}
|
|
1054
1028
|
}
|
|
1055
|
-
else {
|
|
1056
|
-
console.log('Permission denied, not retrying. wasAutoConnected:', wasAutoConnected, 'retryCount:', retryCount);
|
|
1057
|
-
}
|
|
1058
1029
|
return;
|
|
1059
1030
|
}
|
|
1060
1031
|
}
|
|
@@ -1307,7 +1278,6 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
1307
1278
|
isFromAIAgent: isFromAIAgent,
|
|
1308
1279
|
parentAITId: isFromAIAgent ? aitRef.current?.aitId : undefined,
|
|
1309
1280
|
};
|
|
1310
|
-
console.log('createAIT params:', createAITParams);
|
|
1311
1281
|
const createAITResponse = await nxtlinqApi.ait.createAIT(createAITParams, nxtlinqAITServiceAccessToken || '');
|
|
1312
1282
|
if ('error' in createAITResponse) {
|
|
1313
1283
|
throw new Error(`Failed to create AIT: ${createAITResponse.error}`);
|
|
@@ -1327,15 +1297,12 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
1327
1297
|
if (isAITEnabling)
|
|
1328
1298
|
return false; // Prevent duplicate
|
|
1329
1299
|
setIsAITEnabling(true);
|
|
1330
|
-
console.log('enableAIT called with toolName:', toolName, 'existing AIT:', !!aitRef.current);
|
|
1331
1300
|
let currentSigner = signer;
|
|
1332
1301
|
let currentHitAddress = hitAddress;
|
|
1333
1302
|
// If no wallet connected, try to auto-connect first
|
|
1334
1303
|
if (!currentSigner || !currentHitAddress) {
|
|
1335
|
-
console.log('No wallet connected, attempting auto-connect...');
|
|
1336
1304
|
const autoConnectResult = await connectWallet(false); // Don't show sign-in message yet
|
|
1337
1305
|
if (autoConnectResult) {
|
|
1338
|
-
console.log('Auto-connect successful, waiting for state update...');
|
|
1339
1306
|
// Wait for state to update - increase wait time
|
|
1340
1307
|
await new Promise(resolve => setTimeout(resolve, 1500));
|
|
1341
1308
|
// Get the latest state values after connection
|
|
@@ -1343,25 +1310,20 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
1343
1310
|
currentHitAddress = hitAddressRef.current || hitAddress;
|
|
1344
1311
|
// Double check that we have the required state
|
|
1345
1312
|
if (!currentSigner || !currentHitAddress) {
|
|
1346
|
-
console.log('State not updated yet, waiting more...');
|
|
1347
1313
|
await new Promise(resolve => setTimeout(resolve, 1500));
|
|
1348
1314
|
currentSigner = signerRef.current || signer;
|
|
1349
1315
|
currentHitAddress = hitAddressRef.current || hitAddress;
|
|
1350
1316
|
}
|
|
1351
|
-
console.log('Trying to sign in...');
|
|
1352
1317
|
try {
|
|
1353
1318
|
await signInWallet(false); // Don't show success message yet
|
|
1354
|
-
console.log('Auto sign-in successful, continuing with AIT enable...');
|
|
1355
1319
|
}
|
|
1356
1320
|
catch (signInError) {
|
|
1357
|
-
console.log('Auto sign-in failed:', signInError);
|
|
1358
1321
|
showError('Wallet connected but sign-in failed. Please try signing in manually.');
|
|
1359
1322
|
setIsAITEnabling(false);
|
|
1360
1323
|
return false;
|
|
1361
1324
|
}
|
|
1362
1325
|
}
|
|
1363
1326
|
else {
|
|
1364
|
-
console.log('Auto-connect failed');
|
|
1365
1327
|
showError('Please connect your wallet first');
|
|
1366
1328
|
setIsAITEnabling(false);
|
|
1367
1329
|
return false;
|
|
@@ -1378,19 +1340,16 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
1378
1340
|
setIsAITEnabling(false);
|
|
1379
1341
|
return false;
|
|
1380
1342
|
}
|
|
1381
|
-
console.log('Proceeding with AIT creation - Signer:', !!currentSigner, 'Address:', currentHitAddress);
|
|
1382
1343
|
// If we don't have AIT loaded but we have a token, try to refresh it first
|
|
1383
1344
|
if (!aitRef.current && nxtlinqAITServiceAccessToken) {
|
|
1384
|
-
console.log('No AIT loaded but have token, attempting to refresh AIT...');
|
|
1385
1345
|
try {
|
|
1386
1346
|
await refreshAIT();
|
|
1387
1347
|
// Wait a bit for AIT to be loaded
|
|
1388
1348
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
1389
|
-
console.log('AIT refresh completed, current AIT:', !!aitRef.current);
|
|
1390
1349
|
}
|
|
1391
1350
|
catch (error) {
|
|
1392
|
-
console.log('Failed to refresh AIT:', error);
|
|
1393
1351
|
// Continue anyway, we'll create a new AIT if needed
|
|
1352
|
+
console.error('Failed to refresh AIT:', error);
|
|
1394
1353
|
}
|
|
1395
1354
|
}
|
|
1396
1355
|
try {
|
|
@@ -1401,15 +1360,16 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
|
|
|
1401
1360
|
setIsAITEnabling(false);
|
|
1402
1361
|
return false;
|
|
1403
1362
|
}
|
|
1404
|
-
//
|
|
1405
|
-
|
|
1363
|
+
// Get current permissions from AIT metadata instead of React state
|
|
1364
|
+
// This ensures we don't lose existing permissions when enabling new ones
|
|
1365
|
+
const currentAITPermissions = aitRef.current?.metadata?.permissions || permissions;
|
|
1366
|
+
const newPermissions = [...currentAITPermissions];
|
|
1406
1367
|
if (!newPermissions.includes(toolName)) {
|
|
1407
1368
|
newPermissions.push(toolName);
|
|
1408
1369
|
}
|
|
1409
1370
|
// Generate and register AIT with new permissions
|
|
1410
1371
|
// For auto-enable, we should create a regular AIT (not AI Agent AIT) if user doesn't have existing AIT
|
|
1411
1372
|
const shouldCreateAsAIAgent = !!aitRef.current; // Only create as AI Agent if user already has an AIT
|
|
1412
|
-
console.log('Creating AIT - isFromAIAgent:', shouldCreateAsAIAgent, 'existing AIT:', !!aitRef.current);
|
|
1413
1373
|
await generateAndRegisterAITWithSigner(newPermissions, shouldCreateAsAIAgent, currentSigner, currentHitAddress);
|
|
1414
1374
|
showSuccess('AIT permission enabled successfully! You can now use the AI agent.');
|
|
1415
1375
|
await refreshAIT(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BerifyMeModal.d.ts","sourceRoot":"","sources":["../../../src/components/ui/BerifyMeModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"BerifyMeModal.d.ts","sourceRoot":"","sources":["../../../src/components/ui/BerifyMeModal.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,KAA4B,MAAM,OAAO,CAAC;AAIjD,UAAU,kBAAkB;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,sBAAsB,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;CAChC;AASD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAsHtD,CAAC;AAGF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,WAAW,CAAC,EAAE;YACZ,KAAK,EAAE,GAAG,CAAC;YACX,WAAW,EAAE;gBACX,OAAO,EAAE,GAAG,CAAC;gBACb,UAAU,EAAE,GAAG,CAAC;aACjB,CAAC;SACH,CAAC;KACH;CACF"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
2
3
|
import React, { useEffect, useRef } from 'react';
|
|
4
|
+
import { css } from '@emotion/react';
|
|
5
|
+
import { modalOverlay } from './styles/isolatedStyles';
|
|
3
6
|
// Built-in BerifyMe configuration
|
|
4
7
|
const BUILT_IN_BERIFYME_CONFIG = {
|
|
5
8
|
apiKeyId: 'staging_83dc824cb50b4e76747e352b4228f2ee',
|
|
@@ -102,13 +105,8 @@ export const BerifyMeModal = ({ isOpen, onClose, onVerificationComplete, mode =
|
|
|
102
105
|
};
|
|
103
106
|
if (!isOpen)
|
|
104
107
|
return null;
|
|
105
|
-
return (_jsx("div", { ref: modalRef,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
width: '100%',
|
|
110
|
-
height: '100%',
|
|
111
|
-
zIndex: 9999,
|
|
112
|
-
backgroundColor: 'rgba(0, 0, 0, 0.5)'
|
|
113
|
-
} }));
|
|
108
|
+
return (_jsx("div", { ref: modalRef, css: css `
|
|
109
|
+
${modalOverlay}
|
|
110
|
+
z-index: 9999 !important;
|
|
111
|
+
` }));
|
|
114
112
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBotUI.d.ts","sourceRoot":"","sources":["../../../src/components/ui/ChatBotUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatBotUI.d.ts","sourceRoot":"","sources":["../../../src/components/ui/ChatBotUI.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAyF/B,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAkU7B,CAAC"}
|