@bytexbyte/nxtlinq-ai-agent-sdk 1.3.4 → 1.3.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;AAO/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;AAO/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,CA4+ClD,CAAC"}
|
|
@@ -155,6 +155,11 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
155
155
|
}
|
|
156
156
|
else {
|
|
157
157
|
console.log('Failed to get wallet info:', walletResponse.error);
|
|
158
|
+
// Check if the error is due to invalid/expired token
|
|
159
|
+
if (walletResponse.error.includes('Invalid or expired token')) {
|
|
160
|
+
console.log('Token appears to be invalid during wallet info fetch, clearing it');
|
|
161
|
+
setNxtlinqAITServiceAccessToken('');
|
|
162
|
+
}
|
|
158
163
|
}
|
|
159
164
|
}
|
|
160
165
|
catch (error) {
|
|
@@ -229,9 +234,29 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
229
234
|
localStorage.setItem('walletAddress', userAddress);
|
|
230
235
|
setHitAddress(userAddress);
|
|
231
236
|
setSigner(userSigner);
|
|
232
|
-
//
|
|
237
|
+
// Check if we have a valid token before trying to load AIT
|
|
233
238
|
if (nxtlinqAITServiceAccessToken) {
|
|
234
|
-
|
|
239
|
+
try {
|
|
240
|
+
const payload = JSON.parse(atob(nxtlinqAITServiceAccessToken.split('.')[1]));
|
|
241
|
+
const exp = payload.exp * 1000;
|
|
242
|
+
const now = Date.now();
|
|
243
|
+
const address = payload.address;
|
|
244
|
+
// Check if token is expired or address mismatch
|
|
245
|
+
if (exp < now || address !== userAddress) {
|
|
246
|
+
console.log('Token is expired or address mismatch, clearing token');
|
|
247
|
+
setNxtlinqAITServiceAccessToken('');
|
|
248
|
+
// Don't call refreshAIT with invalid token
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
// Token is valid, try to load AIT
|
|
252
|
+
await refreshAIT();
|
|
253
|
+
await sleep(1000);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
catch (error) {
|
|
257
|
+
console.error('Error parsing token during wallet connection:', error);
|
|
258
|
+
setNxtlinqAITServiceAccessToken('');
|
|
259
|
+
}
|
|
235
260
|
}
|
|
236
261
|
if (autoShowSignInMessage) {
|
|
237
262
|
if (isNeedSignInWithWallet) {
|
|
@@ -852,9 +877,9 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
852
877
|
if (response.reply) {
|
|
853
878
|
replyText = Array.isArray(response.reply)
|
|
854
879
|
? response.reply
|
|
855
|
-
.map((item) => item.text
|
|
880
|
+
.map((item) => item.text)
|
|
856
881
|
.join(' ') || ''
|
|
857
|
-
: response.reply
|
|
882
|
+
: response.reply || '';
|
|
858
883
|
}
|
|
859
884
|
else if (response.fullResponse?.output?.message?.content) {
|
|
860
885
|
replyText = response.fullResponse.output.message.content
|
|
@@ -867,6 +892,7 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
867
892
|
if (replyText && replyText.trim()) {
|
|
868
893
|
mergedContent += `\n\n${replyText}`;
|
|
869
894
|
}
|
|
895
|
+
updateSuggestions([...contextMessages, { role: 'assistant', text: mergedContent }]);
|
|
870
896
|
botResponse = {
|
|
871
897
|
id: (Date.now() + 1).toString(),
|
|
872
898
|
content: mergedContent,
|
|
@@ -884,9 +910,9 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
884
910
|
else if (response.reply) {
|
|
885
911
|
const replyText = Array.isArray(response.reply)
|
|
886
912
|
? response.reply
|
|
887
|
-
.map((item) => item.text
|
|
913
|
+
.map((item) => item.text)
|
|
888
914
|
.join(' ') || 'Sorry, I cannot understand your question'
|
|
889
|
-
: response.reply
|
|
915
|
+
: response.reply || 'Sorry, I cannot understand your question';
|
|
890
916
|
updateSuggestions([...contextMessages, { role: 'assistant', text: replyText }]);
|
|
891
917
|
botResponse = {
|
|
892
918
|
id: (Date.now() + 1).toString(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytexbyte/nxtlinq-ai-agent-sdk",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
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",
|
|
@@ -44,4 +44,4 @@
|
|
|
44
44
|
"microsoft-cognitiveservices-speech-sdk": "^1.45.0",
|
|
45
45
|
"universal-cookie": "^8.0.1"
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
}
|