@ai.ntellect/core 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- package/agent/index.ts +43 -7
- package/dist/agent/index.d.ts +5 -1
- package/dist/agent/index.js +25 -9
- package/dist/llm/evaluator/context.js +7 -5
- package/dist/llm/evaluator/index.js +8 -9
- package/dist/llm/interpreter/context.js +1 -1
- package/dist/llm/orchestrator/context.d.ts +1 -1
- package/dist/llm/orchestrator/context.js +4 -6
- package/dist/llm/orchestrator/index.js +1 -1
- package/dist/memory/cache.d.ts +0 -1
- package/dist/memory/cache.js +4 -21
- package/dist/memory/persistent.d.ts +4 -10
- package/dist/memory/persistent.js +17 -53
- package/dist/services/scheduler.d.ts +17 -0
- package/dist/services/scheduler.js +121 -0
- package/dist/services/telegram-monitor.d.ts +15 -0
- package/dist/services/telegram-monitor.js +102 -0
- package/dist/test.d.ts +0 -167
- package/dist/test.js +503 -372
- package/dist/types.d.ts +22 -2
- package/llm/evaluator/index.ts +3 -4
- package/memory/cache.ts +4 -24
- package/memory/persistent.ts +14 -64
- package/package.json +1 -1
- package/services/scheduler.ts +167 -0
- package/services/telegram-monitor.ts +138 -0
- package/types.ts +24 -2
package/dist/test.js
CHANGED
@@ -1,373 +1,504 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
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
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
}
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
2
|
+
// import ccxt from "ccxt";
|
3
|
+
// import { parseEther } from "ethers";
|
4
|
+
// import Parser from "rss-parser";
|
5
|
+
// import { z } from "zod";
|
6
|
+
// import { Agent } from "./agent";
|
7
|
+
// import { Interpreter } from "./llm/interpreter";
|
8
|
+
// import {
|
9
|
+
// generalInterpreterContext,
|
10
|
+
// marketInterpreterContext,
|
11
|
+
// securityInterpreterContext,
|
12
|
+
// } from "./llm/interpreter/context";
|
13
|
+
// import { Orchestrator } from "./llm/orchestrator";
|
14
|
+
// import { CacheMemory } from "./memory/cache";
|
15
|
+
// import { PersistentMemory } from "./memory/persistent";
|
16
|
+
// import { ActionQueueManager } from "./services/queue";
|
17
|
+
// import { ActionScheduler } from "./services/scheduler";
|
18
|
+
// import { ScheduledAction } from "./types";
|
19
|
+
// interface HoneypotParams {
|
20
|
+
// address: string;
|
21
|
+
// chainName?: string;
|
22
|
+
// simulateLiquidity?: boolean;
|
23
|
+
// }
|
24
|
+
// // Mapping des noms de chaînes vers leurs IDs
|
25
|
+
// const CHAIN_IDS: { [key: string]: string } = {
|
26
|
+
// ethereum: "1",
|
27
|
+
// bsc: "56",
|
28
|
+
// polygon: "137",
|
29
|
+
// matic: "137",
|
30
|
+
// avalanche: "43114",
|
31
|
+
// avax: "43114",
|
32
|
+
// fantom: "250",
|
33
|
+
// ftm: "250",
|
34
|
+
// arbitrum: "42161",
|
35
|
+
// arb: "42161",
|
36
|
+
// optimism: "10",
|
37
|
+
// base: "8453",
|
38
|
+
// zksync: "324",
|
39
|
+
// solana: "solana",
|
40
|
+
// sol: "solana",
|
41
|
+
// };
|
42
|
+
// export const checkHoneypot = {
|
43
|
+
// name: "check-honeypot",
|
44
|
+
// description: `Analyze a token to detect if it is a honeypot. RESPECT THIS FORMAT FOR CHAIN NAME: ${CHAIN_IDS.toString()}`,
|
45
|
+
// parameters: z.object({
|
46
|
+
// address: z.string().describe("Address of the token"),
|
47
|
+
// chainName: z.string().describe("Chain name (default: eth)"),
|
48
|
+
// }),
|
49
|
+
// execute: async ({
|
50
|
+
// address,
|
51
|
+
// chainName,
|
52
|
+
// }: {
|
53
|
+
// address: string;
|
54
|
+
// chainName?: string;
|
55
|
+
// }) => {
|
56
|
+
// try {
|
57
|
+
// const API_URL = "https://api.honeypot.is/v2/IsHoneypot";
|
58
|
+
// const chainId = getChainId(chainName);
|
59
|
+
// console.log("💰 Checking honeypot for token", {
|
60
|
+
// address,
|
61
|
+
// chainId,
|
62
|
+
// });
|
63
|
+
// if (chainId === "solana") {
|
64
|
+
// return {
|
65
|
+
// status: "error",
|
66
|
+
// message:
|
67
|
+
// "L'analyse des tokens Solana n'est pas encore supportée. Cette fonctionnalité sera disponible prochainement.",
|
68
|
+
// chain: {
|
69
|
+
// name: "Solana",
|
70
|
+
// id: "solana",
|
71
|
+
// },
|
72
|
+
// };
|
73
|
+
// }
|
74
|
+
// const queryParams = new URLSearchParams({
|
75
|
+
// address: address,
|
76
|
+
// ...(chainId && { chainId }),
|
77
|
+
// ...{ simulateLiquidity: "true" },
|
78
|
+
// });
|
79
|
+
// const response = await fetch(`${API_URL}?${queryParams}`);
|
80
|
+
// if (!response.ok) {
|
81
|
+
// throw new Error(
|
82
|
+
// `Erreur API: ${response.status} ${response.statusText}`
|
83
|
+
// );
|
84
|
+
// }
|
85
|
+
// const data: any = await response.json();
|
86
|
+
// const result = {
|
87
|
+
// status: "success",
|
88
|
+
// token: {
|
89
|
+
// name: data.token.name,
|
90
|
+
// symbol: data.token.symbol,
|
91
|
+
// address: data.token.address,
|
92
|
+
// holders: data.token.totalHolders,
|
93
|
+
// },
|
94
|
+
// risk: {
|
95
|
+
// level: data.summary.risk,
|
96
|
+
// score: data.summary.riskLevel,
|
97
|
+
// flags: data.summary.flags || [],
|
98
|
+
// },
|
99
|
+
// analysis: {
|
100
|
+
// isHoneypot: data.honeypotResult?.isHoneypot || false,
|
101
|
+
// reason: data.honeypotResult?.honeypotReason || null,
|
102
|
+
// buyTax: data.simulationResult?.buyTax || 0,
|
103
|
+
// sellTax: data.simulationResult?.sellTax || 0,
|
104
|
+
// holders: {
|
105
|
+
// total: data.holderAnalysis?.holders || 0,
|
106
|
+
// successful: data.holderAnalysis?.successful || 0,
|
107
|
+
// failed: data.holderAnalysis?.failed || 0,
|
108
|
+
// siphoned: data.holderAnalysis?.siphoned || 0,
|
109
|
+
// },
|
110
|
+
// },
|
111
|
+
// chain: {
|
112
|
+
// name: data.chain.name,
|
113
|
+
// id: data.chain.id,
|
114
|
+
// },
|
115
|
+
// };
|
116
|
+
// return result;
|
117
|
+
// } catch (error: any) {
|
118
|
+
// throw error;
|
119
|
+
// }
|
120
|
+
// },
|
121
|
+
// };
|
122
|
+
// function getChainId(chainName?: string): string | undefined {
|
123
|
+
// if (!chainName) return undefined;
|
124
|
+
// const normalizedChainName = chainName.toLowerCase();
|
125
|
+
// return CHAIN_IDS[normalizedChainName];
|
126
|
+
// }
|
127
|
+
// export interface NetworkConfig {
|
128
|
+
// name: string;
|
129
|
+
// id?: number;
|
130
|
+
// rpc: string;
|
131
|
+
// explorerUrl: string;
|
132
|
+
// nativeToken: string; // WETH
|
133
|
+
// }
|
134
|
+
// export const networkConfigs: Record<string, NetworkConfig> = {
|
135
|
+
// ethereum: {
|
136
|
+
// name: "Ethereum Mainnet",
|
137
|
+
// id: 1,
|
138
|
+
// rpc: "https://eth.llamarpc.com",
|
139
|
+
// explorerUrl: "https://etherscan.io",
|
140
|
+
// nativeToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
141
|
+
// },
|
142
|
+
// polygon: {
|
143
|
+
// name: "Polygon Mainnet",
|
144
|
+
// id: 137,
|
145
|
+
// rpc: "https://polygon.llamarpc.com",
|
146
|
+
// explorerUrl: "https://polygonscan.com",
|
147
|
+
// nativeToken: "0x0000000000000000000000000000000000001010",
|
148
|
+
// },
|
149
|
+
// arbitrum: {
|
150
|
+
// name: "Arbitrum Mainnet",
|
151
|
+
// id: 42161,
|
152
|
+
// rpc: "https://arbitrum.llamarpc.com",
|
153
|
+
// explorerUrl: "https://arbiscan.io",
|
154
|
+
// nativeToken: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
|
155
|
+
// },
|
156
|
+
// base: {
|
157
|
+
// name: "Base Mainnet",
|
158
|
+
// id: 8453,
|
159
|
+
// rpc: "https://base.llamarpc.com",
|
160
|
+
// explorerUrl: "https://basescan.org",
|
161
|
+
// nativeToken: "0x4200000000000000000000000000000000000006",
|
162
|
+
// },
|
163
|
+
// solana: {
|
164
|
+
// name: "Solana Mainnet",
|
165
|
+
// rpc: "https://api.mainnet-beta.solana.com",
|
166
|
+
// explorerUrl: "https://solscan.io",
|
167
|
+
// nativeToken: "So11111111111111111111111111111111111111112",
|
168
|
+
// },
|
169
|
+
// sepolia: {
|
170
|
+
// name: "Sepolia Testnet",
|
171
|
+
// id: 11155111,
|
172
|
+
// rpc: "https://sepolia.llamarpc.com",
|
173
|
+
// explorerUrl: "https://sepolia.etherscan.io",
|
174
|
+
// nativeToken: "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14",
|
175
|
+
// },
|
176
|
+
// baseSepolia: {
|
177
|
+
// name: "Base Sepolia Testnet",
|
178
|
+
// id: 84532,
|
179
|
+
// rpc: "https://base-sepolia-rpc.publicnode.com",
|
180
|
+
// explorerUrl: "https://sepolia.basescan.org",
|
181
|
+
// nativeToken: "0x4200000000000000000000000000000000000006",
|
182
|
+
// },
|
183
|
+
// };
|
184
|
+
// export const getNetworkProvider = (networkName: string) => {
|
185
|
+
// const config = networkConfigs[networkName.toLowerCase()];
|
186
|
+
// if (!config) {
|
187
|
+
// throw new Error(`Network ${networkName} not supported`);
|
188
|
+
// }
|
189
|
+
// return { config };
|
190
|
+
// };
|
191
|
+
// export type TransactionPrepared = {
|
192
|
+
// to: string;
|
193
|
+
// value: string;
|
194
|
+
// data?: string;
|
195
|
+
// chain: {
|
196
|
+
// id: number;
|
197
|
+
// rpc: string;
|
198
|
+
// };
|
199
|
+
// type: "transfer" | "approve" | "swap";
|
200
|
+
// method?: string;
|
201
|
+
// params?: any[];
|
202
|
+
// };
|
203
|
+
// export const prepareEvmTransaction = {
|
204
|
+
// name: "prepare-evm-transaction",
|
205
|
+
// description: "Prepare a transaction for the user to sign.",
|
206
|
+
// parameters: z.object({
|
207
|
+
// walletAddress: z.string(),
|
208
|
+
// amount: z
|
209
|
+
// .string()
|
210
|
+
// .describe("Ask the user for the amount to send, if not specified"),
|
211
|
+
// network: z
|
212
|
+
// .string()
|
213
|
+
// .describe(
|
214
|
+
// "Examples networks: ethereum, arbitrum, base. IMPORTANT: You must respect the network name."
|
215
|
+
// ),
|
216
|
+
// }),
|
217
|
+
// execute: async ({
|
218
|
+
// walletAddress,
|
219
|
+
// amount,
|
220
|
+
// network,
|
221
|
+
// }: {
|
222
|
+
// walletAddress: string;
|
223
|
+
// amount: string;
|
224
|
+
// network: string;
|
225
|
+
// }): Promise<TransactionPrepared> => {
|
226
|
+
// try {
|
227
|
+
// console.log("💰 Preparing transaction", {
|
228
|
+
// to: walletAddress,
|
229
|
+
// amount,
|
230
|
+
// network,
|
231
|
+
// });
|
232
|
+
// const networkConfig = networkConfigs[network.toLowerCase()];
|
233
|
+
// if (!networkConfig) {
|
234
|
+
// throw new Error(`Network ${network} not found`);
|
235
|
+
// }
|
236
|
+
// return {
|
237
|
+
// to: walletAddress,
|
238
|
+
// value: parseEther(amount).toString(),
|
239
|
+
// chain: {
|
240
|
+
// id: networkConfig.id || 0,
|
241
|
+
// rpc: networkConfig.rpc,
|
242
|
+
// },
|
243
|
+
// type: "transfer",
|
244
|
+
// };
|
245
|
+
// } catch (error) {
|
246
|
+
// console.error("💰 Error sending transaction:", error);
|
247
|
+
// throw new Error("An error occurred while sending the transaction");
|
248
|
+
// }
|
249
|
+
// },
|
250
|
+
// };
|
251
|
+
// export const fetchMarkPrice = {
|
252
|
+
// name: "fetch-mark-price",
|
253
|
+
// description: "Fetches mark price for the market",
|
254
|
+
// parameters: z.object({
|
255
|
+
// symbol: z
|
256
|
+
// .string()
|
257
|
+
// .describe(
|
258
|
+
// "Unified symbol of the market to fetch the ticker for (default: BTC/USDT)"
|
259
|
+
// ),
|
260
|
+
// params: z.object({
|
261
|
+
// subType: z
|
262
|
+
// .string()
|
263
|
+
// .describe("Type of funding rate: 'linear' or 'inverse'"),
|
264
|
+
// }),
|
265
|
+
// }),
|
266
|
+
// execute: async ({ symbol, params }: { symbol: string; params: any }) => {
|
267
|
+
// try {
|
268
|
+
// const binance = new ccxt.binance({});
|
269
|
+
// // Fetch mark price from the Binance API
|
270
|
+
// const markPrice = await binance.fetchMarkPrice(symbol, params);
|
271
|
+
// console.log("Mark price fetched:", markPrice);
|
272
|
+
// return markPrice;
|
273
|
+
// } catch (error: any) {
|
274
|
+
// console.error("Error fetching mark price:", error);
|
275
|
+
// throw error;
|
276
|
+
// }
|
277
|
+
// },
|
278
|
+
// };
|
279
|
+
// interface ChainTVL {
|
280
|
+
// name: string;
|
281
|
+
// tvl: number;
|
282
|
+
// tokenSymbol: string | null;
|
283
|
+
// chainId: number | string | null;
|
284
|
+
// gecko_id: string | null;
|
285
|
+
// cmcId: string | null;
|
286
|
+
// }
|
287
|
+
// export const getChainsTVL = {
|
288
|
+
// name: "get_chains_tvl",
|
289
|
+
// description:
|
290
|
+
// "Get current TVL (Total Value Locked) of all chains from DeFiLlama",
|
291
|
+
// parameters: z.object({
|
292
|
+
// limit: z
|
293
|
+
// .number()
|
294
|
+
// .optional()
|
295
|
+
// .default(10)
|
296
|
+
// .describe("Number of top chains to return (default: 10)"),
|
297
|
+
// }),
|
298
|
+
// execute: async ({ limit }: { limit: number }) => {
|
299
|
+
// try {
|
300
|
+
// const response = await fetch("https://api.llama.fi/v2/chains", {
|
301
|
+
// headers: { accept: "*/*" },
|
302
|
+
// });
|
303
|
+
// if (!response.ok) {
|
304
|
+
// throw new Error(`HTTP error! status: ${response.status}`);
|
305
|
+
// }
|
306
|
+
// const chains = (await response.json()) as ChainTVL[];
|
307
|
+
// // Sort chains by TVL in descending order and take top N
|
308
|
+
// const topChains = chains
|
309
|
+
// .sort((a, b) => b.tvl - a.tvl)
|
310
|
+
// .slice(0, limit)
|
311
|
+
// .map((chain) => ({
|
312
|
+
// name: chain.name,
|
313
|
+
// tvl: chain.tvl,
|
314
|
+
// tokenSymbol: chain.tokenSymbol,
|
315
|
+
// }));
|
316
|
+
// const totalTVL = chains.reduce((sum, chain) => sum + chain.tvl, 0);
|
317
|
+
// return {
|
318
|
+
// summary: {
|
319
|
+
// totalTVL,
|
320
|
+
// numberOfChains: chains.length,
|
321
|
+
// },
|
322
|
+
// topChains,
|
323
|
+
// };
|
324
|
+
// } catch (error) {
|
325
|
+
// console.error("Error retrieving chains TVL data:", error);
|
326
|
+
// throw new Error(
|
327
|
+
// `Failed to fetch chains TVL data: ${(error as Error).message}`
|
328
|
+
// );
|
329
|
+
// }
|
330
|
+
// },
|
331
|
+
// };
|
332
|
+
// const RSS_FEEDS = [
|
333
|
+
// "https://www.investing.com/rss/news_301.rss",
|
334
|
+
// "https://cointelegraph.com/rss/category/analysis",
|
335
|
+
// "https://cointelegraph.com/rss/category/top-10-cryptocurrencies",
|
336
|
+
// ];
|
337
|
+
// const parser = new Parser();
|
338
|
+
// function stripHtmlTags(content: string): string {
|
339
|
+
// if (!content) return "";
|
340
|
+
// return content
|
341
|
+
// .replace(/<[^>]*>/g, "")
|
342
|
+
// .replace(/\n/g, "")
|
343
|
+
// .replace(" ", "");
|
344
|
+
// }
|
345
|
+
// export const getRssNews = {
|
346
|
+
// name: "get-news-rss",
|
347
|
+
// description: "Get latest news about on website",
|
348
|
+
// parameters: z.object({}),
|
349
|
+
// execute: async () => {
|
350
|
+
// const itemsPerSource = 5;
|
351
|
+
// try {
|
352
|
+
// const feedPromises = RSS_FEEDS.map((url) => parser.parseURL(url));
|
353
|
+
// const results = await Promise.allSettled(feedPromises);
|
354
|
+
// const successfulFeeds = results
|
355
|
+
// .filter(
|
356
|
+
// (result): result is PromiseFulfilledResult<Parser.Output<any>> => {
|
357
|
+
// return (
|
358
|
+
// result.status === "fulfilled" && result.value?.items?.length > 0
|
359
|
+
// );
|
360
|
+
// }
|
361
|
+
// )
|
362
|
+
// .map((result) => result.value);
|
363
|
+
// const allItems = successfulFeeds
|
364
|
+
// .flatMap((feed) => feed.items.slice(0, itemsPerSource))
|
365
|
+
// .sort((a, b) => {
|
366
|
+
// const dateA = a.pubDate ? new Date(a.pubDate).getTime() : 0;
|
367
|
+
// const dateB = b.pubDate ? new Date(b.pubDate).getTime() : 0;
|
368
|
+
// return dateB - dateA;
|
369
|
+
// })
|
370
|
+
// .slice(0, 5)
|
371
|
+
// .map((item) => ({
|
372
|
+
// title: item.title,
|
373
|
+
// content: stripHtmlTags(item.content),
|
374
|
+
// link: item.link,
|
375
|
+
// date: item.pubDate,
|
376
|
+
// source: item.creator || new URL(item.link).hostname,
|
377
|
+
// }));
|
378
|
+
// const result = {
|
379
|
+
// status: "success",
|
380
|
+
// items: allItems,
|
381
|
+
// };
|
382
|
+
// return result;
|
383
|
+
// } catch (error: any) {
|
384
|
+
// throw error;
|
385
|
+
// }
|
386
|
+
// },
|
387
|
+
// };
|
388
|
+
// (async () => {
|
389
|
+
// const cacheMemory = new CacheMemory();
|
390
|
+
// const memory = new PersistentMemory({
|
391
|
+
// host: "http://localhost:7700",
|
392
|
+
// apiKey: "aSampleMasterKey",
|
393
|
+
// });
|
394
|
+
// const orchestrator = new Orchestrator({
|
395
|
+
// id: "1",
|
396
|
+
// tools: [
|
397
|
+
// prepareEvmTransaction,
|
398
|
+
// checkHoneypot,
|
399
|
+
// getChainsTVL,
|
400
|
+
// getRssNews,
|
401
|
+
// {
|
402
|
+
// name: "hello",
|
403
|
+
// description: "hello",
|
404
|
+
// parameters: z.object({
|
405
|
+
// name: z.string(),
|
406
|
+
// }),
|
407
|
+
// execute: async () => {
|
408
|
+
// console.log("hello");
|
409
|
+
// },
|
410
|
+
// },
|
411
|
+
// ],
|
412
|
+
// memory: {
|
413
|
+
// persistent: memory,
|
414
|
+
// cache: cacheMemory,
|
415
|
+
// },
|
416
|
+
// });
|
417
|
+
// const securityInterpreter = new Interpreter(
|
418
|
+
// "security",
|
419
|
+
// securityInterpreterContext
|
420
|
+
// );
|
421
|
+
// const marketInterpreter = new Interpreter("market", marketInterpreterContext);
|
422
|
+
// const generalInterpreter = new Interpreter(
|
423
|
+
// "general",
|
424
|
+
// generalInterpreterContext
|
425
|
+
// );
|
426
|
+
// // const ccacheMemory = await cacheMemory.findSimilarActions(
|
427
|
+
// // "le top 3 des chaines par TVL en DeFi",
|
428
|
+
// // {
|
429
|
+
// // similarityThreshold: 50,
|
430
|
+
// // maxResults: 5,
|
431
|
+
// // userId: "1",
|
432
|
+
// // scope: MemoryScope.GLOBAL,
|
433
|
+
// // }
|
434
|
+
// // );
|
435
|
+
// // console.log("✅ RECENT_ACTIONS: ", ccacheMemory);
|
436
|
+
// const agent = new Agent({
|
437
|
+
// interpreters: [securityInterpreter, marketInterpreter, generalInterpreter],
|
438
|
+
// orchestrator,
|
439
|
+
// memory: {
|
440
|
+
// persistent: memory,
|
441
|
+
// cache: cacheMemory,
|
442
|
+
// },
|
443
|
+
// stream: false,
|
444
|
+
// maxEvaluatorIteration: 1,
|
445
|
+
// });
|
446
|
+
// const prompt = "tu pourrais analyser le bnb/usdt";
|
447
|
+
// // const result = await agent.process(prompt, {});
|
448
|
+
// const scheduler = new ActionScheduler(
|
449
|
+
// new ActionQueueManager(orchestrator.tools),
|
450
|
+
// orchestrator,
|
451
|
+
// {
|
452
|
+
// onActionScheduled: (action: ScheduledAction) => {
|
453
|
+
// console.log("🗓️ Action programmée:", {
|
454
|
+
// id: action.id,
|
455
|
+
// name: action.action.name,
|
456
|
+
// scheduledTime: action.scheduledTime,
|
457
|
+
// });
|
458
|
+
// },
|
459
|
+
// onActionStart: (action: ScheduledAction) => {
|
460
|
+
// console.log("▶️ Action démarrée:", action.id);
|
461
|
+
// },
|
462
|
+
// onActionComplete: (action: ScheduledAction, result: any) => {
|
463
|
+
// console.log("✅ Action terminée:", {
|
464
|
+
// id: action.id,
|
465
|
+
// result,
|
466
|
+
// });
|
467
|
+
// },
|
468
|
+
// onActionFailed: (action: ScheduledAction, error: any) => {
|
469
|
+
// console.error("❌ Action échouée:", {
|
470
|
+
// id: action.id,
|
471
|
+
// error: error.message,
|
472
|
+
// });
|
473
|
+
// },
|
474
|
+
// onActionCancelled: (actionId: string) => {
|
475
|
+
// console.log("🚫 Action annulée:", actionId);
|
476
|
+
// },
|
477
|
+
// }
|
478
|
+
// );
|
479
|
+
// // Test du scheduler
|
480
|
+
// console.log("🕒 Testing scheduler...");
|
481
|
+
// const scheduledTime = new Date(Date.now() + 10000);
|
482
|
+
// const actionId = await scheduler.scheduleAction(
|
483
|
+
// {
|
484
|
+
// name: "hello",
|
485
|
+
// description: "hello",
|
486
|
+
// parameters: z.object({
|
487
|
+
// name: z.string(),
|
488
|
+
// }),
|
489
|
+
// execute: async () => {
|
490
|
+
// console.log("hello");
|
491
|
+
// return "Hello executed!";
|
492
|
+
// },
|
493
|
+
// },
|
494
|
+
// scheduledTime,
|
495
|
+
// "user123",
|
496
|
+
// {
|
497
|
+
// type: "daily",
|
498
|
+
// interval: 1,
|
499
|
+
// }
|
500
|
+
// );
|
501
|
+
// // Attendre 15 secondes
|
502
|
+
// await new Promise((resolve) => setTimeout(resolve, 15000));
|
503
|
+
// console.log("✅ Test terminé");
|
504
|
+
// })();
|