overmind-mcp 2.0.0 → 2.0.2

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.
@@ -0,0 +1,199 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * ═══════════════════════════════════════════════════════════════════════════════
4
+ * SETUP OVERMIND DATABASE (PostgreSQL Existant)
5
+ * ═══════════════════════════════════════════════════════════════════════════════
6
+ * Script qui initialise la base de données OverMind dans votre PostgreSQL existant
7
+ *
8
+ * Prérequis:
9
+ * - PostgreSQL + pgvector déjà en Docker (container: postgres-pgvector)
10
+ * - Node.js installé
11
+ *
12
+ * Usage:
13
+ * node scripts/setup-overmind-db.js
14
+ * ═══════════════════════════════════════════════════════════════════════════════
15
+ */
16
+
17
+ import { Client } from 'pg';
18
+ import { readFileSync } from 'fs';
19
+ import { dirname, join } from 'path';
20
+ import { fileURLToPath } from 'url';
21
+
22
+ const __filename = fileURLToPath(import.meta.url);
23
+ const __dirname = dirname(__filename);
24
+
25
+ // ═══════════════════════════════════════════════════════════════════════════════
26
+ // CONFIGURATION
27
+ // ═══════════════════════════════════════════════════════════════════════════════
28
+
29
+ const DB_CONFIG = {
30
+ host: process.env.POSTGRES_HOST || 'localhost',
31
+ port: parseInt(process.env.POSTGRES_PORT || '5432', 10),
32
+ user: process.env.POSTGRES_USER || 'postgres',
33
+ password: process.env.POSTGRES_PASSWORD || 'postgres',
34
+ database: 'postgres', // Se connecter à postgres pour créer la DB
35
+ };
36
+
37
+ const OVERMIND_DB_NAME = 'overmind_memory';
38
+
39
+ // ═══════════════════════════════════════════════════════════════════════════════
40
+ // FUNCTIONS
41
+ // ═══════════════════════════════════════════════════════════════════════════════
42
+
43
+ async function checkPgVectorExtension(client) {
44
+ console.log('🔍 Vérification extension pgvector...');
45
+
46
+ try {
47
+ const res = await client.query(`
48
+ SELECT 1 FROM pg_available_extensions
49
+ WHERE name = 'vector'
50
+ `);
51
+
52
+ if (res.rows.length === 0) {
53
+ console.error('❌ pgvector n\'est pas installé !');
54
+ console.error(' Installez-le avec: CREATE EXTENSION vector;');
55
+ throw new Error('pgvector extension not found');
56
+ }
57
+
58
+ console.log('✅ Extension pgvector trouvée');
59
+ } catch (error) {
60
+ console.error('❌ Erreur vérification pgvector:', error.message);
61
+ throw error;
62
+ }
63
+ }
64
+
65
+ async function createDatabase(client) {
66
+ console.log(`🔍 Vérification base de données ${OVERMIND_DB_NAME}...`);
67
+
68
+ try {
69
+ // Vérifier si la DB existe déjà
70
+ const checkRes = await client.query(
71
+ 'SELECT 1 FROM pg_database WHERE datname = $1',
72
+ [OVERMIND_DB_NAME]
73
+ );
74
+
75
+ if (checkRes.rows.length > 0) {
76
+ console.log(`ℹ️ Base de données ${OVERMIND_DB_NAME} existe déjà`);
77
+ return;
78
+ }
79
+
80
+ // Créer la DB
81
+ console.log(`🏗️ Création base de données ${OVERMIND_DB_NAME}...`);
82
+ await client.query(`CREATE DATABASE "${OVERMIND_DB_NAME}"`);
83
+ console.log(`✅ Base de données ${OVERMIND_DB_NAME} créée`);
84
+
85
+ } catch (error) {
86
+ if (error.code === '42P04') {
87
+ // Duplicate database - c'est ok
88
+ console.log(`ℹ️ Base de données ${OVERMIND_DB_NAME} existe déjà`);
89
+ return;
90
+ }
91
+ console.error('❌ Erreur création DB:', error.message);
92
+ throw error;
93
+ }
94
+ }
95
+
96
+ async function initializeOvermindDb() {
97
+ console.log(`🔍 Initialisation base de données ${OVERMIND_DB_NAME}...`);
98
+
99
+ const client = new Client({
100
+ ...DB_CONFIG,
101
+ database: OVERMIND_DB_NAME,
102
+ });
103
+
104
+ try {
105
+ await client.connect();
106
+ console.log(`✅ Connecté à ${OVERMIND_DB_NAME}`);
107
+
108
+ // Activer pgvector
109
+ console.log('🔧 Activation extension pgvector...');
110
+ await client.query('CREATE EXTENSION IF NOT EXISTS vector');
111
+ console.log('✅ Extension pgvector activée');
112
+
113
+ // Créer les tables (via init-db.sql)
114
+ const initSqlPath = join(__dirname, '../init-db.sql');
115
+ try {
116
+ const initSql = readFileSync(initSqlPath, 'utf8');
117
+ console.log('🔧 Exécution init-db.sql...');
118
+ await client.query(initSql);
119
+ console.log('✅ Tables initialisées');
120
+ } catch (error) {
121
+ console.warn('⚠️ Erreur init-db.sql (peut-être déjà exécuté):', error.message);
122
+ }
123
+
124
+ } finally {
125
+ await client.end();
126
+ console.log(`✅ Déconnecté de ${OVERMIND_DB_NAME}`);
127
+ }
128
+ }
129
+
130
+ async function main() {
131
+ console.log('╔══════════════════════════════════════════════════════════════════╗');
132
+ console.log('║ SETUP OVERMIND DATABASE (PostgreSQL Existant) ║');
133
+ console.log('╚══════════════════════════════════════════════════════════════════╝');
134
+ console.log('');
135
+
136
+ const client = new Client(DB_CONFIG);
137
+
138
+ try {
139
+ // Se connecter à postgres
140
+ console.log('🔌 Connexion à PostgreSQL...');
141
+ await client.connect();
142
+ console.log(`✅ Connecté à PostgreSQL (${DB_CONFIG.host}:${DB_CONFIG.port})`);
143
+ console.log('');
144
+
145
+ // Étape 1: Vérifier pgvector
146
+ await checkPgVectorExtension(client);
147
+ console.log('');
148
+
149
+ // Étape 2: Créer la DB
150
+ await createDatabase(client);
151
+ console.log('');
152
+
153
+ // Fermer la connexion postgres
154
+ await client.end();
155
+
156
+ // Étape 3: Initialiser la DB OverMind
157
+ await initializeOvermindDb();
158
+
159
+ console.log('');
160
+ console.log('╔══════════════════════════════════════════════════════════════════╗');
161
+ console.log('║ ✅ SETUP TERMINÉ AVEC SUCCÈS ║');
162
+ console.log('║ ║');
163
+ console.log('║ Prochaine étape: ║');
164
+ console.log('║ 1. docker-compose -f docker-compose.overmind.yml up -d ║');
165
+ console.log('║ 2. pnpm run build ║');
166
+ console.log('║ 3. pnpm run dev ║');
167
+ console.log('╚══════════════════════════════════════════════════════════════════╝');
168
+
169
+ } catch (error) {
170
+ console.error('');
171
+ console.error('╔══════════════════════════════════════════════════════════════════╗');
172
+ console.error('║ ❌ ERREUR SETUP ║');
173
+ console.error('╚══════════════════════════════════════════════════════════════════╝');
174
+ console.error('');
175
+ console.error('Erreur:', error.message);
176
+
177
+ if (error.code === 'ECONNREFUSED') {
178
+ console.error('');
179
+ console.error('💡 Assurez-vous que PostgreSQL est démarré:');
180
+ console.error(' docker ps | grep postgres-pgvector');
181
+ console.error('');
182
+ console.error('💡 Vérifiez les credentials dans .env:');
183
+ console.error(' POSTGRES_HOST=' + DB_CONFIG.host);
184
+ console.error(' POSTGRES_PORT=' + DB_CONFIG.port);
185
+ console.error(' POSTGRES_USER=' + DB_CONFIG.user);
186
+ console.error(' POSTGRES_PASSWORD=*** (votre mot de passe)');
187
+ }
188
+
189
+ process.exit(1);
190
+ }
191
+ }
192
+
193
+ // ═══════════════════════════════════════════════════════════════════════════════
194
+ // MAIN
195
+ // ═══════════════════════════════════════════════════════════════════════════════
196
+
197
+ if (import.meta.url === `file://${process.argv[1]}`) {
198
+ main();
199
+ }
@@ -0,0 +1,264 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * ═══════════════════════════════════════════════════════════════════════════════
4
+ * SETUP WINDOWS SCRIPT
5
+ * ═══════════════════════════════════════════════════════════════════════════════
6
+ * Script d'installation automatique pour OverMind-MCP sur Windows
7
+ * avec PostgreSQL + pgvector existant en Docker.
8
+ *
9
+ * Usage:
10
+ * node scripts/setup-windows.js
11
+ * ═══════════════════════════════════════════════════════════════════════════════
12
+ */
13
+
14
+ import { execSync } from 'child_process';
15
+ import { existsSync, readFileSync, writeFileSync, copyFileSync } from 'fs';
16
+ import { join } from 'path';
17
+ import { fileURLToPath } from 'url';
18
+ import { dirname } from 'path';
19
+
20
+ const __filename = fileURLToPath(import.meta.url);
21
+ const __dirname = dirname(__filename);
22
+ const projectRoot = join(__dirname, '..');
23
+
24
+ // ═══════════════════════════════════════════════════════════════════════════════
25
+ // UTILITIES
26
+ // ═══════════════════════════════════════════════════════════════════════════════
27
+
28
+ function runCommand(command, description) {
29
+ console.log(`\n🔧 ${description}`);
30
+ console.log(` $ ${command}`);
31
+ try {
32
+ execSync(command, { cwd: projectRoot, stdio: 'inherit' });
33
+ console.log(`✅ ${description} terminé`);
34
+ return true;
35
+ } catch (error) {
36
+ console.error(`❌ Erreur: ${error.message}`);
37
+ return false;
38
+ }
39
+ }
40
+
41
+ function logSection(title) {
42
+ console.log('\n╔══════════════════════════════════════════════════════════════════╗');
43
+ console.log(`║ ${title.padEnd(64)} ║`);
44
+ console.log('╚══════════════════════════════════════════════════════════════════╝');
45
+ }
46
+
47
+ // ═══════════════════════════════════════════════════════════════════════════════
48
+ // CHECKS
49
+ // ═══════════════════════════════════════════════════════════════════════════════
50
+
51
+ function checkPrerequisites() {
52
+ logSection('VÉRIFICATION PRÉREQUIS');
53
+
54
+ // Check Node.js
55
+ try {
56
+ const nodeVersion = execSync('node --version', { encoding: 'utf8' }).trim();
57
+ console.log(`✅ Node.js: ${nodeVersion}`);
58
+ } catch {
59
+ console.error('❌ Node.js non trouvé. Installez Node.js 20+');
60
+ return false;
61
+ }
62
+
63
+ // Check pnpm
64
+ try {
65
+ const pnpmVersion = execSync('pnpm --version', { encoding: 'utf8' }).trim();
66
+ console.log(`✅ pnpm: ${pnpmVersion}`);
67
+ } catch {
68
+ console.error('❌ pnpm non trouvé. Installez pnpm:');
69
+ console.error(' npm install -g pnpm');
70
+ return false;
71
+ }
72
+
73
+ // Check Docker
74
+ try {
75
+ const dockerVersion = execSync('docker --version', { encoding: 'utf8' }).trim();
76
+ console.log(`✅ Docker: ${dockerVersion}`);
77
+ } catch {
78
+ console.error('❌ Docker non trouvé. Installez Docker Desktop:');
79
+ console.error(' https://www.docker.com/products/docker-desktop/');
80
+ return false;
81
+ }
82
+
83
+ // Check PostgreSQL container
84
+ try {
85
+ const pgContainers = execSync('docker ps --filter "name=postgres-pgvector" --format "{{.Names}}"', { encoding: 'utf8' }).trim();
86
+ if (pgContainers) {
87
+ console.log(`✅ PostgreSQL container: ${pgContainers}`);
88
+ } else {
89
+ console.error('❌ Container postgres-pgvector non trouvé');
90
+ console.error(' Assurez-vous que PostgreSQL + pgvector tourne en Docker');
91
+ return false;
92
+ }
93
+ } catch {
94
+ console.error('❌ Impossible de vérifier le container PostgreSQL');
95
+ return false;
96
+ }
97
+
98
+ return true;
99
+ }
100
+
101
+ function checkEnvFile() {
102
+ logSection('VÉRIFICATION FICHIER .ENV');
103
+
104
+ const envPath = join(projectRoot, '.env');
105
+ const envExamplePath = join(projectRoot, '.env.example');
106
+
107
+ if (!existsSync(envPath)) {
108
+ console.log('ℹ️ .env non trouvé, création à partir de .env.example...');
109
+ if (existsSync(envExamplePath)) {
110
+ copyFileSync(envExamplePath, envPath);
111
+ console.log('✅ .env créé');
112
+ console.warn('⚠️ ÉDITEZ .env et changez:');
113
+ console.warn(' - POSTGRES_PASSWORD=votre_mot_de_passe');
114
+ console.warn(' - OVERMIND_EMBEDDING_KEY=votre_cle_api');
115
+ return false; // Arrêt pour permettre l'édition
116
+ } else {
117
+ console.error('❌ .env.example non trouvé');
118
+ return false;
119
+ }
120
+ } else {
121
+ console.log('✅ .env existe');
122
+ return true;
123
+ }
124
+ }
125
+
126
+ // ═══════════════════════════════════════════════════════════════════════════════
127
+ // SETUP STEPS
128
+ // ═══════════════════════════════════════════════════════════════════════════════
129
+
130
+ async function setupDatabase() {
131
+ logSection('INITIALISATION BASE DE DONNÉES');
132
+
133
+ return runCommand(
134
+ 'node scripts/setup-overmind-db.js',
135
+ 'Initialisation base OverMind'
136
+ );
137
+ }
138
+
139
+ function startDockerServices() {
140
+ logSection('DÉMARRAGE SERVICES DOCKER');
141
+
142
+ return runCommand(
143
+ 'docker-compose -f docker-compose.overmind.yml up -d',
144
+ 'Démarrage RabbitMQ + Temporal'
145
+ );
146
+ }
147
+
148
+ function buildProject() {
149
+ logSection('BUILD PROJET');
150
+
151
+ return runCommand(
152
+ 'pnpm run build',
153
+ 'Compilation TypeScript'
154
+ );
155
+ }
156
+
157
+ function runTests() {
158
+ logSection('TESTS UNITAIRES');
159
+
160
+ return runCommand(
161
+ 'pnpm run test -- --run',
162
+ 'Exécution tests'
163
+ );
164
+ }
165
+
166
+ // ═══════════════════════════════════════════════════════════════════════════════
167
+ // MAIN
168
+ // ═══════════════════════════════════════════════════════════════════════════════
169
+
170
+ async function main() {
171
+ console.log('╔══════════════════════════════════════════════════════════════════╗');
172
+ console.log('║ ║');
173
+ console.log('║ OVERMIND-MCP: SETUP WINDOWS AUTOMATISÉ ║');
174
+ console.log('║ (PostgreSQL Existant + Docker) ║');
175
+ console.log('║ ║');
176
+ console.log('╚══════════════════════════════════════════════════════════════════╝');
177
+ console.log('');
178
+
179
+ // Check prerequisites
180
+ if (!checkPrerequisites()) {
181
+ console.log('\n❌ PRÉREQUIS NON REMPLIS. Corrigez les problèmes ci-dessus et relancez.');
182
+ process.exit(1);
183
+ }
184
+
185
+ // Check .env file
186
+ const envReady = checkEnvFile();
187
+ if (!envReady) {
188
+ console.log('\n⏸️ SETUP EN PAUSE. Éditez .env avec vos credentials, puis relancez.');
189
+ console.log('\n Commande pour relancer:');
190
+ console.log(' node scripts/setup-windows.js');
191
+ process.exit(0);
192
+ }
193
+
194
+ // Setup database
195
+ const dbSetup = await setupDatabase();
196
+ if (!dbSetup) {
197
+ console.log('\n❌ ERREUR INITIALISATION BASE DE DONNÉES');
198
+ process.exit(1);
199
+ }
200
+
201
+ // Start Docker services
202
+ const dockerStarted = startDockerServices();
203
+ if (!dockerStarted) {
204
+ console.log('\n❌ ERREUR DÉMARRAGE SERVICES DOCKER');
205
+ process.exit(1);
206
+ }
207
+
208
+ // Build project
209
+ const projectBuilt = buildProject();
210
+ if (!projectBuilt) {
211
+ console.log('\n❌ ERREUR BUILD PROJET');
212
+ process.exit(1);
213
+ }
214
+
215
+ // Run tests
216
+ runTests();
217
+
218
+ // Success!
219
+ logSection('✅ SETUP TERMINÉ AVEC SUCCÈS');
220
+
221
+ console.log(`
222
+ 🎉 OVERMIND-MCP EST PRÊT !
223
+
224
+ 📋 SERVICES DÉMARRÉS:
225
+ ✅ PostgreSQL (votre container existant)
226
+ ✅ RabbitMQ (Message Broker)
227
+ ✅ Temporal (Workflow Orchestrator)
228
+ ✅ OverMind Agents (prêt à démarrer)
229
+
230
+ 🌐 INTERFACES DISPONIBLES:
231
+ 📊 RabbitMQ: http://localhost:15672
232
+ 📈 Temporal: http://localhost:8088
233
+ 🗄️ PostgreSQL: localhost:5432
234
+
235
+ 🚀 POUR DÉMARRER OVERMIND:
236
+ pnpm run dev # Mode développement
237
+ pnpm run start # Mode production
238
+
239
+ 📚 DOCUMENTATION:
240
+ - SETUP_WINDOWS.md (guide complet)
241
+ - DEPLOYMENT.md (déploiement avancé)
242
+ - SWARM_USAGE.md (utilisation Swarm)
243
+
244
+ 💡 PREMIER TEST:
245
+ create_agent({
246
+ name: 'test-agent',
247
+ prompt: 'Tu es un agent de test',
248
+ runner: 'claude'
249
+ })
250
+
251
+ ═════════════════════════════════════════════════════════════════════
252
+ `);
253
+ }
254
+
255
+ // ═══════════════════════════════════════════════════════════════════════════════
256
+ // ENTRY POINT
257
+ // ═══════════════════════════════════════════════════════════════════════════════
258
+
259
+ if (import.meta.url === `file://${process.argv[1]}`) {
260
+ main().catch((error) => {
261
+ console.error('\n❌ ERREUR FATALE:', error.message);
262
+ process.exit(1);
263
+ });
264
+ }