@bytexbyte/nxtlinq-ai-agent-sdk 1.2.1 → 1.2.3

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.
Files changed (43) hide show
  1. package/README.md +175 -207
  2. package/dist/api/nxtlinq-api.d.ts.map +1 -1
  3. package/dist/api/nxtlinq-api.js +121 -142
  4. package/dist/components/ChatBot.d.ts +2 -44
  5. package/dist/components/ChatBot.d.ts.map +1 -1
  6. package/dist/components/ChatBot.js +5 -1143
  7. package/dist/components/context/ChatBotContext.d.ts +5 -0
  8. package/dist/components/context/ChatBotContext.d.ts.map +1 -0
  9. package/dist/components/context/ChatBotContext.js +737 -0
  10. package/dist/components/types/ChatBotTypes.d.ts +98 -0
  11. package/dist/components/types/ChatBotTypes.d.ts.map +1 -0
  12. package/dist/components/types/ChatBotTypes.js +1 -0
  13. package/dist/components/ui/ChatBotUI.d.ts +3 -0
  14. package/dist/components/ui/ChatBotUI.d.ts.map +1 -0
  15. package/dist/components/ui/ChatBotUI.js +146 -0
  16. package/dist/components/ui/MessageInput.d.ts +3 -0
  17. package/dist/components/ui/MessageInput.d.ts.map +1 -0
  18. package/dist/components/ui/MessageInput.js +46 -0
  19. package/dist/components/ui/MessageList.d.ts +3 -0
  20. package/dist/components/ui/MessageList.d.ts.map +1 -0
  21. package/dist/components/ui/MessageList.js +54 -0
  22. package/dist/components/ui/NotificationModal.d.ts +14 -0
  23. package/dist/components/ui/NotificationModal.d.ts.map +1 -0
  24. package/dist/components/ui/NotificationModal.js +79 -0
  25. package/dist/components/ui/PermissionForm.d.ts +8 -0
  26. package/dist/components/ui/PermissionForm.d.ts.map +1 -0
  27. package/dist/components/ui/PermissionForm.js +299 -0
  28. package/dist/components/ui/PresetMessages.d.ts +3 -0
  29. package/dist/components/ui/PresetMessages.d.ts.map +1 -0
  30. package/dist/components/ui/PresetMessages.js +35 -0
  31. package/dist/core/utils/aitUtils.d.ts +28 -0
  32. package/dist/core/utils/aitUtils.d.ts.map +1 -0
  33. package/dist/core/utils/aitUtils.js +34 -0
  34. package/dist/core/utils/notificationUtils.d.ts +29 -0
  35. package/dist/core/utils/notificationUtils.d.ts.map +1 -0
  36. package/dist/core/utils/notificationUtils.js +47 -0
  37. package/dist/core/utils/walletUtils.d.ts +10 -0
  38. package/dist/core/utils/walletUtils.d.ts.map +1 -0
  39. package/dist/core/utils/walletUtils.js +38 -0
  40. package/dist/index.d.ts +13 -1
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +17 -0
  43. package/package.json +1 -1
@@ -1,151 +1,130 @@
1
1
  const AI_AGENT_API_HOST = 'https://ai-agent.nxtlinq.ai';
2
2
  const AIT_SERVICE_API_HOST = 'https://staging-ait-service.nxtlinq.ai';
3
- export const createNxtlinqApi = (apiKey, apiSecret) => {
4
- const getAuthHeader = () => {
5
- const token = localStorage.getItem('nxtlinqAITServiceAccessToken');
6
- return token ? { 'Authorization': `Bearer ${JSON.parse(token)}` } : {};
7
- };
8
- return {
9
- ait: {
10
- getAITByServiceIdAndController: async (params, token) => {
11
- const response = await fetch(`${AIT_SERVICE_API_HOST}/api/ait/service/${params.serviceId}/controller/${params.controller}`, {
12
- method: 'GET',
13
- headers: {
14
- 'X-API-Key': apiKey,
15
- 'X-API-Secret': apiSecret,
16
- ...getAuthHeader()
17
- }
18
- });
19
- return response.json();
20
- },
21
- createAIT: async (params, token) => {
22
- const response = await fetch(`${AIT_SERVICE_API_HOST}/api/ait`, {
23
- method: 'POST',
24
- headers: {
25
- 'X-API-Key': apiKey,
26
- 'X-API-Secret': apiSecret,
27
- 'Content-Type': 'application/json',
28
- ...getAuthHeader()
29
- },
30
- body: JSON.stringify(params)
31
- });
32
- return response.json();
33
- }
34
- },
35
- wallet: {
36
- verifyWallet: async (params, token) => {
37
- const response = await fetch(`${AIT_SERVICE_API_HOST}/api/wallet`, {
38
- method: 'POST',
39
- headers: {
40
- 'X-API-Key': apiKey,
41
- 'X-API-Secret': apiSecret,
42
- 'Content-Type': 'application/json',
43
- ...getAuthHeader()
44
- },
45
- body: JSON.stringify(params)
46
- });
47
- return response.json();
48
- },
49
- getWallet: async (params, token) => {
50
- const response = await fetch(`${AIT_SERVICE_API_HOST}/api/wallet/address/${params.address}`, {
51
- method: 'GET',
52
- headers: {
53
- 'X-API-Key': apiKey,
54
- 'X-API-Secret': apiSecret,
55
- ...getAuthHeader()
56
- }
57
- });
58
- return response.json();
59
- }
60
- },
61
- metadata: {
62
- createMetadata: async (metadata, token) => {
63
- const response = await fetch(`${AIT_SERVICE_API_HOST}/api/metadata`, {
64
- method: 'POST',
65
- headers: {
66
- 'X-API-Key': apiKey,
67
- 'X-API-Secret': apiSecret,
68
- 'Content-Type': 'application/json',
69
- ...getAuthHeader()
70
- },
71
- body: JSON.stringify(metadata)
72
- });
73
- return response.json();
74
- }
75
- },
76
- auth: {
77
- getNonce: async (params) => {
78
- const response = await fetch(`${AIT_SERVICE_API_HOST}/api/auth/address/${params.address}/nonce`, {
79
- method: 'GET',
80
- headers: {
81
- 'X-API-Key': apiKey,
82
- 'X-API-Secret': apiSecret,
83
- ...getAuthHeader()
84
- }
85
- });
86
- return response.json();
87
- },
88
- signIn: async (params) => {
89
- const response = await fetch(`${AIT_SERVICE_API_HOST}/api/auth`, {
90
- method: 'POST',
91
- headers: {
92
- 'X-API-Key': apiKey,
93
- 'X-API-Secret': apiSecret,
94
- 'Content-Type': 'application/json',
95
- ...getAuthHeader()
96
- },
97
- body: JSON.stringify(params)
98
- });
99
- return response.json();
3
+ // Helper function to get auth header
4
+ const getAuthHeader = () => {
5
+ const token = localStorage.getItem('nxtlinqAITServiceAccessToken');
6
+ return token ? { 'Authorization': `Bearer ${JSON.parse(token)}` } : {};
7
+ };
8
+ // Helper function to make API requests
9
+ const makeRequest = async (url, options, apiKey, apiSecret) => {
10
+ const response = await fetch(url, {
11
+ ...options,
12
+ headers: {
13
+ 'X-API-Key': apiKey,
14
+ 'X-API-Secret': apiSecret,
15
+ ...getAuthHeader(),
16
+ ...options.headers
17
+ }
18
+ });
19
+ return response.json();
20
+ };
21
+ // AIT API module
22
+ const createAITApi = (apiKey, apiSecret) => ({
23
+ getAITByServiceIdAndController: async (params, token) => {
24
+ return makeRequest(`${AIT_SERVICE_API_HOST}/api/ait/service/${params.serviceId}/controller/${params.controller}`, { method: 'GET' }, apiKey, apiSecret);
25
+ },
26
+ createAIT: async (params, token) => {
27
+ return makeRequest(`${AIT_SERVICE_API_HOST}/api/ait`, {
28
+ method: 'POST',
29
+ headers: { 'Content-Type': 'application/json' },
30
+ body: JSON.stringify(params)
31
+ }, apiKey, apiSecret);
32
+ }
33
+ });
34
+ // Wallet API module
35
+ const createWalletApi = (apiKey, apiSecret) => ({
36
+ verifyWallet: async (params, token) => {
37
+ return makeRequest(`${AIT_SERVICE_API_HOST}/api/wallet`, {
38
+ method: 'POST',
39
+ headers: { 'Content-Type': 'application/json' },
40
+ body: JSON.stringify(params)
41
+ }, apiKey, apiSecret);
42
+ },
43
+ getWallet: async (params, token) => {
44
+ return makeRequest(`${AIT_SERVICE_API_HOST}/api/wallet/address/${params.address}`, { method: 'GET' }, apiKey, apiSecret);
45
+ }
46
+ });
47
+ // Metadata API module
48
+ const createMetadataApi = (apiKey, apiSecret) => ({
49
+ createMetadata: async (metadata, token) => {
50
+ return makeRequest(`${AIT_SERVICE_API_HOST}/api/metadata`, {
51
+ method: 'POST',
52
+ headers: { 'Content-Type': 'application/json' },
53
+ body: JSON.stringify(metadata)
54
+ }, apiKey, apiSecret);
55
+ }
56
+ });
57
+ // Auth API module
58
+ const createAuthApi = (apiKey, apiSecret) => ({
59
+ getNonce: async (params) => {
60
+ return makeRequest(`${AIT_SERVICE_API_HOST}/api/auth/address/${params.address}/nonce`, { method: 'GET' }, apiKey, apiSecret);
61
+ },
62
+ signIn: async (params) => {
63
+ return makeRequest(`${AIT_SERVICE_API_HOST}/api/auth`, {
64
+ method: 'POST',
65
+ headers: { 'Content-Type': 'application/json' },
66
+ body: JSON.stringify(params)
67
+ }, apiKey, apiSecret);
68
+ }
69
+ });
70
+ // Agent API module
71
+ const createAgentApi = () => ({
72
+ sendMessage: async (params) => {
73
+ try {
74
+ const response = await fetch(`${AI_AGENT_API_HOST}/api/nova`, {
75
+ method: 'POST',
76
+ headers: {
77
+ 'Content-Type': 'application/json',
78
+ },
79
+ body: JSON.stringify(params),
80
+ });
81
+ if (!response.ok) {
82
+ throw new Error('Failed to send message');
100
83
  }
101
- },
102
- agent: {
103
- sendMessage: async (params) => {
104
- try {
105
- const response = await fetch(`${AI_AGENT_API_HOST}/api/nova`, {
106
- method: 'POST',
107
- headers: {
108
- 'Content-Type': 'application/json',
109
- },
110
- body: JSON.stringify(params),
111
- });
112
- if (!response.ok) {
113
- throw new Error('Failed to send message');
114
- }
115
- return await response.json();
116
- }
117
- catch (error) {
118
- console.error('Failed to send message:', error);
119
- return { error: error instanceof Error ? error.message : 'Failed to send message' };
120
- }
84
+ return await response.json();
85
+ }
86
+ catch (error) {
87
+ console.error('Failed to send message:', error);
88
+ return { error: error instanceof Error ? error.message : 'Failed to send message' };
89
+ }
90
+ }
91
+ });
92
+ // Permissions API module
93
+ const createPermissionsApi = (apiKey, apiSecret) => ({
94
+ getServicePermissions: async (params) => {
95
+ try {
96
+ const url = new URL(`${AI_AGENT_API_HOST}/api/permissions/service/${params.serviceId}`);
97
+ if (params.groupName) {
98
+ url.searchParams.append('groupName', params.groupName);
121
99
  }
122
- },
123
- permissions: {
124
- getServicePermissions: async (params) => {
125
- try {
126
- const url = new URL(`${AI_AGENT_API_HOST}/api/permissions/service/${params.serviceId}`);
127
- if (params.groupName) {
128
- url.searchParams.append('groupName', params.groupName);
129
- }
130
- const response = await fetch(url.toString(), {
131
- method: 'GET',
132
- headers: {
133
- 'X-API-Key': apiKey,
134
- 'X-API-Secret': apiSecret,
135
- 'Content-Type': 'application/json',
136
- ...getAuthHeader()
137
- }
138
- });
139
- if (!response.ok) {
140
- throw new Error('Failed to fetch permissions');
141
- }
142
- return await response.json();
143
- }
144
- catch (error) {
145
- console.error('Failed to fetch permissions:', error);
146
- return { error: error instanceof Error ? error.message : 'Failed to fetch permissions' };
100
+ const response = await fetch(url.toString(), {
101
+ method: 'GET',
102
+ headers: {
103
+ 'X-API-Key': apiKey,
104
+ 'X-API-Secret': apiSecret,
105
+ 'Content-Type': 'application/json',
106
+ ...getAuthHeader()
147
107
  }
108
+ });
109
+ if (!response.ok) {
110
+ throw new Error('Failed to fetch permissions');
148
111
  }
112
+ return await response.json();
113
+ }
114
+ catch (error) {
115
+ console.error('Failed to fetch permissions:', error);
116
+ return { error: error instanceof Error ? error.message : 'Failed to fetch permissions' };
149
117
  }
118
+ }
119
+ });
120
+ // Main API factory
121
+ export const createNxtlinqApi = (apiKey, apiSecret) => {
122
+ return {
123
+ ait: createAITApi(apiKey, apiSecret),
124
+ wallet: createWalletApi(apiKey, apiSecret),
125
+ metadata: createMetadataApi(apiKey, apiSecret),
126
+ auth: createAuthApi(apiKey, apiSecret),
127
+ agent: createAgentApi(),
128
+ permissions: createPermissionsApi(apiKey, apiSecret)
150
129
  };
151
130
  };
@@ -1,47 +1,5 @@
1
1
  import * as React from 'react';
2
- import { Message } from '../types/ait-api';
3
- export interface PresetMessage {
4
- text: string;
5
- autoSend?: boolean;
6
- }
7
- export interface ToolUse {
8
- name: string;
9
- input: Record<string, any>;
10
- }
11
- export interface ToolCall {
12
- toolUse: ToolUse;
13
- }
14
- export interface NovaResponse {
15
- result: string;
16
- reply: Array<{
17
- text: string;
18
- }>;
19
- toolCall?: ToolCall;
20
- }
21
- export interface NovaError {
22
- error: string;
23
- }
24
- export interface AITMetadata {
25
- model: string;
26
- permissions: string[];
27
- issuedBy: string;
28
- }
29
- export interface ChatBotProps {
30
- onMessage?: (message: Message) => void;
31
- onError?: (error: Error) => void;
32
- onToolUse?: (toolUse: ToolUse) => Promise<Message | void>;
33
- presetMessages?: PresetMessage[];
34
- placeholder?: string;
35
- className?: string;
36
- maxRetries?: number;
37
- retryDelay?: number;
38
- serviceId: string;
39
- apiKey: string;
40
- apiSecret: string;
41
- onVerifyWallet?: () => Promise<{
42
- token: string;
43
- } | undefined>;
44
- permissionGroup?: string;
45
- }
2
+ import { ChatBotProps } from './types/ChatBotTypes';
46
3
  export declare const ChatBot: React.FC<ChatBotProps>;
4
+ export type { ChatBotProps, PresetMessage, ToolUse } from './types/ChatBotTypes';
47
5
  //# sourceMappingURL=ChatBot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChatBot.d.ts","sourceRoot":"","sources":["../../src/components/ChatBot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,OAAO,EAAE,OAAO,EAAkC,MAAM,kBAAkB,CAAC;AAE3E,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAC1D,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC;QAC7B,KAAK,EAAE,MAAM,CAAC;KACf,GAAG,SAAS,CAAC,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AA2cD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAogC1C,CAAC"}
1
+ {"version":3,"file":"ChatBot.d.ts","sourceRoot":"","sources":["../../src/components/ChatBot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAM1C,CAAC;AAEF,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC"}