File size: 1,478 Bytes
668d995
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
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
/**

 * Configuration for MCP Browser Server

 */

import { readFileSync, existsSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';

const __dirname = dirname(fileURLToPath(import.meta.url));

// Load .env file if it exists
function loadEnv(): Record<string, string> {
    const envPath = join(__dirname, '..', '.env');
    const env: Record<string, string> = {};

    if (existsSync(envPath)) {
        const content = readFileSync(envPath, 'utf-8');
        for (const line of content.split('\n')) {
            const trimmed = line.trim();
            if (trimmed && !trimmed.startsWith('#')) {
                const [key, ...valueParts] = trimmed.split('=');
                if (key) {
                    env[key.trim()] = valueParts.join('=').trim();
                }
            }
        }
    }

    return env;
}

const env = loadEnv();

export const config = {
    browser: {
        type: (env.BROWSER_TYPE || 'msedge') as 'msedge' | 'chromium' | 'firefox',
        userDataDir: env.EDGE_USER_DATA_DIR || undefined,
        profile: env.EDGE_PROFILE || 'Default',
        headless: false, // Keep visible for debugging
    },
    timeouts: {
        navigation: parseInt(env.NAVIGATION_TIMEOUT || '30000', 10),
        action: parseInt(env.ACTION_TIMEOUT || '10000', 10),
    },
    messenger: {
        url: env.MESSENGER_URL || 'https://www.messenger.com',
    },
} as const;