@bytexbyte/nxtlinq-ai-agent-sdk 1.6.4 → 1.6.5

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,CA21DlD,CAAC"}
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,CAq5DlD,CAAC"}
@@ -190,6 +190,7 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
190
190
  setAit(null);
191
191
  setPermissions([]);
192
192
  setWalletInfo(null);
193
+ setIsAITLoading(false);
193
194
  return;
194
195
  }
195
196
  setIsAITLoading(true);
@@ -369,8 +370,27 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
369
370
  const currentHitAddress = hitAddressRef.current;
370
371
  const currentSigner = signerRef.current;
371
372
  // If refs don't have the values, try using current state values
372
- const addressToUse = currentHitAddress || hitAddress;
373
- const signerToUse = currentSigner || signer;
373
+ let addressToUse = currentHitAddress || hitAddress;
374
+ let signerToUse = currentSigner || signer;
375
+ // If we have an address but no signer, try to auto-connect wallet
376
+ if (addressToUse && !signerToUse) {
377
+ const storedWalletAddress = localStorage.getItem('walletAddress');
378
+ if (storedWalletAddress === addressToUse) {
379
+ try {
380
+ const autoConnectResult = await connectWallet(false); // Don't show sign-in message yet
381
+ if (autoConnectResult) {
382
+ // Wait for state to update
383
+ await new Promise(resolve => setTimeout(resolve, 1000));
384
+ // Get the updated signer
385
+ signerToUse = signerRef.current || signer;
386
+ addressToUse = hitAddressRef.current || hitAddress;
387
+ }
388
+ }
389
+ catch (error) {
390
+ console.error('Auto-connect failed during sign in:', error);
391
+ }
392
+ }
393
+ }
374
394
  if (!addressToUse) {
375
395
  console.log('No address available, returning early');
376
396
  if (autoShowSuccessMessage) {
@@ -1239,10 +1259,31 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
1239
1259
  };
1240
1260
  // Generate and register AIT
1241
1261
  const generateAndRegisterAIT = async (newPermissions, isFromAIAgent = false) => {
1242
- if (!signer || !hitAddress) {
1262
+ let currentSigner = signer;
1263
+ let currentAddress = hitAddress;
1264
+ // If we have an address but no signer, try to auto-connect wallet
1265
+ if (currentAddress && !currentSigner) {
1266
+ const storedWalletAddress = localStorage.getItem('walletAddress');
1267
+ if (storedWalletAddress === currentAddress) {
1268
+ try {
1269
+ const autoConnectResult = await connectWallet(false); // Don't show sign-in message yet
1270
+ if (autoConnectResult) {
1271
+ // Wait for state to update
1272
+ await new Promise(resolve => setTimeout(resolve, 1000));
1273
+ // Get the updated signer and address
1274
+ currentSigner = signerRef.current || signer;
1275
+ currentAddress = hitAddressRef.current || hitAddress;
1276
+ }
1277
+ }
1278
+ catch (error) {
1279
+ console.error('Auto-connect failed during AIT generation:', error);
1280
+ }
1281
+ }
1282
+ }
1283
+ if (!currentSigner || !currentAddress) {
1243
1284
  throw new Error('Missing signer or wallet address');
1244
1285
  }
1245
- return generateAndRegisterAITWithSigner(newPermissions, isFromAIAgent, signer, hitAddress);
1286
+ return generateAndRegisterAITWithSigner(newPermissions, isFromAIAgent, currentSigner, currentAddress);
1246
1287
  };
1247
1288
  // Generate and register AIT with explicit signer and address
1248
1289
  const generateAndRegisterAITWithSigner = async (newPermissions, isFromAIAgent = false, explicitSigner, explicitAddress) => {
@@ -1583,11 +1624,25 @@ idvBannerDismissSeconds = 86400 // 24 hours in seconds
1583
1624
  throw error;
1584
1625
  }
1585
1626
  };
1627
+ // Initialize wallet address from localStorage on component mount
1628
+ React.useEffect(() => {
1629
+ const storedWalletAddress = localStorage.getItem('walletAddress');
1630
+ if (storedWalletAddress && !hitAddress) {
1631
+ setHitAddress(storedWalletAddress);
1632
+ hitAddressRef.current = storedWalletAddress;
1633
+ }
1634
+ }, []);
1586
1635
  React.useEffect(() => {
1587
1636
  if (hitAddress && nxtlinqAITServiceAccessToken) {
1588
1637
  refreshAIT();
1589
1638
  }
1590
1639
  }, [hitAddress, nxtlinqAITServiceAccessToken]);
1640
+ // Set loading state when permission form opens
1641
+ React.useEffect(() => {
1642
+ if (isPermissionFormOpen && hitAddress) {
1643
+ setIsAITLoading(true);
1644
+ }
1645
+ }, [isPermissionFormOpen, hitAddress]);
1591
1646
  React.useEffect(() => {
1592
1647
  fetchAvailablePermissions();
1593
1648
  }, [serviceId, permissionGroup]);
@@ -1 +1 @@
1
- {"version":3,"file":"PermissionForm.d.ts","sourceRoot":"","sources":["../../../src/components/ui/PermissionForm.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,UAAU,mBAAmB;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAqiBxD,CAAC"}
1
+ {"version":3,"file":"PermissionForm.d.ts","sourceRoot":"","sources":["../../../src/components/ui/PermissionForm.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,UAAU,mBAAmB;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA2iBxD,CAAC"}
@@ -9,10 +9,13 @@ export const PermissionForm = ({ onClose }) => {
9
9
  const [availablePermissions, setAvailablePermissions] = React.useState([]);
10
10
  const [isSaving, setIsSaving] = React.useState(false);
11
11
  const [tempPermissions, setTempPermissions] = React.useState(permissions);
12
- // Update temp permissions when permissions change
12
+ const [hasUserInteracted, setHasUserInteracted] = React.useState(false);
13
+ // Update temp permissions when permissions change, but only if user hasn't interacted
13
14
  React.useEffect(() => {
14
- setTempPermissions(permissions);
15
- }, [permissions]);
15
+ if (!hasUserInteracted) {
16
+ setTempPermissions(permissions);
17
+ }
18
+ }, [permissions, hasUserInteracted]);
16
19
  const fetchAvailablePermissions = async () => {
17
20
  if (!serviceId)
18
21
  return;
@@ -64,6 +67,7 @@ export const PermissionForm = ({ onClose }) => {
64
67
  // Update the actual permissions with temp permissions
65
68
  setPermissions(tempPermissions);
66
69
  await onSave(tempPermissions);
70
+ setHasUserInteracted(false);
67
71
  }
68
72
  finally {
69
73
  setIsSaving(false);
@@ -72,6 +76,7 @@ export const PermissionForm = ({ onClose }) => {
72
76
  const handleCancel = () => {
73
77
  // Reset temp permissions to original permissions
74
78
  setTempPermissions(permissions);
79
+ setHasUserInteracted(false);
75
80
  onClose();
76
81
  };
77
82
  // Check if permissions have changed
@@ -339,6 +344,7 @@ export const PermissionForm = ({ onClose }) => {
339
344
  ? tempPermissions.filter(p => p !== permission.label)
340
345
  : [...tempPermissions, permission.label].sort();
341
346
  setTempPermissions(newPermissions);
347
+ setHasUserInteracted(true);
342
348
  setIsDisabled(false);
343
349
  }
344
350
  }, disabled: isAITLoading, css: css `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytexbyte/nxtlinq-ai-agent-sdk",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
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",