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Eb,kBADM,kBAAkB,QAAQ,KAAK,IAAM,IAI/C,GAAwB,aAApB,QAAQ,KAAK,GAEb,kBADM,sBAAsB,QAAQ,KAAK,IAAM,IAInD,GAAwB,YAApB,QAAQ,KAAK,GAEb,kBADM,qBAAqB,QAAQ,KAAK,IAAM,IAIlD,GAAwB,UAApB,QAAQ,KAAK,GAAgB,CAE7B,GAAe,aADA,QAAQ,KAAK,GACD,CACvB,MAAM,aAAE,SAAuB,OAAO,sBAChC,QAAW,OAAO,MAExB,EADe,QAAQ,IAAI,kBAAoB,KAAK,KAAK,EAAG,UAAW,iBAAkB,gBAEzF,MAAM,cAAE,SAAwB,OAAO,uBACvC,QAAQ,IAAI,yDACZ,MAAM,EAAS,IACf,QAAQ,IAAI,mBAAmB,EAAO,0BAA0B,EAAO,4BAA4B,EAAO,8BAC9G,MAEI,QAAQ,MAAM,8CACd,QAAQ,KAAK,GAEjB,MACJ,CACA,MAAM,OAAE,EAAM,KAAE,GAAS,YACzB,IAAI,EAAmB,KACvB,GAAa,QAAT,EAEA,QAAQ,IAAI,yCACZ,yBAAyB,QAExB,GAAa,cAAT,EAAsB,CAE3B,QAAQ,IAAI,4CACZ,yBAAyB,GACzB,EAAmB,iBAEnB,MAAM,EAAY,IACd,QAAQ,IAAI,cAAc,uBACtB,GACA,EAAiB,KAAK,WAE1B,QAAQ,KAAK,EAAE,EAEnB,QAAQ,GAAG,UAAU,IAAM,EAAS,YACpC,QAAQ,GAAG,WAAW,IAAM,EAAS,YACzC,KACkB,SAAT,GAEL,QAAQ,IAAI,2CACZ,yBAAyB,SACnB,eAAe,UAIf,eAAe,EAE7B,CAEA,OAAO,OAAO,IAEV,QAAQ,MAAM,wCAAyC,GACvD,QAAQ,KAAK,EAAE","file":"/npm/claude-cortex@1.16.0/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/claude-cortex@1.16.0/dist/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\n/**\n * Claude Cortex - Brain-like Memory System for Claude Code\n *\n * This server provides persistent, intelligent memory for Claude Code,\n * solving the context compaction and session persistence problems.\n *\n * Usage:\n *   npx claude-cortex                         # Start MCP server (default)\n *   npx claude-cortex --mode mcp              # Start MCP server\n *   npx claude-cortex --mode api              # Start visualization API server\n *   npx claude-cortex --mode both             # Start both servers\n *   npx claude-cortex --dashboard             # Start API + Dashboard (admin panel)\n *   npx claude-cortex --db /path/to.db        # Custom database path\n *   npx claude-cortex setup                    # Configure Claude for proactive memory use\n *   npx claude-cortex setup uninstall          # Remove hooks and CLAUDE.md block\n *   npx claude-cortex uninstall               # Complete uninstall (keeps database)\n *   npx claude-cortex uninstall --keep-logs   # Complete uninstall, preserve logs\n *   npx claude-cortex hook pre-compact         # Run pre-compact hook (for settings.json)\n *   npx claude-cortex hook session-start       # Run session-start hook (for settings.json)\n *   npx claude-cortex hook session-end         # Run session-end hook (for settings.json)\n *   npx claude-cortex service install         # Auto-start dashboard on login\n *   npx claude-cortex service uninstall       # Remove auto-start\n *   npx claude-cortex service status          # Check service status\n *   npx claude-cortex clawdbot install        # Install OpenClaw/Clawdbot hook\n *   npx claude-cortex clawdbot uninstall      # Remove OpenClaw/Clawdbot hook\n *   npx claude-cortex clawdbot status         # Check Clawdbot hook status\n *   npx claude-cortex plugin                  # Print plugin directory path (for --plugin-dir)\n */\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { spawn } from 'child_process';\nimport { fileURLToPath } from 'url';\nimport path from 'path';\nimport { createServer } from './server.js';\nimport { startVisualizationServer } from './api/visualization-server.js';\nimport { handleServiceCommand } from './service/install.js';\nimport { setupClaudeMd } from './setup/claude-md.js';\nimport { handleHookCommand } from './setup/hooks.js';\nimport { handleClawdbotCommand } from './setup/clawdbot.js';\nimport { createRequire } from 'module';\nconst require = createRequire(import.meta.url);\nconst pkg = require('../package.json');\n// Get the directory of this file for relative paths\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n// Parse command line arguments\nfunction parseArgs() {\n    const args = process.argv.slice(2);\n    const result = { mode: 'mcp' };\n    for (let i = 0; i < args.length; i++) {\n        if (args[i] === '--db' && args[i + 1]) {\n            result.dbPath = args[i + 1];\n            i++;\n        }\n        else if (args[i] === '--dashboard') {\n            result.mode = 'dashboard';\n        }\n        else if (args[i] === '--mode' && args[i + 1]) {\n            const mode = args[i + 1].toLowerCase();\n            if (mode === 'mcp' || mode === 'api' || mode === 'both' || mode === 'dashboard') {\n                result.mode = mode;\n            }\n            i++;\n        }\n    }\n    return result;\n}\n/**\n * Start MCP server for Claude Code integration\n */\nasync function startMcpServer(dbPath) {\n    // Create the MCP server\n    const server = createServer(dbPath);\n    // Connect via stdio transport\n    const transport = new StdioServerTransport();\n    await server.connect(transport);\n    // Handle graceful shutdown\n    process.on('SIGINT', async () => {\n        await server.close();\n        process.exit(0);\n    });\n    process.on('SIGTERM', async () => {\n        await server.close();\n        process.exit(0);\n    });\n}\n/**\n * Start the Next.js dashboard as a child process\n */\nfunction startDashboard() {\n    // Dashboard is in the dashboard/ subdirectory relative to project root\n    // Since we're in dist/, go up one level to find dashboard/\n    const dashboardDir = path.resolve(__dirname, '..', 'dashboard');\n    console.log(`\n╔══════════════════════════════════════════════════════════════╗\n║             🧠 Claude Cortex Dashboard                        ║\n╠══════════════════════════════════════════════════════════════╣\n║  Starting Next.js dashboard...                               ║\n║  Dashboard: http://localhost:3030                            ║\n║  API:       http://localhost:3001                            ║\n╚══════════════════════════════════════════════════════════════╝\n  `);\n    // Start Next.js in production mode if built, otherwise dev mode\n    const dashboard = spawn('npm', ['run', 'start'], {\n        cwd: dashboardDir,\n        stdio: ['ignore', 'pipe', 'pipe'],\n        shell: true,\n    });\n    // Pipe dashboard output with prefix\n    dashboard.stdout?.on('data', (data) => {\n        const lines = data.toString().split('\\n').filter((l) => l.trim());\n        for (const line of lines) {\n            console.log(`[dashboard] ${line}`);\n        }\n    });\n    dashboard.stderr?.on('data', (data) => {\n        const lines = data.toString().split('\\n').filter((l) => l.trim());\n        for (const line of lines) {\n            console.error(`[dashboard] ${line}`);\n        }\n    });\n    dashboard.on('error', (error) => {\n        console.error('[dashboard] Failed to start:', error.message);\n        console.error('[dashboard] Make sure to run \"npm run build\" in the dashboard directory first.');\n    });\n    dashboard.on('exit', (code, signal) => {\n        if (signal) {\n            console.log(`[dashboard] Killed by signal ${signal}`);\n        }\n        else if (code !== 0) {\n            console.error(`[dashboard] Exited with code ${code}`);\n        }\n    });\n    return dashboard;\n}\n/**\n * Main entry point\n */\nasync function main() {\n    // Handle --version / -v\n    if (process.argv[2] === '--version' || process.argv[2] === '-v') {\n        console.log(pkg.version);\n        return;\n    }\n    // Handle \"doctor\" subcommand\n    if (process.argv[2] === 'doctor') {\n        const { handleDoctorCommand } = await import('./setup/doctor.js');\n        await handleDoctorCommand();\n        return;\n    }\n    // Handle \"setup\" subcommand\n    if (process.argv[2] === 'setup') {\n        if (process.argv[3] === 'uninstall') {\n            const { uninstallSetup } = await import('./setup/uninstall.js');\n            await uninstallSetup();\n            return;\n        }\n        const stopHook = process.argv.includes('--with-stop-hook');\n        await setupClaudeMd({ stopHook });\n        return;\n    }\n    // Handle \"plugin\" — print plugin directory path\n    if (process.argv[2] === 'plugin') {\n        const __filename = fileURLToPath(import.meta.url);\n        const __dirname = path.dirname(__filename);\n        const pluginDir = path.resolve(__dirname, '..', 'plugin');\n        console.log(pluginDir);\n        return;\n    }\n    // Handle \"uninstall\" — full uninstall\n    if (process.argv[2] === 'uninstall') {\n        const { uninstallAll } = await import('./setup/uninstall.js');\n        const keepLogs = process.argv.includes('--keep-logs');\n        await uninstallAll({ keepLogs });\n        return;\n    }\n    // Handle \"hook\" subcommand\n    if (process.argv[2] === 'hook') {\n        await handleHookCommand(process.argv[3] || '');\n        return;\n    }\n    // Handle \"clawdbot\" subcommand\n    if (process.argv[2] === 'clawdbot') {\n        await handleClawdbotCommand(process.argv[3] || '');\n        return;\n    }\n    // Handle \"service\" subcommand before normal mode parsing\n    if (process.argv[2] === 'service') {\n        await handleServiceCommand(process.argv[3] || '');\n        return;\n    }\n    // Handle \"graph\" subcommand\n    if (process.argv[2] === 'graph') {\n        const action = process.argv[3];\n        if (action === 'backfill') {\n            const { initDatabase } = await import('./database/init.js');\n            const os = await import('os');\n            const dbPath = process.env.CLAUDE_MEMORY_DB || path.join(os.homedir(), '.claude-cortex', 'memories.db');\n            initDatabase(dbPath);\n            const { backfillGraph } = await import('./graph/backfill.js');\n            console.log('Backfilling knowledge graph from existing memories...');\n            const result = backfillGraph();\n            console.log(`Done! Extracted ${result.entities} new entities, ${result.triples} new triples from ${result.memoriesProcessed} memories.`);\n        }\n        else {\n            console.error('Unknown graph command. Available: backfill');\n            process.exit(1);\n        }\n        return;\n    }\n    const { dbPath, mode } = parseArgs();\n    let dashboardProcess = null;\n    if (mode === 'api') {\n        // API mode only - for dashboard visualization\n        console.log('Starting Claude Cortex in API mode...');\n        startVisualizationServer(dbPath);\n    }\n    else if (mode === 'dashboard') {\n        // Dashboard mode - API + Next.js dashboard\n        console.log('Starting Claude Cortex with Dashboard...');\n        startVisualizationServer(dbPath);\n        dashboardProcess = startDashboard();\n        // Graceful shutdown for dashboard mode\n        const shutdown = (signal) => {\n            console.log(`\\nReceived ${signal}, shutting down...`);\n            if (dashboardProcess) {\n                dashboardProcess.kill('SIGTERM');\n            }\n            process.exit(0);\n        };\n        process.on('SIGINT', () => shutdown('SIGINT'));\n        process.on('SIGTERM', () => shutdown('SIGTERM'));\n    }\n    else if (mode === 'both') {\n        // Both modes - API in background, MCP in foreground\n        console.log('Starting Claude Cortex in both modes...');\n        startVisualizationServer(dbPath);\n        await startMcpServer(dbPath);\n    }\n    else {\n        // MCP mode (default) - for Claude Code integration\n        await startMcpServer(dbPath);\n    }\n}\n// Run\nmain().catch((error) => {\n    // Log to stderr to avoid corrupting MCP protocol\n    console.error('Failed to start claude-cortex server:', error);\n    process.exit(1);\n});\n"]}