@bytexbyte/nxtlinq-ai-agent-ui-react-development 0.3.4 → 0.4.0

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/context/ChatBotContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAyB/B,OAAO,EAEL,kBAAkB,EAClB,YAAY,EAEb,MAAM,uBAAuB,CAAC;AAM/B,eAAO,MAAM,UAAU,0BAMtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA4vGlD,CAAC"}
1
+ {"version":3,"file":"ChatBotContext.d.ts","sourceRoot":"","sources":["../../src/context/ChatBotContext.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAyB/B,OAAO,EAEL,kBAAkB,EAClB,YAAY,EAEb,MAAM,uBAAuB,CAAC;AAM/B,eAAO,MAAM,UAAU,0BAMtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAwvGlD,CAAC"}
@@ -2481,10 +2481,8 @@ piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary
2481
2481
  if (isFromAIAgent && !aitRef.current) {
2482
2482
  throw new Error('You must have an existing AIT before AI Agent can create new AITs');
2483
2483
  }
2484
- // aitId is assigned by AIT-Service (UUIDv7) and returned in the response. It must not be
2485
- // minted here: the client cannot guarantee uniqueness, and this value feeds parentAITId, which
2486
- // is part of the on-chain commitment -- a locally invented id would anchor a parent that does
2487
- // not exist.
2484
+ const timestamp = Math.floor(Date.now() / 1000);
2485
+ const aitId = `did:polygon:nxtlinq:${currentAddress}:${timestamp}`;
2488
2486
  const metadata = {
2489
2487
  permissions: newPermissions || permissions,
2490
2488
  issuedBy: currentAddress,
@@ -2492,14 +2490,17 @@ piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary
2492
2490
  const metadataStr = stringify(metadata);
2493
2491
  // ethers v6: utils.keccak256 -> keccak256, utils.toUtf8Bytes -> toUtf8Bytes
2494
2492
  const metadataHash = ethers.keccak256(ethers.toUtf8Bytes(metadataStr));
2495
- // AIT-Service no longer publishes metadata to IPFS: the registry is hash-only, integrity comes
2496
- // from the on-chain commitment, and /api/metadata has been removed. `permissions` now travels
2497
- // in the request body instead of being recovered from a CID, so nothing is uploaded here.
2493
+ const uploadResponse = await nxtlinqApi.metadata.createMetadata(metadata, nxtlinqAITServiceAccessToken || '');
2494
+ if ('error' in uploadResponse) {
2495
+ throw new Error(`Failed to upload metadata: ${uploadResponse.error}`);
2496
+ }
2497
+ const { metadataCid } = uploadResponse;
2498
2498
  const createAITParams = {
2499
+ aitId,
2499
2500
  controller: currentAddress,
2500
2501
  serviceId,
2501
- permissions: metadata.permissions,
2502
2502
  metadataHash,
2503
+ metadataCid,
2503
2504
  isFromAIAgent: isFromAIAgent,
2504
2505
  parentAITId: isFromAIAgent ? aitRef.current?.aitId : undefined,
2505
2506
  };
@@ -2507,17 +2508,12 @@ piiDisplayMode = 'redacted', voiceThresholds, debugVoiceRms = false, sttGlossary
2507
2508
  if ('error' in createAITResponse) {
2508
2509
  throw new Error(`Failed to create AIT: ${createAITResponse.error}`);
2509
2510
  }
2510
- const aitId = createAITResponse.aitId;
2511
- if (!aitId) {
2512
- // Surfaced rather than substituted: this id becomes parentAITId on agent-created AITs, and
2513
- // parentAITId is committed on chain. Guessing one would anchor a dangling parent link.
2514
- throw new Error('AIT-Service did not return an aitId; refusing to invent one.');
2515
- }
2516
2511
  const aitInfo = {
2517
2512
  aitId,
2518
2513
  controller: currentAddress,
2519
2514
  metadata,
2520
2515
  metadataHash,
2516
+ metadataCid,
2521
2517
  };
2522
2518
  setAit(aitInfo);
2523
2519
  setPermissions(newPermissions || permissions);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytexbyte/nxtlinq-ai-agent-ui-react-development",
3
- "version": "0.3.4",
3
+ "version": "0.4.0",
4
4
  "description": "Official React Web UI for nxtlinq AI Agent — drop-in chat widget",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@bytexbyte/nxtlinq-ai-agent-core-development": "0.5.0",
42
- "@bytexbyte/nxtlinq-ai-agent-web-development": "0.3.2",
42
+ "@bytexbyte/nxtlinq-ai-agent-web-development": "0.4.0",
43
43
  "@emotion/react": "^11.14.0",
44
44
  "@emotion/styled": "^11.14.1",
45
45
  "@mui/icons-material": "^7.2.0",
@@ -2767,10 +2767,8 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
2767
2767
  throw new Error('You must have an existing AIT before AI Agent can create new AITs');
2768
2768
  }
2769
2769
 
2770
- // aitId is assigned by AIT-Service (UUIDv7) and returned in the response. It must not be
2771
- // minted here: the client cannot guarantee uniqueness, and this value feeds parentAITId, which
2772
- // is part of the on-chain commitment -- a locally invented id would anchor a parent that does
2773
- // not exist.
2770
+ const timestamp = Math.floor(Date.now() / 1000);
2771
+ const aitId = `did:polygon:nxtlinq:${currentAddress}:${timestamp}`;
2774
2772
 
2775
2773
  const metadata = {
2776
2774
  permissions: newPermissions || permissions,
@@ -2781,15 +2779,19 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
2781
2779
  // ethers v6: utils.keccak256 -> keccak256, utils.toUtf8Bytes -> toUtf8Bytes
2782
2780
  const metadataHash = ethers.keccak256(ethers.toUtf8Bytes(metadataStr));
2783
2781
 
2784
- // AIT-Service no longer publishes metadata to IPFS: the registry is hash-only, integrity comes
2785
- // from the on-chain commitment, and /api/metadata has been removed. `permissions` now travels
2786
- // in the request body instead of being recovered from a CID, so nothing is uploaded here.
2782
+ const uploadResponse = await nxtlinqApi.metadata.createMetadata(metadata, nxtlinqAITServiceAccessToken || '');
2783
+ if ('error' in uploadResponse) {
2784
+ throw new Error(`Failed to upload metadata: ${uploadResponse.error}`);
2785
+ }
2786
+
2787
+ const { metadataCid } = uploadResponse;
2787
2788
 
2788
2789
  const createAITParams = {
2790
+ aitId,
2789
2791
  controller: currentAddress,
2790
2792
  serviceId,
2791
- permissions: metadata.permissions,
2792
2793
  metadataHash,
2794
+ metadataCid,
2793
2795
  isFromAIAgent: isFromAIAgent,
2794
2796
  parentAITId: isFromAIAgent ? aitRef.current?.aitId : undefined,
2795
2797
  };
@@ -2800,18 +2802,12 @@ export const ChatBotProvider: React.FC<ChatBotProps> = ({
2800
2802
  throw new Error(`Failed to create AIT: ${createAITResponse.error}`);
2801
2803
  }
2802
2804
 
2803
- const aitId = (createAITResponse as { aitId?: string }).aitId;
2804
- if (!aitId) {
2805
- // Surfaced rather than substituted: this id becomes parentAITId on agent-created AITs, and
2806
- // parentAITId is committed on chain. Guessing one would anchor a dangling parent link.
2807
- throw new Error('AIT-Service did not return an aitId; refusing to invent one.');
2808
- }
2809
-
2810
2805
  const aitInfo = {
2811
2806
  aitId,
2812
2807
  controller: currentAddress,
2813
2808
  metadata,
2814
2809
  metadataHash,
2810
+ metadataCid,
2815
2811
  };
2816
2812
 
2817
2813
  setAit(aitInfo);