@ai.ntellect/core 0.3.1 → 0.4.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/.nvmrc +1 -0
- package/README.FR.md +201 -261
- package/README.md +208 -260
- package/agent/index.ts +204 -185
- package/agent/tools/get-rss.ts +64 -0
- package/bull.ts +5 -0
- package/dist/agent/index.d.ts +29 -22
- package/dist/agent/index.js +124 -97
- package/dist/agent/tools/get-rss.d.ts +16 -0
- package/dist/agent/tools/get-rss.js +62 -0
- package/dist/bull.d.ts +1 -0
- package/dist/bull.js +9 -0
- package/dist/examples/index.d.ts +2 -0
- package/dist/examples/index.js +89 -0
- package/dist/llm/interpreter/context.d.ts +5 -22
- package/dist/llm/interpreter/context.js +8 -9
- package/dist/llm/interpreter/index.d.ts +9 -5
- package/dist/llm/interpreter/index.js +55 -48
- package/dist/llm/memory-manager/context.d.ts +2 -0
- package/dist/llm/memory-manager/context.js +22 -0
- package/dist/llm/memory-manager/index.d.ts +17 -0
- package/dist/llm/memory-manager/index.js +107 -0
- package/dist/llm/orchestrator/context.d.ts +2 -10
- package/dist/llm/orchestrator/context.js +19 -16
- package/dist/llm/orchestrator/index.d.ts +36 -21
- package/dist/llm/orchestrator/index.js +122 -88
- package/dist/llm/orchestrator/types.d.ts +12 -0
- package/dist/llm/orchestrator/types.js +2 -0
- package/dist/memory/cache.d.ts +6 -6
- package/dist/memory/cache.js +35 -42
- package/dist/memory/persistent.d.ts +9 -13
- package/dist/memory/persistent.js +94 -114
- package/dist/services/redis-cache.d.ts +37 -0
- package/dist/services/redis-cache.js +93 -0
- package/dist/services/scheduler.d.ts +40 -0
- package/dist/services/scheduler.js +99 -0
- package/dist/services/telegram-monitor.d.ts +0 -0
- package/dist/services/telegram-monitor.js +118 -0
- package/dist/test.d.ts +0 -167
- package/dist/test.js +437 -372
- package/dist/types.d.ts +60 -9
- package/dist/utils/generate-object.d.ts +12 -0
- package/dist/utils/generate-object.js +90 -0
- package/dist/utils/header-builder.d.ts +11 -0
- package/dist/utils/header-builder.js +34 -0
- package/dist/utils/inject-actions.js +2 -2
- package/dist/utils/queue-item-transformer.d.ts +2 -2
- package/dist/utils/schema-generator.d.ts +16 -0
- package/dist/utils/schema-generator.js +46 -0
- package/examples/index.ts +103 -0
- package/llm/interpreter/context.ts +20 -8
- package/llm/interpreter/index.ts +81 -54
- package/llm/memory-manager/context.ts +21 -0
- package/llm/memory-manager/index.ts +163 -0
- package/llm/orchestrator/context.ts +20 -13
- package/llm/orchestrator/index.ts +210 -130
- package/llm/orchestrator/types.ts +14 -0
- package/memory/cache.ts +41 -55
- package/memory/persistent.ts +121 -149
- package/package.json +11 -2
- package/services/redis-cache.ts +128 -0
- package/services/scheduler.ts +128 -0
- package/services/telegram-monitor.ts +138 -0
- package/t.py +79 -0
- package/t.spec +38 -0
- package/types.ts +64 -9
- package/utils/generate-object.ts +105 -0
- package/utils/header-builder.ts +40 -0
- package/utils/inject-actions.ts +4 -6
- package/utils/queue-item-transformer.ts +2 -1
- package/utils/schema-generator.ts +73 -0
- package/agent/handlers/ActionHandler.ts +0 -48
- package/agent/handlers/ConfirmationHandler.ts +0 -37
- package/agent/handlers/EventHandler.ts +0 -35
- package/dist/agent/handlers/ActionHandler.d.ts +0 -8
- package/dist/agent/handlers/ActionHandler.js +0 -36
- package/dist/agent/handlers/ConfirmationHandler.d.ts +0 -7
- package/dist/agent/handlers/ConfirmationHandler.js +0 -31
- package/dist/agent/handlers/EventHandler.d.ts +0 -10
- package/dist/agent/handlers/EventHandler.js +0 -34
- package/dist/llm/evaluator/context.d.ts +0 -10
- package/dist/llm/evaluator/context.js +0 -22
- package/dist/llm/evaluator/index.d.ts +0 -16
- package/dist/llm/evaluator/index.js +0 -151
- package/llm/evaluator/context.ts +0 -21
- package/llm/evaluator/index.ts +0 -194
@@ -0,0 +1,40 @@
|
|
1
|
+
import { AgentRuntime } from "../llm/orchestrator";
|
2
|
+
import { RedisCache } from "./redis-cache";
|
3
|
+
interface ScheduledRequest {
|
4
|
+
id: string;
|
5
|
+
originalRequest: string;
|
6
|
+
cronExpression: string;
|
7
|
+
isRecurring: boolean;
|
8
|
+
createdAt: Date;
|
9
|
+
}
|
10
|
+
export declare class TaskScheduler {
|
11
|
+
private scheduledRequests;
|
12
|
+
private cronJobs;
|
13
|
+
private readonly agentRuntime;
|
14
|
+
private readonly cache;
|
15
|
+
constructor(agentRuntime: AgentRuntime, cache: RedisCache);
|
16
|
+
/**
|
17
|
+
* Schedule a new request to be processed later
|
18
|
+
*/
|
19
|
+
scheduleRequest(request: {
|
20
|
+
originalRequest: string;
|
21
|
+
cronExpression: string;
|
22
|
+
}): Promise<string>;
|
23
|
+
/**
|
24
|
+
* Execute a scheduled request by launching a new process
|
25
|
+
*/
|
26
|
+
private executeScheduledRequest;
|
27
|
+
/**
|
28
|
+
* Cancel a scheduled request
|
29
|
+
*/
|
30
|
+
cancelScheduledRequest(requestId: string): boolean;
|
31
|
+
/**
|
32
|
+
* Get all scheduled requests
|
33
|
+
*/
|
34
|
+
getScheduledRequests(): ScheduledRequest[];
|
35
|
+
/**
|
36
|
+
* Stop all cron jobs
|
37
|
+
*/
|
38
|
+
stopAll(): void;
|
39
|
+
}
|
40
|
+
export {};
|
@@ -0,0 +1,99 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.TaskScheduler = void 0;
|
7
|
+
const node_cron_1 = __importDefault(require("node-cron"));
|
8
|
+
class TaskScheduler {
|
9
|
+
constructor(agentRuntime, cache) {
|
10
|
+
this.scheduledRequests = new Map();
|
11
|
+
this.cronJobs = new Map();
|
12
|
+
this.agentRuntime = agentRuntime;
|
13
|
+
this.cache = cache;
|
14
|
+
}
|
15
|
+
/**
|
16
|
+
* Schedule a new request to be processed later
|
17
|
+
*/
|
18
|
+
async scheduleRequest(request) {
|
19
|
+
const id = crypto.randomUUID();
|
20
|
+
const scheduledRequest = {
|
21
|
+
id,
|
22
|
+
originalRequest: request.originalRequest,
|
23
|
+
cronExpression: request.cronExpression,
|
24
|
+
isRecurring: false,
|
25
|
+
createdAt: new Date(),
|
26
|
+
};
|
27
|
+
// Create cron job
|
28
|
+
const cronJob = node_cron_1.default.schedule(request.cronExpression, async () => {
|
29
|
+
await this.executeScheduledRequest(scheduledRequest);
|
30
|
+
if (!scheduledRequest.isRecurring) {
|
31
|
+
this.cancelScheduledRequest(id);
|
32
|
+
}
|
33
|
+
});
|
34
|
+
// Store request and job
|
35
|
+
this.scheduledRequests.set(id, scheduledRequest);
|
36
|
+
this.cronJobs.set(id, cronJob);
|
37
|
+
console.log(`✅ Request scheduled with cron expression: ${request.cronExpression}`);
|
38
|
+
return id;
|
39
|
+
}
|
40
|
+
/**
|
41
|
+
* Execute a scheduled request by launching a new process
|
42
|
+
*/
|
43
|
+
async executeScheduledRequest(request) {
|
44
|
+
try {
|
45
|
+
console.log(`🔄 Executing scheduled request from ${request.createdAt}`);
|
46
|
+
// Récupérer les actions précédentes du cache
|
47
|
+
const previousActions = await this.cache.getPreviousActions(request.id);
|
48
|
+
// Add context about when this request was scheduled
|
49
|
+
const contextualRequest = `You are a scheduler.
|
50
|
+
You were asked to execute this request: ${request.originalRequest}\n
|
51
|
+
Date of the request: ${request.createdAt.toISOString()}\n
|
52
|
+
Act like if you know the request was scheduled.
|
53
|
+
Don't reschedule the same action.
|
54
|
+
Just execute it.`;
|
55
|
+
// Process the request as if it was just received
|
56
|
+
const result = await this.agentRuntime.process({
|
57
|
+
currentContext: contextualRequest,
|
58
|
+
previousActions,
|
59
|
+
});
|
60
|
+
// Store the new actions in cache
|
61
|
+
if (result.actions.length > 0) {
|
62
|
+
await this.cache.storePreviousActions(request.id, result.actions);
|
63
|
+
}
|
64
|
+
console.log(`✅ Scheduled request executed successfully`);
|
65
|
+
}
|
66
|
+
catch (error) {
|
67
|
+
console.error(`❌ Failed to execute scheduled request:`, error);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
/**
|
71
|
+
* Cancel a scheduled request
|
72
|
+
*/
|
73
|
+
cancelScheduledRequest(requestId) {
|
74
|
+
const cronJob = this.cronJobs.get(requestId);
|
75
|
+
if (cronJob) {
|
76
|
+
cronJob.stop();
|
77
|
+
this.cronJobs.delete(requestId);
|
78
|
+
}
|
79
|
+
return this.scheduledRequests.delete(requestId);
|
80
|
+
}
|
81
|
+
/**
|
82
|
+
* Get all scheduled requests
|
83
|
+
*/
|
84
|
+
getScheduledRequests() {
|
85
|
+
return Array.from(this.scheduledRequests.values());
|
86
|
+
}
|
87
|
+
/**
|
88
|
+
* Stop all cron jobs
|
89
|
+
*/
|
90
|
+
stopAll() {
|
91
|
+
for (const [id, cronJob] of this.cronJobs) {
|
92
|
+
cronJob.stop();
|
93
|
+
this.cronJobs.delete(id);
|
94
|
+
this.scheduledRequests.delete(id);
|
95
|
+
}
|
96
|
+
console.log("All scheduled requests stopped");
|
97
|
+
}
|
98
|
+
}
|
99
|
+
exports.TaskScheduler = TaskScheduler;
|
File without changes
|
@@ -0,0 +1,118 @@
|
|
1
|
+
"use strict";
|
2
|
+
// import dotenv from "dotenv";
|
3
|
+
// import promptSync from "prompt-sync";
|
4
|
+
// import { TelegramClient } from "telegram";
|
5
|
+
// import { NewMessage } from "telegram/events";
|
6
|
+
// import { StringSession } from "telegram/sessions";
|
7
|
+
// dotenv.config();
|
8
|
+
// const prompt = promptSync({ sigint: true });
|
9
|
+
// export interface TokenLaunch {
|
10
|
+
// tokenAddress: string;
|
11
|
+
// messageUrl: string;
|
12
|
+
// timestamp: string;
|
13
|
+
// }
|
14
|
+
// export class TelegramMonitor {
|
15
|
+
// private client: TelegramClient;
|
16
|
+
// private botStartTime: Date;
|
17
|
+
// constructor() {
|
18
|
+
// if (!process.env.TELEGRAM_API_ID || !process.env.TELEGRAM_API_HASH) {
|
19
|
+
// throw new Error("TELEGRAM_API_ID and TELEGRAM_API_HASH must be set");
|
20
|
+
// }
|
21
|
+
// this.botStartTime = new Date();
|
22
|
+
// const apiId = parseInt(process.env.TELEGRAM_API_ID);
|
23
|
+
// const apiHash = process.env.TELEGRAM_API_HASH;
|
24
|
+
// // Utiliser une session stockée si disponible
|
25
|
+
// const sessionString = process.env.TELEGRAM_SESSION;
|
26
|
+
// this.client = new TelegramClient(
|
27
|
+
// new StringSession(sessionString),
|
28
|
+
// apiId,
|
29
|
+
// apiHash,
|
30
|
+
// {
|
31
|
+
// connectionRetries: 5,
|
32
|
+
// }
|
33
|
+
// );
|
34
|
+
// }
|
35
|
+
// async connect() {
|
36
|
+
// // Se connecter en tant qu'utilisateur
|
37
|
+
// await this.client.start({
|
38
|
+
// phoneNumber: async () => prompt("Numéro de téléphone ? "),
|
39
|
+
// password: async () => prompt("Mot de passe ? "),
|
40
|
+
// phoneCode: async () => prompt("Code reçu ? "),
|
41
|
+
// onError: (err) => console.log(err),
|
42
|
+
// });
|
43
|
+
// // Sauvegarder la session pour une utilisation ultérieure
|
44
|
+
// console.log("Session string à sauvegarder:", this.client.session.save());
|
45
|
+
// }
|
46
|
+
// async startMonitoring(
|
47
|
+
// channelUsername: string,
|
48
|
+
// callback: {
|
49
|
+
// onNewLaunch: (message: string) => void;
|
50
|
+
// }
|
51
|
+
// ) {
|
52
|
+
// console.log(`Démarrage du monitoring pour ${channelUsername}`);
|
53
|
+
// try {
|
54
|
+
// // S'assurer que le client est connecté
|
55
|
+
// if (!this.client.connected) {
|
56
|
+
// console.log("Client non connecté, tentative de connexion...");
|
57
|
+
// await this.client.connect();
|
58
|
+
// console.log("Client connecté avec succès");
|
59
|
+
// }
|
60
|
+
// console.log("État de la connexion:", this.client.connected);
|
61
|
+
// // Vérifier si le canal existe et est accessible
|
62
|
+
// try {
|
63
|
+
// const channel = await this.client.getEntity(channelUsername);
|
64
|
+
// console.log("Canal trouvé:", channel.id);
|
65
|
+
// } catch (e) {
|
66
|
+
// console.error("Erreur lors de l'accès au canal:", e);
|
67
|
+
// }
|
68
|
+
// this.client.addEventHandler(async (event: any) => {
|
69
|
+
// const message = event.message;
|
70
|
+
// if (!message) {
|
71
|
+
// console.log("Pas de message dans l'événement");
|
72
|
+
// return;
|
73
|
+
// }
|
74
|
+
// if (!message.text) {
|
75
|
+
// console.log("Message sans texte:", message);
|
76
|
+
// return;
|
77
|
+
// }
|
78
|
+
// try {
|
79
|
+
// callback.onNewLaunch(message.text);
|
80
|
+
// } catch (error) {
|
81
|
+
// console.error("Erreur lors du traitement du message:", error);
|
82
|
+
// }
|
83
|
+
// }, new NewMessage({ chats: [channelUsername] }));
|
84
|
+
// console.log("Handler d'événements ajouté avec succès");
|
85
|
+
// } catch (error) {
|
86
|
+
// console.error("Erreur lors du démarrage du monitoring:", error);
|
87
|
+
// }
|
88
|
+
// }
|
89
|
+
// static async generateNewSession() {
|
90
|
+
// // Supprimer la session existante
|
91
|
+
// const client = new TelegramClient(
|
92
|
+
// new StringSession(""),
|
93
|
+
// parseInt(process.env.TELEGRAM_API_ID || ""),
|
94
|
+
// process.env.TELEGRAM_API_HASH || "",
|
95
|
+
// {
|
96
|
+
// connectionRetries: 5,
|
97
|
+
// }
|
98
|
+
// );
|
99
|
+
// // Se connecter en tant qu'utilisateur
|
100
|
+
// await client.start({
|
101
|
+
// phoneNumber: async () => prompt("Numéro de téléphone ? "),
|
102
|
+
// password: async () => prompt("Mot de passe ? "),
|
103
|
+
// phoneCode: async () => prompt("Code reçu ? "),
|
104
|
+
// onError: (err) => console.log(err),
|
105
|
+
// });
|
106
|
+
// // Sauvegarder la nouvelle session pour une utilisation ultérieure
|
107
|
+
// console.log(
|
108
|
+
// "Nouvelle session string à sauvegarder:",
|
109
|
+
// client.session.save()
|
110
|
+
// );
|
111
|
+
// }
|
112
|
+
// }
|
113
|
+
// const telegramMonitor = new TelegramMonitor();
|
114
|
+
// telegramMonitor.startMonitoring("testcalldegen", {
|
115
|
+
// onNewLaunch: (message: string) => {
|
116
|
+
// console.log("Nouveau message:", message);
|
117
|
+
// },
|
118
|
+
// });
|
package/dist/test.d.ts
CHANGED
@@ -1,167 +0,0 @@
|
|
1
|
-
import { z } from "zod";
|
2
|
-
export declare const checkHoneypot: {
|
3
|
-
name: string;
|
4
|
-
description: string;
|
5
|
-
parameters: z.ZodObject<{
|
6
|
-
address: z.ZodString;
|
7
|
-
chainName: z.ZodString;
|
8
|
-
}, "strip", z.ZodTypeAny, {
|
9
|
-
address: string;
|
10
|
-
chainName: string;
|
11
|
-
}, {
|
12
|
-
address: string;
|
13
|
-
chainName: string;
|
14
|
-
}>;
|
15
|
-
execute: ({ address, chainName, }: {
|
16
|
-
address: string;
|
17
|
-
chainName?: string;
|
18
|
-
}) => Promise<{
|
19
|
-
status: string;
|
20
|
-
token: {
|
21
|
-
name: any;
|
22
|
-
symbol: any;
|
23
|
-
address: any;
|
24
|
-
holders: any;
|
25
|
-
};
|
26
|
-
risk: {
|
27
|
-
level: any;
|
28
|
-
score: any;
|
29
|
-
flags: any;
|
30
|
-
};
|
31
|
-
analysis: {
|
32
|
-
isHoneypot: any;
|
33
|
-
reason: any;
|
34
|
-
buyTax: any;
|
35
|
-
sellTax: any;
|
36
|
-
holders: {
|
37
|
-
total: any;
|
38
|
-
successful: any;
|
39
|
-
failed: any;
|
40
|
-
siphoned: any;
|
41
|
-
};
|
42
|
-
};
|
43
|
-
chain: {
|
44
|
-
name: any;
|
45
|
-
id: any;
|
46
|
-
};
|
47
|
-
} | {
|
48
|
-
status: string;
|
49
|
-
message: string;
|
50
|
-
chain: {
|
51
|
-
name: string;
|
52
|
-
id: string;
|
53
|
-
};
|
54
|
-
}>;
|
55
|
-
};
|
56
|
-
export interface NetworkConfig {
|
57
|
-
name: string;
|
58
|
-
id?: number;
|
59
|
-
rpc: string;
|
60
|
-
explorerUrl: string;
|
61
|
-
nativeToken: string;
|
62
|
-
}
|
63
|
-
export declare const networkConfigs: Record<string, NetworkConfig>;
|
64
|
-
export declare const getNetworkProvider: (networkName: string) => {
|
65
|
-
config: NetworkConfig;
|
66
|
-
};
|
67
|
-
export type TransactionPrepared = {
|
68
|
-
to: string;
|
69
|
-
value: string;
|
70
|
-
data?: string;
|
71
|
-
chain: {
|
72
|
-
id: number;
|
73
|
-
rpc: string;
|
74
|
-
};
|
75
|
-
type: "transfer" | "approve" | "swap";
|
76
|
-
method?: string;
|
77
|
-
params?: any[];
|
78
|
-
};
|
79
|
-
export declare const prepareEvmTransaction: {
|
80
|
-
name: string;
|
81
|
-
description: string;
|
82
|
-
parameters: z.ZodObject<{
|
83
|
-
walletAddress: z.ZodString;
|
84
|
-
amount: z.ZodString;
|
85
|
-
network: z.ZodString;
|
86
|
-
}, "strip", z.ZodTypeAny, {
|
87
|
-
walletAddress: string;
|
88
|
-
amount: string;
|
89
|
-
network: string;
|
90
|
-
}, {
|
91
|
-
walletAddress: string;
|
92
|
-
amount: string;
|
93
|
-
network: string;
|
94
|
-
}>;
|
95
|
-
execute: ({ walletAddress, amount, network, }: {
|
96
|
-
walletAddress: string;
|
97
|
-
amount: string;
|
98
|
-
network: string;
|
99
|
-
}) => Promise<TransactionPrepared>;
|
100
|
-
};
|
101
|
-
export declare const fetchMarkPrice: {
|
102
|
-
name: string;
|
103
|
-
description: string;
|
104
|
-
parameters: z.ZodObject<{
|
105
|
-
symbol: z.ZodString;
|
106
|
-
params: z.ZodObject<{
|
107
|
-
subType: z.ZodString;
|
108
|
-
}, "strip", z.ZodTypeAny, {
|
109
|
-
subType: string;
|
110
|
-
}, {
|
111
|
-
subType: string;
|
112
|
-
}>;
|
113
|
-
}, "strip", z.ZodTypeAny, {
|
114
|
-
symbol: string;
|
115
|
-
params: {
|
116
|
-
subType: string;
|
117
|
-
};
|
118
|
-
}, {
|
119
|
-
symbol: string;
|
120
|
-
params: {
|
121
|
-
subType: string;
|
122
|
-
};
|
123
|
-
}>;
|
124
|
-
execute: ({ symbol, params }: {
|
125
|
-
symbol: string;
|
126
|
-
params: any;
|
127
|
-
}) => Promise<import("ccxt").Ticker>;
|
128
|
-
};
|
129
|
-
export declare const getChainsTVL: {
|
130
|
-
name: string;
|
131
|
-
description: string;
|
132
|
-
parameters: z.ZodObject<{
|
133
|
-
limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
134
|
-
}, "strip", z.ZodTypeAny, {
|
135
|
-
limit: number;
|
136
|
-
}, {
|
137
|
-
limit?: number | undefined;
|
138
|
-
}>;
|
139
|
-
execute: ({ limit }: {
|
140
|
-
limit: number;
|
141
|
-
}) => Promise<{
|
142
|
-
summary: {
|
143
|
-
totalTVL: number;
|
144
|
-
numberOfChains: number;
|
145
|
-
};
|
146
|
-
topChains: {
|
147
|
-
name: string;
|
148
|
-
tvl: number;
|
149
|
-
tokenSymbol: string | null;
|
150
|
-
}[];
|
151
|
-
}>;
|
152
|
-
};
|
153
|
-
export declare const getRssNews: {
|
154
|
-
name: string;
|
155
|
-
description: string;
|
156
|
-
parameters: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
157
|
-
execute: () => Promise<{
|
158
|
-
status: string;
|
159
|
-
items: {
|
160
|
-
title: any;
|
161
|
-
content: string;
|
162
|
-
link: any;
|
163
|
-
date: any;
|
164
|
-
source: any;
|
165
|
-
}[];
|
166
|
-
}>;
|
167
|
-
};
|