@bytexbyte/nxtlinq-ai-agent-sdk 1.0.8 → 1.1.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.
- package/dist/api/nxtlinq-api.d.ts +3 -0
- package/dist/api/nxtlinq-api.d.ts.map +1 -0
- package/dist/api/nxtlinq-api.js +124 -0
- package/dist/components/ChatBot.d.ts +62 -0
- package/dist/components/ChatBot.d.ts.map +1 -0
- package/dist/components/ChatBot.js +843 -0
- package/dist/core/lib/useLocalStorage.d.ts +3 -0
- package/dist/core/lib/useLocalStorage.d.ts.map +1 -0
- package/dist/core/lib/useLocalStorage.js +18 -0
- package/dist/core/metakeepClient.d.ts +4 -0
- package/dist/core/metakeepClient.d.ts.map +1 -0
- package/dist/core/metakeepClient.js +11 -0
- package/dist/hooks/useNxtlinqAIT.d.ts +14 -0
- package/dist/hooks/useNxtlinqAIT.d.ts.map +1 -0
- package/dist/hooks/useNxtlinqAIT.js +98 -0
- package/dist/index.d.ts +114 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -138
- package/dist/types/ait-api.d.ts +127 -0
- package/dist/types/ait-api.d.ts.map +1 -0
- package/dist/types/ait-api.js +1 -0
- package/package.json +5 -5
- package/src/components/ChatBot.tsx +0 -1192
- package/src/core/metakeepClient.ts +0 -13
- package/src/hooks/useNxtlinqAIT.ts +0 -99
- package/src/index.ts +0 -557
- package/src/types/ait-api.ts +0 -103
- package/src/types/window.d.ts +0 -9
- package/tsconfig.json +0 -25
- package/tsup.config.ts +0 -15
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nxtlinq-api.d.ts","sourceRoot":"","sources":["../../src/api/nxtlinq-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAK1C,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,WAAW,MAAM,KAAG,MA2HpE,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
const AI_AGENT_API_HOST = 'https://ai-agent.nxtlinq.ai';
|
|
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();
|
|
100
|
+
}
|
|
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
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface Message {
|
|
3
|
+
id: string;
|
|
4
|
+
content: string;
|
|
5
|
+
role: 'user' | 'assistant';
|
|
6
|
+
timestamp: string;
|
|
7
|
+
button?: boolean;
|
|
8
|
+
error?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface PresetMessage {
|
|
11
|
+
text: string;
|
|
12
|
+
autoSend?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface ToolUse {
|
|
15
|
+
name: string;
|
|
16
|
+
input: Record<string, any>;
|
|
17
|
+
}
|
|
18
|
+
export interface ToolCall {
|
|
19
|
+
toolUse: ToolUse;
|
|
20
|
+
}
|
|
21
|
+
export interface NovaResponse {
|
|
22
|
+
result: string;
|
|
23
|
+
reply: Array<{
|
|
24
|
+
text: string;
|
|
25
|
+
}>;
|
|
26
|
+
toolCall?: ToolCall;
|
|
27
|
+
}
|
|
28
|
+
export interface NovaError {
|
|
29
|
+
error: string;
|
|
30
|
+
}
|
|
31
|
+
export interface AITMetadata {
|
|
32
|
+
model: string;
|
|
33
|
+
permissions: string[];
|
|
34
|
+
issuedBy: string;
|
|
35
|
+
}
|
|
36
|
+
export interface AIT {
|
|
37
|
+
aitId: string;
|
|
38
|
+
controller: string;
|
|
39
|
+
metadata: AITMetadata;
|
|
40
|
+
metadataHash: string;
|
|
41
|
+
metadataCid: string;
|
|
42
|
+
signature: string;
|
|
43
|
+
}
|
|
44
|
+
export interface ChatBotProps {
|
|
45
|
+
projectId?: string;
|
|
46
|
+
onMessage?: (message: Message) => void;
|
|
47
|
+
onError?: (error: Error) => void;
|
|
48
|
+
onToolUse?: (toolUse: ToolUse) => Promise<Message | void>;
|
|
49
|
+
presetMessages?: PresetMessage[];
|
|
50
|
+
placeholder?: string;
|
|
51
|
+
className?: string;
|
|
52
|
+
maxRetries?: number;
|
|
53
|
+
retryDelay?: number;
|
|
54
|
+
serviceId: string;
|
|
55
|
+
apiKey: string;
|
|
56
|
+
apiSecret: string;
|
|
57
|
+
onVerifyWallet?: (address: string) => Promise<{
|
|
58
|
+
token: string;
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
61
|
+
export declare const ChatBot: React.FC<ChatBotProps>;
|
|
62
|
+
//# sourceMappingURL=ChatBot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatBot.d.ts","sourceRoot":"","sources":["../../src/components/ChatBot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IAC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