@bytexbyte/nxtlinq-ai-agent-sdk 1.0.8 → 1.0.9
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 +126 -0
- package/dist/components/ChatBot.d.ts +49 -0
- package/dist/components/ChatBot.d.ts.map +1 -0
- package/dist/components/ChatBot.js +836 -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 +1 -126
- 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,MA6HpE,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
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/agent/message`, {
|
|
106
|
+
method: 'POST',
|
|
107
|
+
headers: {
|
|
108
|
+
'X-API-Key': apiKey,
|
|
109
|
+
'X-API-Secret': apiSecret,
|
|
110
|
+
'Content-Type': 'application/json',
|
|
111
|
+
...getAuthHeader()
|
|
112
|
+
},
|
|
113
|
+
body: JSON.stringify(params)
|
|
114
|
+
});
|
|
115
|
+
if (!response.ok) {
|
|
116
|
+
throw new Error('发送消息失败');
|
|
117
|
+
}
|
|
118
|
+
return await response.json();
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
return { error: error instanceof Error ? error.message : '发送消息失败' };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
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 AITMetadata {
|
|
19
|
+
model: string;
|
|
20
|
+
permissions: string[];
|
|
21
|
+
issuedBy: string;
|
|
22
|
+
}
|
|
23
|
+
export interface AIT {
|
|
24
|
+
aitId: string;
|
|
25
|
+
controller: string;
|
|
26
|
+
metadata: AITMetadata;
|
|
27
|
+
metadataHash: string;
|
|
28
|
+
metadataCid: string;
|
|
29
|
+
signature: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ChatBotProps {
|
|
32
|
+
projectId?: string;
|
|
33
|
+
onMessage?: (message: Message) => void;
|
|
34
|
+
onError?: (error: Error) => void;
|
|
35
|
+
onToolUse?: (toolUse: ToolUse) => Promise<Message | void>;
|
|
36
|
+
presetMessages?: PresetMessage[];
|
|
37
|
+
placeholder?: string;
|
|
38
|
+
className?: string;
|
|
39
|
+
maxRetries?: number;
|
|
40
|
+
retryDelay?: number;
|
|
41
|
+
serviceId: string;
|
|
42
|
+
apiKey: string;
|
|
43
|
+
apiSecret: string;
|
|
44
|
+
onVerifyWallet?: (address: string) => Promise<{
|
|
45
|
+
token: string;
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
export declare const ChatBot: React.FC<ChatBotProps>;
|
|
49
|
+
//# 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;AAM/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;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,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,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;I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