@bytexbyte/nxtlinq-ai-agent-sdk 1.5.0 → 1.5.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/context/ChatBotContext.d.ts.map +1 -1
- package/dist/components/context/ChatBotContext.js +22 -51
- package/dist/components/ui/MessageList.d.ts.map +1 -1
- package/dist/components/ui/MessageList.js +19 -8
- package/package.json +2 -2
- package/dist/core/utils/__tests__/urlUtils.test.d.ts +0 -5
- package/dist/core/utils/__tests__/urlUtils.test.d.ts.map +0 -1
- package/dist/core/utils/__tests__/urlUtils.test.js +0 -57
- package/dist/setupTests.d.ts +0 -2
- package/dist/setupTests.d.ts.map +0 -1
- package/dist/setupTests.js +0 -16
|
@@ -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,CAwtDlD,CAAC"}
|
|
@@ -858,10 +858,17 @@ requireWalletIDVVerification = true }) => {
|
|
|
858
858
|
// Try to sign in wallet
|
|
859
859
|
await signInWallet(false); // Don't show success message yet
|
|
860
860
|
console.log('Auto sign-in successful, retrying message...');
|
|
861
|
-
// Wait a bit for everything to settle
|
|
862
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
863
|
-
// Retry the message
|
|
864
|
-
sendMessage(content, retryCount + 1, isPresetMessage);
|
|
861
|
+
// // Wait a bit for everything to settle
|
|
862
|
+
// await new Promise(resolve => setTimeout(resolve, 2000));
|
|
863
|
+
// // Retry the message
|
|
864
|
+
// sendMessage(content, retryCount + 1, isPresetMessage);
|
|
865
|
+
setMessages(prev => [...prev, {
|
|
866
|
+
id: Date.now().toString(),
|
|
867
|
+
content: 'Click button to continue tool',
|
|
868
|
+
role: 'assistant',
|
|
869
|
+
timestamp: new Date().toISOString(),
|
|
870
|
+
button: 'continue'
|
|
871
|
+
}]);
|
|
865
872
|
}
|
|
866
873
|
catch (signInError) {
|
|
867
874
|
console.log('Auto sign-in failed, showing error message');
|
|
@@ -939,54 +946,18 @@ requireWalletIDVVerification = true }) => {
|
|
|
939
946
|
permissionDenied = true;
|
|
940
947
|
}
|
|
941
948
|
if (!isToolAllowed) {
|
|
942
|
-
|
|
943
|
-
if (permissionDenied)
|
|
944
|
-
setIsLoading(false);
|
|
949
|
+
setIsLoading(false);
|
|
950
|
+
if (permissionDenied)
|
|
945
951
|
return;
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
// If not signed in, directly retry the message without waiting for AIT
|
|
956
|
-
console.log('Wallet connected but not signed in, retrying message directly');
|
|
957
|
-
setTimeout(() => {
|
|
958
|
-
sendMessage(content, retryCount + 1, isPresetMessage);
|
|
959
|
-
}, 2000);
|
|
960
|
-
}
|
|
961
|
-
else {
|
|
962
|
-
// If already signed in, wait for AIT to be fully loaded before retrying
|
|
963
|
-
setTimeout(async () => {
|
|
964
|
-
// Wait for AIT to be loaded if needed
|
|
965
|
-
if (!aitRef.current && nxtlinqAITServiceAccessTokenRef.current) {
|
|
966
|
-
await refreshAIT();
|
|
967
|
-
}
|
|
968
|
-
// Wait for AIT to be fully loaded with polling
|
|
969
|
-
let attempts = 0;
|
|
970
|
-
const maxAttempts = 5; // Wait up to 10 seconds (5 * 2000ms)
|
|
971
|
-
while (!aitRef.current && attempts < maxAttempts) {
|
|
972
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
973
|
-
attempts++;
|
|
974
|
-
}
|
|
975
|
-
// Only retry if AIT is actually loaded
|
|
976
|
-
if (aitRef.current) {
|
|
977
|
-
console.log('AIT loaded successfully, retrying message');
|
|
978
|
-
// Wait a bit more to ensure permissions are also loaded
|
|
979
|
-
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
980
|
-
sendMessage(content, retryCount + 1, isPresetMessage);
|
|
981
|
-
}
|
|
982
|
-
else {
|
|
983
|
-
console.log('AIT failed to load, not retrying');
|
|
984
|
-
}
|
|
985
|
-
}, 2000);
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
else {
|
|
989
|
-
console.log('Permission denied, not retrying. wasAutoConnected:', wasAutoConnected, 'retryCount:', retryCount);
|
|
952
|
+
if (wasAutoConnected) {
|
|
953
|
+
// ✅ 不自動重試,改成丟出一顆 Continue
|
|
954
|
+
setMessages(prev => [...prev, {
|
|
955
|
+
id: Date.now().toString(),
|
|
956
|
+
content: 'Click button to continue tool',
|
|
957
|
+
role: 'assistant',
|
|
958
|
+
timestamp: new Date().toISOString(),
|
|
959
|
+
button: 'continue'
|
|
960
|
+
}]);
|
|
990
961
|
}
|
|
991
962
|
return;
|
|
992
963
|
}
|
|
@@ -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,EAyM/B,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { convertUrlsToLinks } from '../../core/utils/urlUtils';
|
|
3
4
|
import { useChatBot } from '../context/ChatBotContext';
|
|
4
5
|
import { AI_MODEL_MAP } from '../types/ChatBotTypes';
|
|
5
|
-
import { convertUrlsToLinks } from '../../core/utils/urlUtils';
|
|
6
6
|
export const MessageList = () => {
|
|
7
7
|
const { messages, isLoading, connectWallet, signInWallet, hitAddress, ait, setShowPermissionForm, isWalletLoading, isAutoConnecting, isNeedSignInWithWallet, enableAIT, isAITLoading, isAITEnabling, sendMessage, permissions } = useChatBot();
|
|
8
8
|
const messagesEndRef = React.useRef(null);
|
|
@@ -33,6 +33,13 @@ export const MessageList = () => {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
else if (buttonType === 'continue') {
|
|
37
|
+
const lastUserMsg = [...messages].reverse().find(m => m.role === 'user');
|
|
38
|
+
if (lastUserMsg && lastUserMsg.content) {
|
|
39
|
+
// Re-execute the previous user message
|
|
40
|
+
await sendMessage(lastUserMsg.content);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
36
43
|
};
|
|
37
44
|
const getModelDisplayName = (modelValue) => {
|
|
38
45
|
if (!modelValue)
|
|
@@ -74,30 +81,34 @@ export const MessageList = () => {
|
|
|
74
81
|
isAutoConnecting ? '#6c757d' :
|
|
75
82
|
(message.button === 'connectWallet' && Boolean(hitAddress)) ? '#28a745' :
|
|
76
83
|
(message.button === 'signIn' && !isNeedSignInWithWallet) ? '#28a745' :
|
|
77
|
-
(message.button === '
|
|
78
|
-
(message.
|
|
79
|
-
|
|
84
|
+
(message.button === 'continue') ? '#28a745' :
|
|
85
|
+
(message.button === 'enableAIT' && (isAITLoading || isAITEnabling ||
|
|
86
|
+
(message.metadata?.toolName && permissions.includes(message.metadata.toolName)))) ?
|
|
87
|
+
((message.metadata?.toolName && permissions.includes(message.metadata.toolName)) ? '#28a745' : '#6c757d') : '#007bff',
|
|
80
88
|
color: message.role === 'user' ? 'white' : 'white',
|
|
81
89
|
border: 'none',
|
|
82
90
|
borderRadius: '5px',
|
|
83
91
|
cursor: (isAutoConnecting ||
|
|
84
92
|
(message.button === 'connectWallet' && Boolean(hitAddress)) ||
|
|
85
93
|
(message.button === 'signIn' && !isNeedSignInWithWallet) ||
|
|
94
|
+
(message.button === 'continue') ||
|
|
86
95
|
(message.button === 'enableAIT' && (isAITLoading || isAITEnabling ||
|
|
87
96
|
(message.metadata?.toolName && permissions.includes(message.metadata.toolName))))) ? 'not-allowed' : 'pointer',
|
|
88
97
|
fontSize: '14px',
|
|
89
98
|
opacity: (isAutoConnecting ||
|
|
90
99
|
(message.button === 'connectWallet' && Boolean(hitAddress)) ||
|
|
91
100
|
(message.button === 'signIn' && !isNeedSignInWithWallet) ||
|
|
101
|
+
(message.button === 'continue') ||
|
|
92
102
|
(message.button === 'enableAIT' && (isAITLoading || isAITEnabling ||
|
|
93
103
|
(message.metadata?.toolName && permissions.includes(message.metadata.toolName))))) ? 0.8 : 1
|
|
94
104
|
}, children: isAutoConnecting ? 'Connecting...' :
|
|
95
105
|
message.button === 'connectWallet' ? (Boolean(hitAddress) ? 'Connected' : 'Connect Wallet') :
|
|
96
106
|
message.button === 'signIn' ? (!isNeedSignInWithWallet ? 'Signed In' : 'Sign In') :
|
|
97
|
-
message.button === '
|
|
98
|
-
|
|
99
|
-
(
|
|
100
|
-
|
|
107
|
+
message.button === 'continue' ? 'Continue' :
|
|
108
|
+
message.button === 'enableAIT' ?
|
|
109
|
+
((isAITLoading || isAITEnabling) ? 'Enabling...' :
|
|
110
|
+
(message.metadata?.toolName && permissions.includes(message.metadata.toolName)) ? 'AIT Enabled' : 'Enable AIT Permissions') :
|
|
111
|
+
message.button }) }))] }), message.role === 'assistant' && message.metadata?.model && (_jsx("div", { style: {
|
|
101
112
|
display: 'flex',
|
|
102
113
|
alignItems: 'center',
|
|
103
114
|
marginTop: '4px',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytexbyte/nxtlinq-ai-agent-sdk",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Nxtlinq AI Agent SDK - Proprietary Software with enhanced async operation handling",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -59,4 +59,4 @@
|
|
|
59
59
|
"universal-cookie": "^8.0.1",
|
|
60
60
|
"uuid": "^11.1.0"
|
|
61
61
|
}
|
|
62
|
-
}
|
|
62
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"urlUtils.test.d.ts","sourceRoot":"","sources":["../../../../src/core/utils/__tests__/urlUtils.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for URL utility functions
|
|
3
|
-
*/
|
|
4
|
-
import { containsUrls, convertUrlsToLinks, convertUrlsToHtml } from '../urlUtils';
|
|
5
|
-
describe('URL Utils', () => {
|
|
6
|
-
describe('containsUrls', () => {
|
|
7
|
-
it('should detect URLs with http protocol', () => {
|
|
8
|
-
expect(containsUrls('Visit https://example.com for more info')).toBe(true);
|
|
9
|
-
expect(containsUrls('Check out http://test.org')).toBe(true);
|
|
10
|
-
});
|
|
11
|
-
it('should detect URLs with www', () => {
|
|
12
|
-
expect(containsUrls('Go to www.google.com')).toBe(true);
|
|
13
|
-
expect(containsUrls('Visit www.example.org')).toBe(true);
|
|
14
|
-
});
|
|
15
|
-
it('should detect domain names', () => {
|
|
16
|
-
expect(containsUrls('Contact us at support@company.com')).toBe(false);
|
|
17
|
-
expect(containsUrls('Visit company.com for details')).toBe(true);
|
|
18
|
-
});
|
|
19
|
-
it('should return false for text without URLs', () => {
|
|
20
|
-
expect(containsUrls('This is just plain text')).toBe(false);
|
|
21
|
-
expect(containsUrls('No URLs here')).toBe(false);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
describe('convertUrlsToHtml', () => {
|
|
25
|
-
it('should convert URLs to HTML anchor tags', () => {
|
|
26
|
-
const text = 'Visit https://example.com for more info';
|
|
27
|
-
const result = convertUrlsToHtml(text);
|
|
28
|
-
expect(result).toContain('<a href="https://example.com"');
|
|
29
|
-
expect(result).toContain('target="_blank"');
|
|
30
|
-
expect(result).toContain('rel="noopener noreferrer"');
|
|
31
|
-
});
|
|
32
|
-
it('should handle www URLs', () => {
|
|
33
|
-
const text = 'Go to www.google.com';
|
|
34
|
-
const result = convertUrlsToHtml(text);
|
|
35
|
-
expect(result).toContain('<a href="https://www.google.com"');
|
|
36
|
-
});
|
|
37
|
-
it('should handle multiple URLs', () => {
|
|
38
|
-
const text = 'Visit https://example.com and www.google.com';
|
|
39
|
-
const result = convertUrlsToHtml(text);
|
|
40
|
-
expect(result).toContain('https://example.com');
|
|
41
|
-
expect(result).toContain('https://www.google.com');
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
describe('convertUrlsToLinks', () => {
|
|
45
|
-
it('should return array with mixed content', () => {
|
|
46
|
-
const text = 'Visit https://example.com for more info';
|
|
47
|
-
const result = convertUrlsToLinks(text);
|
|
48
|
-
expect(Array.isArray(result)).toBe(true);
|
|
49
|
-
expect(result.length).toBeGreaterThan(0);
|
|
50
|
-
});
|
|
51
|
-
it('should handle text without URLs', () => {
|
|
52
|
-
const text = 'This is just plain text';
|
|
53
|
-
const result = convertUrlsToLinks(text);
|
|
54
|
-
expect(result).toEqual([text]);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
package/dist/setupTests.d.ts
DELETED
package/dist/setupTests.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setupTests.d.ts","sourceRoot":"","sources":["../src/setupTests.ts"],"names":[],"mappings":"AACA,OAAO,2BAA2B,CAAC"}
|
package/dist/setupTests.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// Test setup file for Jest
|
|
2
|
-
import '@testing-library/jest-dom';
|
|
3
|
-
// Mock window.open for URL tests
|
|
4
|
-
Object.defineProperty(window, 'open', {
|
|
5
|
-
writable: true,
|
|
6
|
-
value: jest.fn(),
|
|
7
|
-
});
|
|
8
|
-
// Mock console methods to avoid noise in tests
|
|
9
|
-
global.console = {
|
|
10
|
-
...console,
|
|
11
|
-
log: jest.fn(),
|
|
12
|
-
debug: jest.fn(),
|
|
13
|
-
info: jest.fn(),
|
|
14
|
-
warn: jest.fn(),
|
|
15
|
-
error: jest.fn(),
|
|
16
|
-
};
|