@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,128 @@
|
|
1
|
+
import Redis from "ioredis";
|
2
|
+
import cron from "node-cron";
|
3
|
+
|
4
|
+
export interface CacheConfig {
|
5
|
+
host: string;
|
6
|
+
port: number;
|
7
|
+
password?: string;
|
8
|
+
ttl?: number; // Time to live in seconds (default 30 minutes)
|
9
|
+
cleanupInterval?: string; // Cron expression (default every 30 minutes)
|
10
|
+
}
|
11
|
+
|
12
|
+
export class RedisCache {
|
13
|
+
private redis: Redis;
|
14
|
+
private readonly defaultTTL: number;
|
15
|
+
private readonly cleanupJob: cron.ScheduledTask;
|
16
|
+
|
17
|
+
constructor(config: CacheConfig) {
|
18
|
+
this.redis = new Redis({
|
19
|
+
host: config.host,
|
20
|
+
port: config.port,
|
21
|
+
password: config.password,
|
22
|
+
});
|
23
|
+
|
24
|
+
this.defaultTTL = config.ttl || 1800; // 30 minutes in seconds
|
25
|
+
|
26
|
+
// Setup cleanup job (default: every 30 minutes)
|
27
|
+
this.cleanupJob = cron.schedule(
|
28
|
+
config.cleanupInterval || "*/30 * * * *",
|
29
|
+
() => this.cleanup()
|
30
|
+
);
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Store previous actions for a specific request
|
35
|
+
*/
|
36
|
+
async storePreviousActions(requestId: string, actions: any[]): Promise<void> {
|
37
|
+
const key = `previous_actions:${requestId}`;
|
38
|
+
await this.redis.setex(
|
39
|
+
key,
|
40
|
+
this.defaultTTL,
|
41
|
+
JSON.stringify({
|
42
|
+
timestamp: new Date().toISOString(),
|
43
|
+
actions,
|
44
|
+
})
|
45
|
+
);
|
46
|
+
}
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Get previous actions for a specific request
|
50
|
+
*/
|
51
|
+
async getPreviousActions(requestId: string): Promise<any[]> {
|
52
|
+
const key = `previous_actions:${requestId}`;
|
53
|
+
const data = await this.redis.get(key);
|
54
|
+
if (!data) return [];
|
55
|
+
|
56
|
+
const parsed = JSON.parse(data);
|
57
|
+
return parsed.actions;
|
58
|
+
}
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Store a recent message
|
62
|
+
*/
|
63
|
+
async storeRecentMessage(
|
64
|
+
message: string,
|
65
|
+
metadata?: Record<string, any>
|
66
|
+
): Promise<void> {
|
67
|
+
const id = crypto.randomUUID();
|
68
|
+
const key = `recent_messages:${id}`;
|
69
|
+
await this.redis.setex(
|
70
|
+
key,
|
71
|
+
this.defaultTTL,
|
72
|
+
JSON.stringify({
|
73
|
+
timestamp: new Date().toISOString(),
|
74
|
+
message,
|
75
|
+
metadata,
|
76
|
+
})
|
77
|
+
);
|
78
|
+
}
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Get recent messages
|
82
|
+
*/
|
83
|
+
async getRecentMessages(limit: number = 10): Promise<any[]> {
|
84
|
+
const keys = await this.redis.keys("recent_messages:*");
|
85
|
+
if (!keys.length) return [];
|
86
|
+
|
87
|
+
const messages = await Promise.all(
|
88
|
+
keys.map(async (key) => {
|
89
|
+
const data = await this.redis.get(key);
|
90
|
+
return data ? JSON.parse(data) : null;
|
91
|
+
})
|
92
|
+
);
|
93
|
+
|
94
|
+
return messages
|
95
|
+
.filter(Boolean)
|
96
|
+
.sort(
|
97
|
+
(a, b) =>
|
98
|
+
new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime()
|
99
|
+
)
|
100
|
+
.slice(0, limit);
|
101
|
+
}
|
102
|
+
|
103
|
+
/**
|
104
|
+
* Cleanup expired keys
|
105
|
+
*/
|
106
|
+
private async cleanup(): Promise<void> {
|
107
|
+
console.log("🧹 Starting cache cleanup...");
|
108
|
+
try {
|
109
|
+
// Redis automatically removes expired keys
|
110
|
+
// This is just for logging purposes
|
111
|
+
const actionKeys = await this.redis.keys("previous_actions:*");
|
112
|
+
const messageKeys = await this.redis.keys("recent_messages:*");
|
113
|
+
console.log(
|
114
|
+
`Cache status: ${actionKeys.length} actions, ${messageKeys.length} messages`
|
115
|
+
);
|
116
|
+
} catch (error) {
|
117
|
+
console.error("❌ Cache cleanup error:", error);
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
/**
|
122
|
+
* Stop the cleanup job and close Redis connection
|
123
|
+
*/
|
124
|
+
async close(): Promise<void> {
|
125
|
+
this.cleanupJob.stop();
|
126
|
+
await this.redis.quit();
|
127
|
+
}
|
128
|
+
}
|
@@ -0,0 +1,128 @@
|
|
1
|
+
import cron from "node-cron";
|
2
|
+
import { AgentRuntime } from "../llm/orchestrator";
|
3
|
+
import { RedisCache } from "./redis-cache";
|
4
|
+
|
5
|
+
interface ScheduledRequest {
|
6
|
+
id: string;
|
7
|
+
originalRequest: string;
|
8
|
+
cronExpression: string;
|
9
|
+
isRecurring: boolean;
|
10
|
+
createdAt: Date;
|
11
|
+
}
|
12
|
+
|
13
|
+
export class TaskScheduler {
|
14
|
+
private scheduledRequests: Map<string, ScheduledRequest> = new Map();
|
15
|
+
private cronJobs: Map<string, cron.ScheduledTask> = new Map();
|
16
|
+
private readonly agentRuntime: AgentRuntime;
|
17
|
+
private readonly cache: RedisCache;
|
18
|
+
|
19
|
+
constructor(agentRuntime: AgentRuntime, cache: RedisCache) {
|
20
|
+
this.agentRuntime = agentRuntime;
|
21
|
+
this.cache = cache;
|
22
|
+
}
|
23
|
+
|
24
|
+
/**
|
25
|
+
* Schedule a new request to be processed later
|
26
|
+
*/
|
27
|
+
async scheduleRequest(request: {
|
28
|
+
originalRequest: string;
|
29
|
+
cronExpression: string;
|
30
|
+
}): Promise<string> {
|
31
|
+
const id = crypto.randomUUID();
|
32
|
+
|
33
|
+
const scheduledRequest: ScheduledRequest = {
|
34
|
+
id,
|
35
|
+
originalRequest: request.originalRequest,
|
36
|
+
cronExpression: request.cronExpression,
|
37
|
+
isRecurring: false,
|
38
|
+
createdAt: new Date(),
|
39
|
+
};
|
40
|
+
|
41
|
+
// Create cron job
|
42
|
+
const cronJob = cron.schedule(request.cronExpression, async () => {
|
43
|
+
await this.executeScheduledRequest(scheduledRequest);
|
44
|
+
|
45
|
+
if (!scheduledRequest.isRecurring) {
|
46
|
+
this.cancelScheduledRequest(id);
|
47
|
+
}
|
48
|
+
});
|
49
|
+
|
50
|
+
// Store request and job
|
51
|
+
this.scheduledRequests.set(id, scheduledRequest);
|
52
|
+
this.cronJobs.set(id, cronJob);
|
53
|
+
|
54
|
+
console.log(
|
55
|
+
`✅ Request scheduled with cron expression: ${request.cronExpression}`
|
56
|
+
);
|
57
|
+
|
58
|
+
return id;
|
59
|
+
}
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Execute a scheduled request by launching a new process
|
63
|
+
*/
|
64
|
+
private async executeScheduledRequest(
|
65
|
+
request: ScheduledRequest
|
66
|
+
): Promise<void> {
|
67
|
+
try {
|
68
|
+
console.log(`🔄 Executing scheduled request from ${request.createdAt}`);
|
69
|
+
|
70
|
+
// Récupérer les actions précédentes du cache
|
71
|
+
const previousActions = await this.cache.getPreviousActions(request.id);
|
72
|
+
|
73
|
+
// Add context about when this request was scheduled
|
74
|
+
const contextualRequest = `You are a scheduler.
|
75
|
+
You were asked to execute this request: ${request.originalRequest}\n
|
76
|
+
Date of the request: ${request.createdAt.toISOString()}\n
|
77
|
+
Act like if you know the request was scheduled.
|
78
|
+
Don't reschedule the same action.
|
79
|
+
Just execute it.`;
|
80
|
+
|
81
|
+
// Process the request as if it was just received
|
82
|
+
const result = await this.agentRuntime.process({
|
83
|
+
currentContext: contextualRequest,
|
84
|
+
previousActions,
|
85
|
+
});
|
86
|
+
|
87
|
+
// Store the new actions in cache
|
88
|
+
if (result.actions.length > 0) {
|
89
|
+
await this.cache.storePreviousActions(request.id, result.actions);
|
90
|
+
}
|
91
|
+
|
92
|
+
console.log(`✅ Scheduled request executed successfully`);
|
93
|
+
} catch (error) {
|
94
|
+
console.error(`❌ Failed to execute scheduled request:`, error);
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
/**
|
99
|
+
* Cancel a scheduled request
|
100
|
+
*/
|
101
|
+
cancelScheduledRequest(requestId: string): boolean {
|
102
|
+
const cronJob = this.cronJobs.get(requestId);
|
103
|
+
if (cronJob) {
|
104
|
+
cronJob.stop();
|
105
|
+
this.cronJobs.delete(requestId);
|
106
|
+
}
|
107
|
+
return this.scheduledRequests.delete(requestId);
|
108
|
+
}
|
109
|
+
|
110
|
+
/**
|
111
|
+
* Get all scheduled requests
|
112
|
+
*/
|
113
|
+
getScheduledRequests(): ScheduledRequest[] {
|
114
|
+
return Array.from(this.scheduledRequests.values());
|
115
|
+
}
|
116
|
+
|
117
|
+
/**
|
118
|
+
* Stop all cron jobs
|
119
|
+
*/
|
120
|
+
stopAll(): void {
|
121
|
+
for (const [id, cronJob] of this.cronJobs) {
|
122
|
+
cronJob.stop();
|
123
|
+
this.cronJobs.delete(id);
|
124
|
+
this.scheduledRequests.delete(id);
|
125
|
+
}
|
126
|
+
console.log("All scheduled requests stopped");
|
127
|
+
}
|
128
|
+
}
|
@@ -0,0 +1,138 @@
|
|
1
|
+
// import dotenv from "dotenv";
|
2
|
+
// import promptSync from "prompt-sync";
|
3
|
+
// import { TelegramClient } from "telegram";
|
4
|
+
// import { NewMessage } from "telegram/events";
|
5
|
+
// import { StringSession } from "telegram/sessions";
|
6
|
+
|
7
|
+
// dotenv.config();
|
8
|
+
|
9
|
+
// const prompt = promptSync({ sigint: true });
|
10
|
+
|
11
|
+
// export interface TokenLaunch {
|
12
|
+
// tokenAddress: string;
|
13
|
+
// messageUrl: string;
|
14
|
+
// timestamp: string;
|
15
|
+
// }
|
16
|
+
|
17
|
+
// export class TelegramMonitor {
|
18
|
+
// private client: TelegramClient;
|
19
|
+
// private botStartTime: Date;
|
20
|
+
|
21
|
+
// constructor() {
|
22
|
+
// if (!process.env.TELEGRAM_API_ID || !process.env.TELEGRAM_API_HASH) {
|
23
|
+
// throw new Error("TELEGRAM_API_ID and TELEGRAM_API_HASH must be set");
|
24
|
+
// }
|
25
|
+
// this.botStartTime = new Date();
|
26
|
+
|
27
|
+
// const apiId = parseInt(process.env.TELEGRAM_API_ID);
|
28
|
+
// const apiHash = process.env.TELEGRAM_API_HASH;
|
29
|
+
|
30
|
+
// // Utiliser une session stockée si disponible
|
31
|
+
// const sessionString = process.env.TELEGRAM_SESSION;
|
32
|
+
// this.client = new TelegramClient(
|
33
|
+
// new StringSession(sessionString),
|
34
|
+
// apiId,
|
35
|
+
// apiHash,
|
36
|
+
// {
|
37
|
+
// connectionRetries: 5,
|
38
|
+
// }
|
39
|
+
// );
|
40
|
+
// }
|
41
|
+
|
42
|
+
// async connect() {
|
43
|
+
// // Se connecter en tant qu'utilisateur
|
44
|
+
// await this.client.start({
|
45
|
+
// phoneNumber: async () => prompt("Numéro de téléphone ? "),
|
46
|
+
// password: async () => prompt("Mot de passe ? "),
|
47
|
+
// phoneCode: async () => prompt("Code reçu ? "),
|
48
|
+
// onError: (err) => console.log(err),
|
49
|
+
// });
|
50
|
+
|
51
|
+
// // Sauvegarder la session pour une utilisation ultérieure
|
52
|
+
// console.log("Session string à sauvegarder:", this.client.session.save());
|
53
|
+
// }
|
54
|
+
|
55
|
+
// async startMonitoring(
|
56
|
+
// channelUsername: string,
|
57
|
+
// callback: {
|
58
|
+
// onNewLaunch: (message: string) => void;
|
59
|
+
// }
|
60
|
+
// ) {
|
61
|
+
// console.log(`Démarrage du monitoring pour ${channelUsername}`);
|
62
|
+
|
63
|
+
// try {
|
64
|
+
// // S'assurer que le client est connecté
|
65
|
+
// if (!this.client.connected) {
|
66
|
+
// console.log("Client non connecté, tentative de connexion...");
|
67
|
+
// await this.client.connect();
|
68
|
+
// console.log("Client connecté avec succès");
|
69
|
+
// }
|
70
|
+
|
71
|
+
// console.log("État de la connexion:", this.client.connected);
|
72
|
+
|
73
|
+
// // Vérifier si le canal existe et est accessible
|
74
|
+
// try {
|
75
|
+
// const channel = await this.client.getEntity(channelUsername);
|
76
|
+
// console.log("Canal trouvé:", channel.id);
|
77
|
+
// } catch (e) {
|
78
|
+
// console.error("Erreur lors de l'accès au canal:", e);
|
79
|
+
// }
|
80
|
+
|
81
|
+
// this.client.addEventHandler(async (event: any) => {
|
82
|
+
// const message = event.message;
|
83
|
+
// if (!message) {
|
84
|
+
// console.log("Pas de message dans l'événement");
|
85
|
+
// return;
|
86
|
+
// }
|
87
|
+
|
88
|
+
// if (!message.text) {
|
89
|
+
// console.log("Message sans texte:", message);
|
90
|
+
// return;
|
91
|
+
// }
|
92
|
+
|
93
|
+
// try {
|
94
|
+
// callback.onNewLaunch(message.text);
|
95
|
+
// } catch (error) {
|
96
|
+
// console.error("Erreur lors du traitement du message:", error);
|
97
|
+
// }
|
98
|
+
// }, new NewMessage({ chats: [channelUsername] }));
|
99
|
+
|
100
|
+
// console.log("Handler d'événements ajouté avec succès");
|
101
|
+
// } catch (error) {
|
102
|
+
// console.error("Erreur lors du démarrage du monitoring:", error);
|
103
|
+
// }
|
104
|
+
// }
|
105
|
+
|
106
|
+
// static async generateNewSession() {
|
107
|
+
// // Supprimer la session existante
|
108
|
+
// const client = new TelegramClient(
|
109
|
+
// new StringSession(""),
|
110
|
+
// parseInt(process.env.TELEGRAM_API_ID || ""),
|
111
|
+
// process.env.TELEGRAM_API_HASH || "",
|
112
|
+
// {
|
113
|
+
// connectionRetries: 5,
|
114
|
+
// }
|
115
|
+
// );
|
116
|
+
|
117
|
+
// // Se connecter en tant qu'utilisateur
|
118
|
+
// await client.start({
|
119
|
+
// phoneNumber: async () => prompt("Numéro de téléphone ? "),
|
120
|
+
// password: async () => prompt("Mot de passe ? "),
|
121
|
+
// phoneCode: async () => prompt("Code reçu ? "),
|
122
|
+
// onError: (err) => console.log(err),
|
123
|
+
// });
|
124
|
+
|
125
|
+
// // Sauvegarder la nouvelle session pour une utilisation ultérieure
|
126
|
+
// console.log(
|
127
|
+
// "Nouvelle session string à sauvegarder:",
|
128
|
+
// client.session.save()
|
129
|
+
// );
|
130
|
+
// }
|
131
|
+
// }
|
132
|
+
|
133
|
+
// const telegramMonitor = new TelegramMonitor();
|
134
|
+
// telegramMonitor.startMonitoring("testcalldegen", {
|
135
|
+
// onNewLaunch: (message: string) => {
|
136
|
+
// console.log("Nouveau message:", message);
|
137
|
+
// },
|
138
|
+
// });
|
package/t.py
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
import os
|
2
|
+
import platform
|
3
|
+
import subprocess
|
4
|
+
import urllib.request
|
5
|
+
import sys
|
6
|
+
|
7
|
+
def download_meilisearch():
|
8
|
+
"""Download the Meilisearch binary for the current OS."""
|
9
|
+
print("Checking operating system...")
|
10
|
+
os_name = platform.system().lower()
|
11
|
+
if os_name == "windows":
|
12
|
+
binary_url = "https://github.com/meilisearch/meilisearch/releases/latest/download/meilisearch-windows-amd64.exe"
|
13
|
+
binary_name = "meilisearch.exe"
|
14
|
+
elif os_name == "darwin": # macOS
|
15
|
+
binary_url = "https://github.com/meilisearch/meilisearch/releases/latest/download/meilisearch-macos-amd64"
|
16
|
+
binary_name = "meilisearch"
|
17
|
+
elif os_name == "linux":
|
18
|
+
binary_url = "https://github.com/meilisearch/meilisearch/releases/latest/download/meilisearch-linux-amd64"
|
19
|
+
binary_name = "meilisearch"
|
20
|
+
else:
|
21
|
+
print(f"Unsupported operating system: {os_name}")
|
22
|
+
sys.exit(1)
|
23
|
+
|
24
|
+
# Download the binary
|
25
|
+
if not os.path.exists(binary_name):
|
26
|
+
print(f"Downloading Meilisearch binary for {os_name}...")
|
27
|
+
try:
|
28
|
+
urllib.request.urlretrieve(binary_url, binary_name)
|
29
|
+
print("Download complete.")
|
30
|
+
except Exception as e:
|
31
|
+
print(f"Failed to download Meilisearch: {e}")
|
32
|
+
sys.exit(1)
|
33
|
+
|
34
|
+
# Add execute permissions for Linux/macOS
|
35
|
+
if os_name != "windows":
|
36
|
+
os.chmod(binary_name, 0o755)
|
37
|
+
else:
|
38
|
+
print("Meilisearch binary already exists.")
|
39
|
+
|
40
|
+
return binary_name
|
41
|
+
|
42
|
+
|
43
|
+
def create_data_directory():
|
44
|
+
"""Create a directory for Meilisearch data if it doesn't exist."""
|
45
|
+
data_dir = "./data"
|
46
|
+
if not os.path.exists(data_dir):
|
47
|
+
print("Creating data directory...")
|
48
|
+
os.makedirs(data_dir)
|
49
|
+
else:
|
50
|
+
print("Data directory already exists.")
|
51
|
+
return data_dir
|
52
|
+
|
53
|
+
def launch_meilisearch(binary_name, data_dir):
|
54
|
+
"""Launch the Meilisearch server."""
|
55
|
+
print("Launching Meilisearch...")
|
56
|
+
try:
|
57
|
+
process = subprocess.Popen(
|
58
|
+
[
|
59
|
+
f"./{binary_name}" if platform.system().lower() != "windows" else binary_name,
|
60
|
+
"--db-path",
|
61
|
+
data_dir,
|
62
|
+
"--master-key",
|
63
|
+
"DEFAULT_MASTER_KEY",
|
64
|
+
],
|
65
|
+
stdout=subprocess.PIPE,
|
66
|
+
stderr=subprocess.PIPE,
|
67
|
+
)
|
68
|
+
print("Meilisearch is running! Access it at http://localhost:7700")
|
69
|
+
for line in iter(process.stdout.readline, b""):
|
70
|
+
print("Meilisearch Log:", line.decode().strip())
|
71
|
+
except Exception as e:
|
72
|
+
print(f"Failed to launch Meilisearch: {e}")
|
73
|
+
sys.exit(1)
|
74
|
+
|
75
|
+
|
76
|
+
if __name__ == "__main__":
|
77
|
+
binary = download_meilisearch()
|
78
|
+
data_directory = create_data_directory()
|
79
|
+
launch_meilisearch(binary, data_directory)
|
package/t.spec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- mode: python ; coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
a = Analysis(
|
5
|
+
['t.py'],
|
6
|
+
pathex=[],
|
7
|
+
binaries=[],
|
8
|
+
datas=[],
|
9
|
+
hiddenimports=[],
|
10
|
+
hookspath=[],
|
11
|
+
hooksconfig={},
|
12
|
+
runtime_hooks=[],
|
13
|
+
excludes=[],
|
14
|
+
noarchive=False,
|
15
|
+
optimize=0,
|
16
|
+
)
|
17
|
+
pyz = PYZ(a.pure)
|
18
|
+
|
19
|
+
exe = EXE(
|
20
|
+
pyz,
|
21
|
+
a.scripts,
|
22
|
+
a.binaries,
|
23
|
+
a.datas,
|
24
|
+
[],
|
25
|
+
name='t',
|
26
|
+
debug=False,
|
27
|
+
bootloader_ignore_signals=False,
|
28
|
+
strip=False,
|
29
|
+
upx=True,
|
30
|
+
upx_exclude=[],
|
31
|
+
runtime_tmpdir=None,
|
32
|
+
console=True,
|
33
|
+
disable_windowed_traceback=False,
|
34
|
+
argv_emulation=False,
|
35
|
+
target_arch=None,
|
36
|
+
codesign_identity=None,
|
37
|
+
entitlements_file=None,
|
38
|
+
)
|
package/types.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Embedding, StreamTextResult } from "ai";
|
1
|
+
import { Embedding, EmbeddingModel, StreamTextResult } from "ai";
|
2
2
|
import { z } from "zod";
|
3
3
|
|
4
4
|
export interface BaseLLM {
|
@@ -146,22 +146,44 @@ export interface SummarizerAgent {
|
|
146
146
|
}
|
147
147
|
|
148
148
|
export interface CacheMemoryOptions {
|
149
|
+
embeddingModel: EmbeddingModel<string>;
|
149
150
|
cacheTTL?: number;
|
150
151
|
redisUrl?: string;
|
151
152
|
cachePrefix?: string;
|
152
153
|
}
|
153
154
|
|
155
|
+
export type GenerateObjectResponse = {
|
156
|
+
shouldContinue: boolean;
|
157
|
+
actions: Array<{
|
158
|
+
name: string;
|
159
|
+
parameters: Array<{
|
160
|
+
name: string;
|
161
|
+
value: any;
|
162
|
+
}>;
|
163
|
+
scheduler?: {
|
164
|
+
isScheduled: boolean;
|
165
|
+
cronExpression: string;
|
166
|
+
reason?: string;
|
167
|
+
};
|
168
|
+
}>;
|
169
|
+
socialResponse?: {
|
170
|
+
shouldRespond: boolean;
|
171
|
+
response?: string;
|
172
|
+
isPartialResponse?: boolean;
|
173
|
+
};
|
174
|
+
interpreter?: string;
|
175
|
+
};
|
176
|
+
|
154
177
|
export interface CreateMemoryInput {
|
155
|
-
|
156
|
-
|
157
|
-
data: string[];
|
178
|
+
query: string;
|
179
|
+
data: any;
|
158
180
|
userId?: string;
|
159
181
|
scope?: MemoryScope;
|
182
|
+
ttl?: number;
|
160
183
|
}
|
161
184
|
|
162
185
|
export interface CacheMemoryType {
|
163
186
|
id: string;
|
164
|
-
type: MemoryType;
|
165
187
|
data: any;
|
166
188
|
query: string;
|
167
189
|
embedding: Embedding;
|
@@ -183,15 +205,15 @@ export interface MemoryChunk {
|
|
183
205
|
|
184
206
|
export type MemoryScopeType = (typeof MemoryScope)[keyof typeof MemoryScope];
|
185
207
|
|
186
|
-
export interface
|
208
|
+
export interface LongTermMemory {
|
187
209
|
id: string;
|
188
210
|
query: string;
|
189
|
-
|
211
|
+
category: string;
|
190
212
|
data: any;
|
191
|
-
|
192
|
-
userId?: string;
|
213
|
+
roomId: string;
|
193
214
|
createdAt: Date;
|
194
215
|
chunks?: MemoryChunk[];
|
216
|
+
tags: string[];
|
195
217
|
}
|
196
218
|
|
197
219
|
export const ActionSchema = z.array(
|
@@ -231,3 +253,36 @@ export interface TransformedQueueItem {
|
|
231
253
|
name: string;
|
232
254
|
parameters: QueueItemParameter[];
|
233
255
|
}
|
256
|
+
|
257
|
+
export interface ScheduledAction {
|
258
|
+
id: string;
|
259
|
+
action: {
|
260
|
+
name: string;
|
261
|
+
parameters: QueueItemParameter[];
|
262
|
+
};
|
263
|
+
scheduledTime: Date;
|
264
|
+
userId: string;
|
265
|
+
status: "pending" | "completed" | "failed";
|
266
|
+
recurrence?: {
|
267
|
+
type: "daily" | "weekly" | "monthly";
|
268
|
+
interval: number;
|
269
|
+
};
|
270
|
+
}
|
271
|
+
|
272
|
+
export interface ScheduledActionEvents {
|
273
|
+
onActionStart?: (action: ScheduledAction) => void;
|
274
|
+
onActionComplete?: (action: ScheduledAction, result: any) => void;
|
275
|
+
onActionFailed?: (action: ScheduledAction, error: Error) => void;
|
276
|
+
onActionScheduled?: (action: ScheduledAction) => void;
|
277
|
+
onActionCancelled?: (actionId: string) => void;
|
278
|
+
}
|
279
|
+
|
280
|
+
export interface WorkflowPattern {
|
281
|
+
query: string;
|
282
|
+
actions: Array<{
|
283
|
+
done: boolean;
|
284
|
+
name: string;
|
285
|
+
result: string;
|
286
|
+
}>;
|
287
|
+
success: boolean;
|
288
|
+
}
|