@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.
- package/README.md +175 -207
- package/dist/api/nxtlinq-api.d.ts.map +1 -1
- package/dist/api/nxtlinq-api.js +121 -142
- package/dist/components/ChatBot.d.ts +2 -44
- package/dist/components/ChatBot.d.ts.map +1 -1
- package/dist/components/ChatBot.js +5 -1143
- package/dist/components/context/ChatBotContext.d.ts +5 -0
- package/dist/components/context/ChatBotContext.d.ts.map +1 -0
- package/dist/components/context/ChatBotContext.js +737 -0
- package/dist/components/types/ChatBotTypes.d.ts +98 -0
- package/dist/components/types/ChatBotTypes.d.ts.map +1 -0
- package/dist/components/types/ChatBotTypes.js +1 -0
- package/dist/components/ui/ChatBotUI.d.ts +3 -0
- package/dist/components/ui/ChatBotUI.d.ts.map +1 -0
- package/dist/components/ui/ChatBotUI.js +146 -0
- package/dist/components/ui/MessageInput.d.ts +3 -0
- package/dist/components/ui/MessageInput.d.ts.map +1 -0
- package/dist/components/ui/MessageInput.js +46 -0
- package/dist/components/ui/MessageList.d.ts +3 -0
- package/dist/components/ui/MessageList.d.ts.map +1 -0
- package/dist/components/ui/MessageList.js +54 -0
- package/dist/components/ui/NotificationModal.d.ts +14 -0
- package/dist/components/ui/NotificationModal.d.ts.map +1 -0
- package/dist/components/ui/NotificationModal.js +79 -0
- package/dist/components/ui/PermissionForm.d.ts +8 -0
- package/dist/components/ui/PermissionForm.d.ts.map +1 -0
- package/dist/components/ui/PermissionForm.js +299 -0
- package/dist/components/ui/PresetMessages.d.ts +3 -0
- package/dist/components/ui/PresetMessages.d.ts.map +1 -0
- package/dist/components/ui/PresetMessages.js +35 -0
- package/dist/core/utils/aitUtils.d.ts +28 -0
- package/dist/core/utils/aitUtils.d.ts.map +1 -0
- package/dist/core/utils/aitUtils.js +34 -0
- package/dist/core/utils/notificationUtils.d.ts +29 -0
- package/dist/core/utils/notificationUtils.d.ts.map +1 -0
- package/dist/core/utils/notificationUtils.js +47 -0
- package/dist/core/utils/walletUtils.d.ts +10 -0
- package/dist/core/utils/walletUtils.d.ts.map +1 -0
- package/dist/core/utils/walletUtils.js +38 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -0
- package/package.json +1 -1
package/dist/api/nxtlinq-api.js
CHANGED
|
@@ -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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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 {
|
|
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;
|
|
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"}
|