@bytexbyte/nxtlinq-ai-agent-sdk 1.5.5 → 1.5.6
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.
|
@@ -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,CAqvDlD,CAAC"}
|
|
@@ -387,7 +387,7 @@ requireWalletIDVVerification = true }) => {
|
|
|
387
387
|
}
|
|
388
388
|
};
|
|
389
389
|
// Check permissions
|
|
390
|
-
const hasPermission = async (toolName, autoRetry = true, onAutoConnect) => {
|
|
390
|
+
const hasPermission = async (toolName, autoRetry = true, onAutoConnect, onAutoSignIn) => {
|
|
391
391
|
// Use refs to get latest state values
|
|
392
392
|
const currentHitAddress = hitAddressRef.current;
|
|
393
393
|
const currentAit = aitRef.current;
|
|
@@ -423,6 +423,7 @@ requireWalletIDVVerification = true }) => {
|
|
|
423
423
|
if (!tokenAfterConnect) {
|
|
424
424
|
setIsAutoConnecting(true);
|
|
425
425
|
await signInWallet(false);
|
|
426
|
+
onAutoSignIn?.(); // Call callback if provided
|
|
426
427
|
setIsAutoConnecting(false);
|
|
427
428
|
showSuccess('Auto sign-in successful after wallet connect');
|
|
428
429
|
await refreshAIT();
|
|
@@ -462,6 +463,7 @@ requireWalletIDVVerification = true }) => {
|
|
|
462
463
|
setIsAutoConnecting(true); // Mark as auto-signing
|
|
463
464
|
console.log('Starting auto sign-in...');
|
|
464
465
|
await signInWallet(false); // Don't show success message yet
|
|
466
|
+
onAutoSignIn?.(); // Call callback if provided
|
|
465
467
|
console.log('Auto sign-in completed');
|
|
466
468
|
setIsAutoConnecting(false); // Clear auto-signing state
|
|
467
469
|
// Show brief success message for auto-sign-in
|
|
@@ -516,6 +518,7 @@ requireWalletIDVVerification = true }) => {
|
|
|
516
518
|
try {
|
|
517
519
|
setIsAutoConnecting(true); // Mark as auto-signing
|
|
518
520
|
await signInWallet(false); // Don't show success message yet
|
|
521
|
+
onAutoSignIn?.(); // Call callback if provided
|
|
519
522
|
setIsAutoConnecting(false); // Clear auto-signing state
|
|
520
523
|
// Show brief success message for auto-sign-in after session expiry
|
|
521
524
|
showSuccess('Auto sign-in successful after session expiry');
|
|
@@ -566,6 +569,7 @@ requireWalletIDVVerification = true }) => {
|
|
|
566
569
|
try {
|
|
567
570
|
setIsAutoConnecting(true); // Mark as auto-signing
|
|
568
571
|
await signInWallet(false); // Don't show success message yet
|
|
572
|
+
onAutoSignIn?.(); // Call callback if provided
|
|
569
573
|
setIsAutoConnecting(false); // Clear auto-signing state
|
|
570
574
|
// Show brief success message for auto-sign-in after address mismatch
|
|
571
575
|
showSuccess('Auto sign-in successful after address mismatch');
|
|
@@ -617,6 +621,7 @@ requireWalletIDVVerification = true }) => {
|
|
|
617
621
|
try {
|
|
618
622
|
setIsAutoConnecting(true); // Mark as auto-signing
|
|
619
623
|
await signInWallet(false); // Don't show success message yet
|
|
624
|
+
onAutoSignIn?.(); // Call callback if provided
|
|
620
625
|
setIsAutoConnecting(false); // Clear auto-signing state
|
|
621
626
|
// Show brief success message for auto-sign-in after token parse error
|
|
622
627
|
showSuccess('Auto sign-in successful after token error');
|
|
@@ -859,17 +864,18 @@ requireWalletIDVVerification = true }) => {
|
|
|
859
864
|
await signInWallet(false); // Don't show success message yet
|
|
860
865
|
console.log('Auto sign-in successful, retrying message...');
|
|
861
866
|
// Wait a bit for everything to settle
|
|
862
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
867
|
+
// await new Promise(resolve => setTimeout(resolve, 2000));
|
|
863
868
|
// // Retry the message
|
|
864
869
|
// sendMessage(content, retryCount + 1, isPresetMessage);
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
870
|
+
setIsLoading(false);
|
|
871
|
+
setMessages(prev => [...prev, {
|
|
872
|
+
id: Date.now().toString(),
|
|
873
|
+
content: 'Click button to continue using tool',
|
|
874
|
+
role: 'assistant',
|
|
875
|
+
timestamp: new Date().toISOString(),
|
|
876
|
+
button: 'continue'
|
|
877
|
+
}]);
|
|
878
|
+
return;
|
|
873
879
|
}
|
|
874
880
|
catch (signInError) {
|
|
875
881
|
console.log('Auto sign-in failed, showing error message');
|
|
@@ -937,68 +943,33 @@ requireWalletIDVVerification = true }) => {
|
|
|
937
943
|
let toolMsg = '';
|
|
938
944
|
if (onToolUse) {
|
|
939
945
|
let wasAutoConnected = false;
|
|
946
|
+
let wasAutoSignedIn = false;
|
|
940
947
|
// Added: Mark if permission denied due to missing AIT permission
|
|
941
948
|
let permissionDenied = false;
|
|
942
|
-
const isToolAllowed = await hasPermission(toolUse.name, true, () => {
|
|
943
|
-
wasAutoConnected = true;
|
|
944
|
-
});
|
|
949
|
+
const isToolAllowed = await hasPermission(toolUse.name, true, () => { wasAutoConnected = true; }, () => { wasAutoSignedIn = true; });
|
|
945
950
|
// If currentPermissions does not include toolName and availablePermissionLabels includes toolName, it means AIT permission is missing
|
|
946
951
|
if (!isToolAllowed && !permissions.includes(toolUse.name) && availablePermissions.map(p => p.label).includes(toolUse.name)) {
|
|
947
952
|
permissionDenied = true;
|
|
948
953
|
}
|
|
949
954
|
if (!isToolAllowed) {
|
|
955
|
+
setIsLoading(false);
|
|
950
956
|
// If permission denied due to missing AIT permission return
|
|
951
957
|
if (permissionDenied) {
|
|
952
|
-
setIsLoading(false);
|
|
953
958
|
return;
|
|
954
959
|
}
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
console.log('Wallet connected but not signed in, retrying message directly');
|
|
965
|
-
setTimeout(() => {
|
|
966
|
-
sendMessage(content, retryCount + 1, isPresetMessage);
|
|
967
|
-
}, 2000);
|
|
968
|
-
}
|
|
969
|
-
else {
|
|
970
|
-
// If already signed in, wait for AIT to be fully loaded before retrying
|
|
971
|
-
setTimeout(async () => {
|
|
972
|
-
// Wait for AIT to be loaded if needed
|
|
973
|
-
if (!aitRef.current && nxtlinqAITServiceAccessTokenRef.current) {
|
|
974
|
-
await refreshAIT();
|
|
975
|
-
}
|
|
976
|
-
// Wait for AIT to be fully loaded with polling
|
|
977
|
-
let attempts = 0;
|
|
978
|
-
const maxAttempts = 5; // Wait up to 10 seconds (5 * 2000ms)
|
|
979
|
-
while (!aitRef.current && attempts < maxAttempts) {
|
|
980
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
981
|
-
attempts++;
|
|
982
|
-
}
|
|
983
|
-
// Only retry if AIT is actually loaded
|
|
984
|
-
if (aitRef.current) {
|
|
985
|
-
console.log('AIT loaded successfully, retrying message');
|
|
986
|
-
// Wait a bit more to ensure permissions are also loaded
|
|
987
|
-
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
988
|
-
sendMessage(content, retryCount + 1, isPresetMessage);
|
|
989
|
-
}
|
|
990
|
-
else {
|
|
991
|
-
console.log('AIT failed to load, not retrying');
|
|
992
|
-
}
|
|
993
|
-
}, 2000);
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
else {
|
|
997
|
-
console.log('Permission denied, not retrying. wasAutoConnected:', wasAutoConnected, 'retryCount:', retryCount);
|
|
960
|
+
if (wasAutoSignedIn) {
|
|
961
|
+
setMessages(prev => [...prev, {
|
|
962
|
+
id: Date.now().toString(),
|
|
963
|
+
content: 'Click button to continue using tool',
|
|
964
|
+
role: 'assistant',
|
|
965
|
+
timestamp: new Date().toISOString(),
|
|
966
|
+
button: 'continue'
|
|
967
|
+
}]);
|
|
968
|
+
return;
|
|
998
969
|
}
|
|
999
970
|
return;
|
|
1000
971
|
}
|
|
1001
|
-
if (
|
|
972
|
+
if (wasAutoSignedIn) {
|
|
1002
973
|
setIsLoading(false);
|
|
1003
974
|
setMessages(prev => [...prev, {
|
|
1004
975
|
id: Date.now().toString(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MessageList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MessageList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAuM/B,CAAC"}
|
|
@@ -88,17 +88,15 @@ export const MessageList = () => {
|
|
|
88
88
|
color: message.role === 'user' ? 'white' : 'white',
|
|
89
89
|
border: 'none',
|
|
90
90
|
borderRadius: '5px',
|
|
91
|
-
cursor: (isAutoConnecting ||
|
|
91
|
+
cursor: (message.button !== 'continue' && (isAutoConnecting ||
|
|
92
92
|
(message.button === 'connectWallet' && Boolean(hitAddress)) ||
|
|
93
93
|
(message.button === 'signIn' && !isNeedSignInWithWallet) ||
|
|
94
|
-
(message.button === 'continue') ||
|
|
95
94
|
(message.button === 'enableAIT' && (isAITLoading || isAITEnabling ||
|
|
96
|
-
(message.metadata?.toolName && permissions.includes(message.metadata.toolName))))) ? 'not-allowed' : 'pointer',
|
|
95
|
+
(message.metadata?.toolName && permissions.includes(message.metadata.toolName)))))) ? 'not-allowed' : 'pointer',
|
|
97
96
|
fontSize: '14px',
|
|
98
97
|
opacity: (isAutoConnecting ||
|
|
99
98
|
(message.button === 'connectWallet' && Boolean(hitAddress)) ||
|
|
100
99
|
(message.button === 'signIn' && !isNeedSignInWithWallet) ||
|
|
101
|
-
(message.button === 'continue') ||
|
|
102
100
|
(message.button === 'enableAIT' && (isAITLoading || isAITEnabling ||
|
|
103
101
|
(message.metadata?.toolName && permissions.includes(message.metadata.toolName))))) ? 0.8 : 1
|
|
104
102
|
}, children: isAutoConnecting ? 'Connecting...' :
|
package/package.json
CHANGED