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AI,wBACjB,EAAsB,KAAK,KAAK,EAAW,QAAS,aACpD,OAAO,KAAK,CAAE,uBAAuB,gEAErC,EACA,cAAc,WAAW,CAAE,yBAG3B,OAAO,MAAM,mEACb,cAAc,WAAW,CAAC,IAE9B,0BAAyB,UACrB,OAAO,KAAK,yCACN,cAAc,yBAAyB,IAEjD,KAAK,GAAQ,OAAM,IACf,OAAO,MAAM,CAAE,IAAK,GAAS,0BAC7B,QAAQ,KAAK,EAAE,GACjB,IACH,OAAM,IACL,OAAO,MAAM,CAAE,IAAK,GAAa,4CACjC,QAAQ,KAAK,EAAE","file":"/npm/vibe-coder-mcp@0.3.5/build/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/vibe-coder-mcp@0.3.5/build/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","#!/usr/bin/env node\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { SSEServerTransport } from \"@modelcontextprotocol/sdk/server/sse.js\";\nimport express from \"express\";\nimport cors from \"cors\";\nimport dotenv from \"dotenv\";\nimport path from 'path';\nimport { fileURLToPath } from 'url';\nimport logger, { registerShutdownCallback } from \"./logger.js\";\nimport { initializeToolEmbeddings } from './services/routing/embeddingStore.js';\nimport { OpenRouterConfigManager } from './utils/openrouter-config-manager.js';\nimport { ToolRegistry } from './services/routing/toolRegistry.js';\nimport { sseNotifier } from './services/sse-notifier/index.js';\nimport { transportManager } from './services/transport-manager/index.js';\nimport { PortAllocator } from './utils/port-allocator.js';\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\nconst envPath = path.resolve(__dirname, '../.env');\nconst dotenvResult = dotenv.config({ path: envPath });\nif (dotenvResult.error) {\n    logger.warn({ err: dotenvResult.error, path: envPath }, `Could not load .env file from explicit path. Environment variables might be missing.`);\n}\nelse {\n    logger.info({ path: envPath, loaded: dotenvResult.parsed ? Object.keys(dotenvResult.parsed) : [] }, `Loaded environment variables from .env file.`);\n}\nconst isMessageHandlingTransport = (t) => t !== null && typeof t === 'object' && 'handlePostMessage' in t && typeof t.handlePostMessage === 'function';\nconst args = process.argv.slice(2);\nconst useSSE = args.includes('--sse');\nasync function main(mcpServer) {\n    try {\n        if (useSSE) {\n            const app = express();\n            app.use(cors());\n            app.use(express.json());\n            const allocatedSsePort = transportManager.getServicePort('sse');\n            const port = allocatedSsePort ||\n                (process.env.SSE_PORT ? parseInt(process.env.SSE_PORT) : undefined) ||\n                (process.env.PORT ? parseInt(process.env.PORT) : 3000);\n            logger.debug({\n                allocatedSsePort,\n                envSsePort: process.env.SSE_PORT,\n                envPort: process.env.PORT,\n                finalPort: port\n            }, 'SSE server port selection');\n            app.get('/health', (req, res) => {\n                res.status(200).json({ status: 'ok' });\n            });\n            app.get('/sse', (req, res) => {\n                const sessionId = req.query.sessionId || `sse-${Math.random().toString(36).substring(2)}`;\n                const transport = new SSEServerTransport('/messages', res);\n                req.sessionId = sessionId;\n                logger.info({ sessionId, transportSessionId: transport.sessionId }, 'Established SSE connection');\n                mcpServer.connect(transport).catch((error) => {\n                    logger.error({ err: error }, 'Failed to connect transport');\n                });\n            });\n            app.post('/messages', async (req, res) => {\n                if (!req.body) {\n                    return res.status(400).json({ error: 'Invalid request body' });\n                }\n                try {\n                    const sessionId = req.query.sessionId || req.body.session_id;\n                    if (!sessionId) {\n                        return res.status(400).json({ error: 'Missing session ID. Establish an SSE connection first.' });\n                    }\n                    const transport = mcpServer.server.transport;\n                    if (!transport) {\n                        return res.status(400).json({ error: 'No active SSE connection' });\n                    }\n                    if (isMessageHandlingTransport(transport)) {\n                        const context = {\n                            sessionId,\n                            transportType: sessionId === 'stdio-session' ? 'stdio' : 'sse'\n                        };\n                        await transport.handlePostMessage(req, res, context);\n                    }\n                    else {\n                        logger.error('Active transport does not support handlePostMessage or is not defined.');\n                        if (!res.headersSent) {\n                            res.status(500).json({ error: 'Internal server error: Cannot handle POST message.' });\n                        }\n                        return;\n                    }\n                }\n                catch (error) {\n                    logger.error({ err: error }, 'Error handling POST message');\n                    if (!res.headersSent) {\n                        res.status(500).json({ error: 'Internal server error while handling POST message.' });\n                    }\n                }\n            });\n            app.listen(port, async () => {\n                logger.info({\n                    port,\n                    allocatedByTransportManager: !!allocatedSsePort,\n                    source: allocatedSsePort ? 'Transport Manager' : 'Environment/Default'\n                }, `Vibe Coder MCP SSE server running on http://localhost:${port}`);\n                logger.info('Connect using SSE at /sse and post messages to /messages');\n                logger.info('Subscribe to job progress events at /events/:sessionId');\n                await PortAllocator.registerInstance(port, 'sse-server');\n            });\n            app.get('/events/:sessionId', (req, res) => {\n                const sessionId = req.params.sessionId;\n                if (!sessionId) {\n                    res.status(400).send('Session ID is required.');\n                    return;\n                }\n                logger.info({ sessionId }, `Received request to establish SSE connection for job progress.`);\n                sseNotifier.registerConnection(sessionId, res);\n            });\n        }\n        else {\n            process.env.MCP_TRANSPORT = 'stdio';\n            console.log = (...args) => process.stderr.write(args.join(' ') + '\\n');\n            console.info = (...args) => process.stderr.write('[INFO] ' + args.join(' ') + '\\n');\n            console.warn = (...args) => process.stderr.write('[WARN] ' + args.join(' ') + '\\n');\n            console.error = (...args) => process.stderr.write('[ERROR] ' + args.join(' ') + '\\n');\n            const stdioSessionId = 'stdio-session';\n            const transport = new StdioServerTransport();\n            logger.info({ sessionId: stdioSessionId }, 'Initialized stdio transport with session ID');\n            await mcpServer.connect(transport);\n            logger.info('Vibe Coder MCP server running on stdio');\n        }\n    }\n    catch (error) {\n        logger.fatal({ err: error }, 'Server error');\n        process.exit(1);\n    }\n}\nasync function initDirectories() {\n    try {\n        try {\n            const researchManager = await import('./tools/research-manager/index.js');\n            if (typeof researchManager.initDirectories === 'function') {\n                await researchManager.initDirectories();\n                logger.debug('Initialized research-manager directories');\n            }\n        }\n        catch (error) {\n            logger.error({ err: error }, 'Error initializing research-manager');\n        }\n        try {\n            const rulesGenerator = await import('./tools/rules-generator/index.js');\n            if (typeof rulesGenerator.initDirectories === 'function') {\n                await rulesGenerator.initDirectories();\n                logger.debug('Initialized rules-generator directories');\n            }\n        }\n        catch (error) {\n            logger.error({ err: error }, 'Error initializing rules-generator');\n        }\n        try {\n            const prdGenerator = await import('./tools/prd-generator/index.js');\n            if (typeof prdGenerator.initDirectories === 'function') {\n                await prdGenerator.initDirectories();\n                logger.debug('Initialized prd-generator directories');\n            }\n        }\n        catch (error) {\n            logger.error({ err: error }, 'Error initializing prd-generator');\n        }\n        try {\n            const userStoriesGenerator = await import('./tools/user-stories-generator/index.js');\n            if (typeof userStoriesGenerator.initDirectories === 'function') {\n                await userStoriesGenerator.initDirectories();\n                logger.debug('Initialized user-stories-generator directories');\n            }\n        }\n        catch (error) {\n            logger.error({ err: error }, 'Error initializing user-stories-generator');\n        }\n        try {\n            const contextCurator = await import('./tools/context-curator/index.js');\n            if (typeof contextCurator.initDirectories === 'function') {\n                await contextCurator.initDirectories();\n                logger.debug('Initialized context-curator directories');\n            }\n        }\n        catch (error) {\n            logger.error({ err: error }, 'Error initializing context-curator');\n        }\n        try {\n            const taskListGenerator = await import('./tools/task-list-generator/index.js');\n            if (typeof taskListGenerator.initDirectories === 'function') {\n                await taskListGenerator.initDirectories();\n                logger.debug('Initialized task-list-generator directories');\n            }\n        }\n        catch (error) {\n            logger.error({ err: error }, 'Error initializing task-list-generator');\n        }\n        logger.info('Tool directory initialization complete');\n    }\n    catch (error) {\n        logger.error({ err: error }, 'Error initializing directories');\n    }\n}\nasync function initializeApp() {\n    const cwd = process.cwd();\n    const scriptDir = __dirname;\n    const projectRoot = path.resolve(scriptDir, '..');\n    logger.info({\n        cwd,\n        scriptDir,\n        projectRoot\n    }, 'Directory information');\n    if (cwd === '/' || cwd === '\\\\' || cwd === 'C:\\\\' || cwd === 'C:/' || cwd.match(/^[A-Z]:[\\\\/]$/)) {\n        logger.warn({\n            cwd,\n            scriptDir,\n            projectRoot,\n            message: 'Working directory is root. Using project root for relative paths.'\n        }, 'Working directory warning');\n    }\n    logger.info('Initializing centralized OpenRouter configuration manager...');\n    const configManager = OpenRouterConfigManager.getInstance();\n    await configManager.initialize();\n    const openRouterConfig = await configManager.getOpenRouterConfig();\n    const mappingKeys = Object.keys(openRouterConfig.llm_mapping || {});\n    logger.info('Loaded OpenRouter configuration details:', {\n        hasApiKey: Boolean(openRouterConfig.apiKey),\n        baseUrl: openRouterConfig.baseUrl,\n        geminiModel: openRouterConfig.geminiModel,\n        perplexityModel: openRouterConfig.perplexityModel,\n        mappingLoaded: mappingKeys.length > 0,\n        numberOfMappings: mappingKeys.length,\n        mappingKeys: mappingKeys\n    });\n    const validation = configManager.validateConfiguration();\n    if (!validation.valid) {\n        logger.error({ errors: validation.errors }, 'OpenRouter configuration validation failed');\n        throw new Error(`Configuration validation failed: ${validation.errors.join(', ')}`);\n    }\n    if (validation.warnings.length > 0) {\n        logger.warn({ warnings: validation.warnings, suggestions: validation.suggestions }, 'OpenRouter configuration has warnings');\n    }\n    logger.info('Initializing ToolRegistry with full configuration including model mappings');\n    ToolRegistry.getInstance(openRouterConfig);\n    await initializeToolEmbeddings();\n    try {\n        logger.info('Checking for other running vibe-coder-mcp instances...');\n        const commonPorts = [8080, 8081, 8082, 8083, 8084, 8085, 8086, 8087, 8088, 8089, 8090, 3011, 3012];\n        const conflicts = await PortAllocator.detectPortConflicts(commonPorts);\n        const portsInUse = Array.from(conflicts.entries())\n            .filter(([_, inUse]) => inUse)\n            .map(([port, _]) => port);\n        if (portsInUse.length > 0) {\n            logger.warn({\n                portsInUse,\n                conflictCount: portsInUse.length,\n                message: 'Detected ports in use that may indicate other vibe-coder-mcp instances running'\n            }, 'Multiple instance detection warning');\n        }\n        else {\n            logger.info('No conflicting instances detected on common ports');\n        }\n    }\n    catch (error) {\n        logger.warn({ err: error }, 'Instance detection failed, continuing with startup');\n    }\n    try {\n        logger.info('Starting port cleanup for orphaned processes...');\n        const cleanedPorts = await PortAllocator.cleanupOrphanedPorts();\n        logger.info({ cleanedPorts }, 'Port cleanup completed');\n    }\n    catch (error) {\n        logger.warn({ err: error }, 'Port cleanup failed, continuing with startup');\n    }\n    transportManager.configure({\n        websocket: { enabled: true, port: 8080, path: '/agent-ws' },\n        http: { enabled: true, port: 3011, cors: true },\n        sse: { enabled: true },\n        stdio: { enabled: true }\n    });\n    try {\n        const { transportCoordinator } = await import('./services/transport-coordinator.js');\n        await transportCoordinator.ensureTransportsStarted();\n        logger.info('All transport services started successfully with dynamic port allocation');\n    }\n    catch (error) {\n        logger.error({ err: error }, 'Failed to start transport services');\n    }\n    registerShutdownCallback(async () => {\n        logger.info('Shutting down transport services...');\n        try {\n            await transportManager.stopAll();\n            logger.info('Transport services stopped successfully');\n        }\n        catch (error) {\n            logger.error({ err: error }, 'Error stopping transport services');\n        }\n    });\n    registerShutdownCallback(async () => {\n        logger.info('Cleaning up port allocations...');\n        try {\n            await PortAllocator.cleanupOrphanedPorts();\n            logger.info('Port cleanup completed');\n        }\n        catch (error) {\n            logger.error({ err: error }, 'Error during port cleanup');\n        }\n    });\n    logger.info('Application initialization complete.');\n    return openRouterConfig;\n}\ninitializeApp().then(async (loadedConfig) => {\n    const { createServer } = await import('./server.js');\n    const server = createServer(loadedConfig);\n    logger.info('Initializing tool directories after server creation...');\n    await initDirectories();\n    const instanceDir = process.env.VIBE_CODER_INSTANCE_DIR;\n    const outputDir = process.env.VIBE_CODER_OUTPUT_DIR || path.join(process.cwd(), 'VibeCoderOutput');\n    let instanceTrackingDir;\n    if (instanceDir) {\n        instanceTrackingDir = instanceDir;\n        logger.info({ instanceDir }, 'Using explicitly configured instance directory');\n    }\n    else if (process.env.VIBE_CODER_OUTPUT_DIR) {\n        instanceTrackingDir = path.join(outputDir, '.temp', 'instances');\n        logger.info({ instanceTrackingDir }, 'Using instance directory within configured output directory');\n    }\n    if (instanceTrackingDir) {\n        PortAllocator.initialize({ instanceTrackingDir });\n    }\n    else {\n        logger.debug('PortAllocator using default OS temp instance tracking directory');\n        PortAllocator.initialize({});\n    }\n    registerShutdownCallback(async () => {\n        logger.info('Cleaning up port allocations...');\n        await PortAllocator.cleanupInstanceTracking();\n    });\n    main(server).catch(error => {\n        logger.fatal({ err: error }, 'Failed to start server');\n        process.exit(1);\n    });\n}).catch(initError => {\n    logger.fatal({ err: initError }, 'Failed during application initialization');\n    process.exit(1);\n});\n"]}