@ai.ntellect/core 0.4.1 → 0.6.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.
Files changed (125) hide show
  1. package/.mocharc.json +1 -1
  2. package/README.md +311 -272
  3. package/dist/graph/controller.js +63 -0
  4. package/dist/graph/engine.js +563 -0
  5. package/dist/index.js +6 -6
  6. package/dist/memory/adapters/meilisearch/index.js +249 -0
  7. package/dist/memory/adapters/redis/index.js +96 -0
  8. package/dist/memory/index.js +9 -0
  9. package/dist/services/agenda.js +115 -0
  10. package/dist/services/embedding.js +40 -0
  11. package/dist/services/queue.js +99 -103
  12. package/dist/test/graph/controller.test.js +170 -0
  13. package/dist/test/graph/engine.test.js +465 -0
  14. package/dist/test/memory/adapters/meilisearch.test.js +250 -0
  15. package/dist/test/memory/adapters/redis.test.js +143 -0
  16. package/dist/test/memory/base.test.js +209 -0
  17. package/dist/test/services/agenda.test.js +230 -0
  18. package/dist/test/services/queue.test.js +258 -0
  19. package/dist/types/index.js +2 -0
  20. package/dist/utils/generate-object.js +32 -11
  21. package/dist/utils/inject-actions.js +2 -2
  22. package/dist/utils/queue-item-transformer.js +2 -2
  23. package/dist/utils/state-manager.js +20 -0
  24. package/graph/controller.ts +60 -0
  25. package/graph/engine.ts +709 -0
  26. package/index.ts +7 -7
  27. package/interfaces/index.ts +119 -0
  28. package/memory/adapters/meilisearch/index.ts +286 -0
  29. package/memory/adapters/redis/index.ts +103 -0
  30. package/memory/index.ts +22 -0
  31. package/package.json +9 -2
  32. package/services/agenda.ts +118 -0
  33. package/services/embedding.ts +26 -0
  34. package/services/queue.ts +5 -32
  35. package/test/.env.test +4 -0
  36. package/test/graph/controller.test.ts +186 -0
  37. package/test/graph/engine.test.ts +563 -0
  38. package/test/memory/adapters/meilisearch.test.ts +297 -0
  39. package/test/memory/adapters/redis.test.ts +160 -0
  40. package/test/memory/base.test.ts +229 -0
  41. package/test/services/agenda.test.ts +280 -0
  42. package/test/services/queue.test.ts +286 -44
  43. package/tsconfig.json +10 -9
  44. package/types/index.ts +270 -0
  45. package/utils/generate-object.js +111 -0
  46. package/utils/generate-object.ts +24 -12
  47. package/utils/header-builder.js +34 -0
  48. package/utils/inject-actions.js +16 -0
  49. package/utils/inject-actions.ts +3 -3
  50. package/utils/queue-item-transformer.js +24 -0
  51. package/utils/queue-item-transformer.ts +8 -11
  52. package/utils/sanitize-results.js +60 -0
  53. package/utils/schema-generator.js +46 -0
  54. package/utils/state-manager.js +20 -0
  55. package/utils/state-manager.ts +30 -0
  56. package/.nvmrc +0 -1
  57. package/README.FR.md +0 -365
  58. package/agent/index.ts +0 -244
  59. package/agent/tools/get-rss.ts +0 -64
  60. package/bull.ts +0 -5
  61. package/dist/agent/index.d.ts +0 -38
  62. package/dist/agent/index.js +0 -143
  63. package/dist/agent/tools/get-rss.d.ts +0 -16
  64. package/dist/agent/tools/get-rss.js +0 -62
  65. package/dist/bull.d.ts +0 -1
  66. package/dist/bull.js +0 -9
  67. package/dist/examples/index.d.ts +0 -2
  68. package/dist/examples/index.js +0 -89
  69. package/dist/index.d.ts +0 -7
  70. package/dist/llm/interpreter/context.d.ts +0 -15
  71. package/dist/llm/interpreter/context.js +0 -89
  72. package/dist/llm/interpreter/index.d.ts +0 -21
  73. package/dist/llm/interpreter/index.js +0 -87
  74. package/dist/llm/memory-manager/context.d.ts +0 -2
  75. package/dist/llm/memory-manager/context.js +0 -22
  76. package/dist/llm/memory-manager/index.d.ts +0 -17
  77. package/dist/llm/memory-manager/index.js +0 -107
  78. package/dist/llm/orchestrator/context.d.ts +0 -2
  79. package/dist/llm/orchestrator/context.js +0 -23
  80. package/dist/llm/orchestrator/index.d.ts +0 -44
  81. package/dist/llm/orchestrator/index.js +0 -139
  82. package/dist/llm/orchestrator/types.d.ts +0 -12
  83. package/dist/memory/cache.d.ts +0 -22
  84. package/dist/memory/cache.js +0 -165
  85. package/dist/memory/persistent.d.ts +0 -57
  86. package/dist/memory/persistent.js +0 -189
  87. package/dist/services/queue.d.ts +0 -13
  88. package/dist/services/redis-cache.d.ts +0 -37
  89. package/dist/services/redis-cache.js +0 -93
  90. package/dist/services/scheduler.d.ts +0 -40
  91. package/dist/services/scheduler.js +0 -99
  92. package/dist/services/telegram-monitor.d.ts +0 -0
  93. package/dist/services/telegram-monitor.js +0 -118
  94. package/dist/t.d.ts +0 -46
  95. package/dist/t.js +0 -102
  96. package/dist/test.d.ts +0 -0
  97. package/dist/test.js +0 -438
  98. package/dist/types.d.ts +0 -258
  99. package/dist/types.js +0 -22
  100. package/dist/utils/generate-object.d.ts +0 -12
  101. package/dist/utils/header-builder.d.ts +0 -11
  102. package/dist/utils/inject-actions.d.ts +0 -2
  103. package/dist/utils/queue-item-transformer.d.ts +0 -7
  104. package/dist/utils/sanitize-results.d.ts +0 -17
  105. package/dist/utils/schema-generator.d.ts +0 -16
  106. package/examples/index.ts +0 -103
  107. package/llm/interpreter/context.ts +0 -101
  108. package/llm/interpreter/index.ts +0 -136
  109. package/llm/memory-manager/context.ts +0 -21
  110. package/llm/memory-manager/index.ts +0 -163
  111. package/llm/orchestrator/context.ts +0 -22
  112. package/llm/orchestrator/index.ts +0 -232
  113. package/llm/orchestrator/types.ts +0 -14
  114. package/memory/cache.ts +0 -221
  115. package/memory/persistent.ts +0 -265
  116. package/services/redis-cache.ts +0 -128
  117. package/services/scheduler.ts +0 -128
  118. package/services/telegram-monitor.ts +0 -138
  119. package/t.py +0 -79
  120. package/t.spec +0 -38
  121. package/t.ts +0 -133
  122. package/test/llm/orchestrator.test.ts +0 -47
  123. package/test/llm/synthesizer.test.ts +0 -31
  124. package/types.ts +0 -288
  125. /package/dist/{llm/orchestrator/types.js → interfaces/index.js} +0 -0
@@ -1,189 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PersistentMemory = void 0;
4
- const ai_1 = require("ai");
5
- const text_splitter_1 = require("langchain/text_splitter");
6
- /**
7
- * Handles persistent memory storage using Meilisearch API
8
- */
9
- class PersistentMemory {
10
- constructor(options) {
11
- this.host = options.host;
12
- this.apiKey = options.apiKey;
13
- this.INDEX_PREFIX = options.indexPrefix || "memory";
14
- this.embeddingModel = options.embeddingModel;
15
- }
16
- /**
17
- * Initialize indexes
18
- */
19
- async init() {
20
- try {
21
- // Create or get main index
22
- await this._getOrCreateIndex(this.INDEX_PREFIX);
23
- console.log(`✅ Index '${this.INDEX_PREFIX}' initialized successfully`);
24
- }
25
- catch (error) {
26
- console.error(`❌ Failed to initialize index: ${error}`);
27
- throw error;
28
- }
29
- }
30
- /**
31
- * Make API request to Meilisearch
32
- */
33
- async _makeRequest(path, options = {}) {
34
- const url = `${this.host}${path}`;
35
- console.log("🔍 Making request to Meilisearch:", url);
36
- const response = await fetch(url, {
37
- ...options,
38
- headers: {
39
- "Content-Type": "application/json",
40
- Authorization: `Bearer ${this.apiKey}`,
41
- ...options.headers,
42
- },
43
- });
44
- if (!response.ok) {
45
- console.log({ response });
46
- throw new Error(`Meilisearch API error: ${response.statusText}`);
47
- }
48
- return response.json();
49
- }
50
- /**
51
- * Get or create an index with proper settings
52
- */
53
- async _getOrCreateIndex(indexName) {
54
- try {
55
- // Check if index exists first
56
- const indexExists = await this._makeRequest(`/indexes/${indexName}`, {
57
- method: "GET",
58
- }).catch(() => false);
59
- if (!indexExists) {
60
- console.log(`Creating new index: ${indexName}`);
61
- await this._makeRequest("/indexes", {
62
- method: "POST",
63
- body: JSON.stringify({
64
- uid: indexName,
65
- primaryKey: "id",
66
- }),
67
- });
68
- }
69
- // Update index settings
70
- const settings = {
71
- searchableAttributes: ["query", "purpose", "chunks.content"],
72
- sortableAttributes: ["createdAt"],
73
- };
74
- await this._makeRequest(`/indexes/${indexName}/settings`, {
75
- method: "PATCH",
76
- body: JSON.stringify(settings),
77
- });
78
- console.log(`Index ${indexName} configured successfully`);
79
- }
80
- catch (error) {
81
- console.error(`Failed to configure index ${indexName}:`, error);
82
- throw error;
83
- }
84
- }
85
- async processContent(content) {
86
- // Split content into chunks
87
- const textSplitter = new text_splitter_1.RecursiveCharacterTextSplitter({
88
- chunkSize: 1000,
89
- });
90
- const chunks = await textSplitter.createDocuments([content]);
91
- // Generate embeddings for all chunks
92
- const { embeddings } = await (0, ai_1.embedMany)({
93
- model: this.embeddingModel,
94
- values: chunks.map((chunk) => chunk.pageContent),
95
- });
96
- // Create processed chunks with embeddings
97
- return chunks.map((chunk, i) => ({
98
- content: chunk.pageContent,
99
- embedding: embeddings[i],
100
- }));
101
- }
102
- /**
103
- * Store a memory in the database
104
- */
105
- async createMemory(memory) {
106
- try {
107
- console.log(`📝 Creating memory in index: ${this.INDEX_PREFIX}`);
108
- // Process content into chunks with embeddings
109
- const chunks = await this.processContent(memory.data);
110
- // Generate unique ID if not provided
111
- const id = memory.id || crypto.randomUUID();
112
- const document = {
113
- ...memory,
114
- chunks,
115
- createdAt: memory.createdAt.toISOString(),
116
- };
117
- const response = await this._makeRequest(`/indexes/${this.INDEX_PREFIX}/documents`, {
118
- method: "POST",
119
- body: JSON.stringify([document]),
120
- });
121
- console.log("✅ Memory created successfully", { id });
122
- return response;
123
- }
124
- catch (error) {
125
- console.error("❌ Failed to create memory:", error);
126
- throw error;
127
- }
128
- }
129
- /**
130
- * Find best matching memories
131
- */
132
- async findRelevantDocuments(query, options = {}) {
133
- console.log(`\n🔍 Searching in index: ${this.INDEX_PREFIX}`);
134
- console.log("Query:", query);
135
- try {
136
- // Generate embedding for the query
137
- const { embedding: queryEmbedding } = await (0, ai_1.embed)({
138
- model: this.embeddingModel,
139
- value: query,
140
- });
141
- // Search in the index
142
- const searchResults = await this._makeRequest(`/indexes/${this.INDEX_PREFIX}/search`, {
143
- method: "POST",
144
- body: JSON.stringify({
145
- q: query,
146
- limit: options.maxResults || 10,
147
- }),
148
- });
149
- if (!searchResults?.hits?.length) {
150
- console.log("❌ No matches found");
151
- return [];
152
- }
153
- // Process and filter results using cosine similarity
154
- const results = searchResults.hits
155
- .flatMap((hit) => {
156
- const chunkSimilarities = hit.chunks.map((chunk) => ({
157
- query: hit.query,
158
- data: hit.data,
159
- similarityPercentage: ((0, ai_1.cosineSimilarity)(queryEmbedding, chunk.embedding) + 1) * 50,
160
- createdAt: hit.createdAt,
161
- }));
162
- return chunkSimilarities.reduce((best, current) => current.similarityPercentage > best.similarityPercentage
163
- ? current
164
- : best, chunkSimilarities[0]);
165
- })
166
- .filter((match) => match.similarityPercentage >= (options.similarityThreshold || 70))
167
- .sort((a, b) => b.similarityPercentage - a.similarityPercentage);
168
- console.log(`✨ Found ${results.length} relevant matches`);
169
- return results.map((result) => ({
170
- query: result.query,
171
- data: result.data,
172
- createdAt: result.createdAt,
173
- }));
174
- }
175
- catch (error) {
176
- console.error("❌ Search failed:", error);
177
- return [];
178
- }
179
- }
180
- /**
181
- * Delete memories for a given scope and user
182
- */
183
- async deleteMemories() {
184
- return this._makeRequest(`/indexes/${this.INDEX_PREFIX}`, {
185
- method: "DELETE",
186
- });
187
- }
188
- }
189
- exports.PersistentMemory = PersistentMemory;
@@ -1,13 +0,0 @@
1
- import { ActionSchema, QueueCallbacks, QueueItem, QueueResult } from "../types";
2
- export declare class ActionQueueManager {
3
- private queue;
4
- private results;
5
- private callbacks;
6
- private actions;
7
- private isProcessing;
8
- constructor(actions: ActionSchema[], callbacks?: QueueCallbacks);
9
- addToQueue(actions: QueueItem | QueueItem[]): void;
10
- processQueue(): Promise<QueueResult[] | undefined>;
11
- private formatArguments;
12
- private executeAction;
13
- }
@@ -1,37 +0,0 @@
1
- export interface CacheConfig {
2
- host: string;
3
- port: number;
4
- password?: string;
5
- ttl?: number;
6
- cleanupInterval?: string;
7
- }
8
- export declare class RedisCache {
9
- private redis;
10
- private readonly defaultTTL;
11
- private readonly cleanupJob;
12
- constructor(config: CacheConfig);
13
- /**
14
- * Store previous actions for a specific request
15
- */
16
- storePreviousActions(requestId: string, actions: any[]): Promise<void>;
17
- /**
18
- * Get previous actions for a specific request
19
- */
20
- getPreviousActions(requestId: string): Promise<any[]>;
21
- /**
22
- * Store a recent message
23
- */
24
- storeRecentMessage(message: string, metadata?: Record<string, any>): Promise<void>;
25
- /**
26
- * Get recent messages
27
- */
28
- getRecentMessages(limit?: number): Promise<any[]>;
29
- /**
30
- * Cleanup expired keys
31
- */
32
- private cleanup;
33
- /**
34
- * Stop the cleanup job and close Redis connection
35
- */
36
- close(): Promise<void>;
37
- }
@@ -1,93 +0,0 @@
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.RedisCache = void 0;
7
- const ioredis_1 = __importDefault(require("ioredis"));
8
- const node_cron_1 = __importDefault(require("node-cron"));
9
- class RedisCache {
10
- constructor(config) {
11
- this.redis = new ioredis_1.default({
12
- host: config.host,
13
- port: config.port,
14
- password: config.password,
15
- });
16
- this.defaultTTL = config.ttl || 1800; // 30 minutes in seconds
17
- // Setup cleanup job (default: every 30 minutes)
18
- this.cleanupJob = node_cron_1.default.schedule(config.cleanupInterval || "*/30 * * * *", () => this.cleanup());
19
- }
20
- /**
21
- * Store previous actions for a specific request
22
- */
23
- async storePreviousActions(requestId, actions) {
24
- const key = `previous_actions:${requestId}`;
25
- await this.redis.setex(key, this.defaultTTL, JSON.stringify({
26
- timestamp: new Date().toISOString(),
27
- actions,
28
- }));
29
- }
30
- /**
31
- * Get previous actions for a specific request
32
- */
33
- async getPreviousActions(requestId) {
34
- const key = `previous_actions:${requestId}`;
35
- const data = await this.redis.get(key);
36
- if (!data)
37
- return [];
38
- const parsed = JSON.parse(data);
39
- return parsed.actions;
40
- }
41
- /**
42
- * Store a recent message
43
- */
44
- async storeRecentMessage(message, metadata) {
45
- const id = crypto.randomUUID();
46
- const key = `recent_messages:${id}`;
47
- await this.redis.setex(key, this.defaultTTL, JSON.stringify({
48
- timestamp: new Date().toISOString(),
49
- message,
50
- metadata,
51
- }));
52
- }
53
- /**
54
- * Get recent messages
55
- */
56
- async getRecentMessages(limit = 10) {
57
- const keys = await this.redis.keys("recent_messages:*");
58
- if (!keys.length)
59
- return [];
60
- const messages = await Promise.all(keys.map(async (key) => {
61
- const data = await this.redis.get(key);
62
- return data ? JSON.parse(data) : null;
63
- }));
64
- return messages
65
- .filter(Boolean)
66
- .sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime())
67
- .slice(0, limit);
68
- }
69
- /**
70
- * Cleanup expired keys
71
- */
72
- async cleanup() {
73
- console.log("🧹 Starting cache cleanup...");
74
- try {
75
- // Redis automatically removes expired keys
76
- // This is just for logging purposes
77
- const actionKeys = await this.redis.keys("previous_actions:*");
78
- const messageKeys = await this.redis.keys("recent_messages:*");
79
- console.log(`Cache status: ${actionKeys.length} actions, ${messageKeys.length} messages`);
80
- }
81
- catch (error) {
82
- console.error("❌ Cache cleanup error:", error);
83
- }
84
- }
85
- /**
86
- * Stop the cleanup job and close Redis connection
87
- */
88
- async close() {
89
- this.cleanupJob.stop();
90
- await this.redis.quit();
91
- }
92
- }
93
- exports.RedisCache = RedisCache;
@@ -1,40 +0,0 @@
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 {};
@@ -1,99 +0,0 @@
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
@@ -1,118 +0,0 @@
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/t.d.ts DELETED
@@ -1,46 +0,0 @@
1
- export interface NetworkConfig {
2
- name: string;
3
- id?: number;
4
- rpc: string;
5
- explorerUrl: string;
6
- nativeToken: string;
7
- }
8
- export declare const networkConfigs: Record<string, NetworkConfig>;
9
- export declare const getNetworkProvider: (networkName: string) => {
10
- config: NetworkConfig;
11
- };
12
- import { z } from "zod";
13
- export type TransactionPrepared = {
14
- to: string;
15
- value: string;
16
- data?: string;
17
- chain: {
18
- id: number;
19
- rpc: string;
20
- };
21
- type: "transfer" | "approve" | "swap";
22
- method?: string;
23
- params?: any[];
24
- };
25
- export declare const prepareEvmTransaction: {
26
- name: string;
27
- description: string;
28
- parameters: z.ZodObject<{
29
- walletAddress: z.ZodString;
30
- amount: z.ZodString;
31
- network: z.ZodString;
32
- }, "strip", z.ZodTypeAny, {
33
- walletAddress: string;
34
- amount: string;
35
- network: string;
36
- }, {
37
- walletAddress: string;
38
- amount: string;
39
- network: string;
40
- }>;
41
- execute: ({ walletAddress, amount, network, }: {
42
- walletAddress: string;
43
- amount: string;
44
- network: string;
45
- }) => Promise<TransactionPrepared>;
46
- };