diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..03118ef5 --- /dev/null +++ b/.env.example @@ -0,0 +1,53 @@ +# Brainy Configuration Example +# Copy this file to .env and fill in your values + +# =================================== +# Core Configuration +# =================================== +NODE_ENV=development +DEBUG=false +LOG_LEVEL=info + +# =================================== +# Brain Cloud Configuration (Optional) +# =================================== +# Sign up at https://soulcraft.com/brain-cloud +BRAIN_CLOUD_URL=https://api.soulcraft.com/brain-cloud +BRAIN_CLOUD_KEY= +BRAIN_CLOUD_CUSTOMER_ID= + +# =================================== +# Licensing (Optional) +# =================================== +# Get your license at https://soulcraft.com +BRAINY_LICENSE_KEY= + +# =================================== +# LLM API Keys (Optional) +# =================================== +# Required only if using BrainyChat features +ANTHROPIC_API_KEY= +OPENAI_API_KEY= + +# =================================== +# AWS S3 Storage (Optional) +# =================================== +# Required only if using S3 storage adapter +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_REGION=us-east-1 +S3_BUCKET_NAME= + +# =================================== +# MCP Server Configuration (Optional) +# =================================== +# For Claude integration via MCP +CUSTOMER_ID= +MCP_SERVER_PORT=3000 + +# =================================== +# Development/Testing +# =================================== +# Test environment settings +TEST_TIMEOUT=30000 +VITEST_WORKERS=1 \ No newline at end of file diff --git a/PERFORMANCE_OPTIMIZATION_TODO.md b/PERFORMANCE_OPTIMIZATION_TODO.md index b2a2145c..dcd08218 100644 --- a/PERFORMANCE_OPTIMIZATION_TODO.md +++ b/PERFORMANCE_OPTIMIZATION_TODO.md @@ -14,7 +14,7 @@ Current metadata filtering has a **300-400% search overhead** due to a fixed 3x ### Root Cause ```typescript // Current implementation (inefficient) -// File: /home/dpsifr/Projects/brainy/src/hnsw/hnswIndex.ts:377 +// File: src/hnsw/hnswIndex.ts:377 const ef = filter ? Math.max(this.config.efSearch * 3, k * 3) : Math.max(this.config.efSearch, k) ``` @@ -41,7 +41,7 @@ function getEfMultiplier(selectivity: number): number { ### 3. Implementation Location -**File**: `/home/dpsifr/Projects/brainy/src/brainyData.ts` +**File**: `src/brainyData.ts` **Method**: `searchByNounTypes` (around line 2165) ```typescript @@ -58,7 +58,7 @@ if (hasMetadataFilter && this.metadataIndex) { } ``` -**File**: `/home/dpsifr/Projects/brainy/src/hnsw/hnswIndex.ts` +**File**: `src/hnsw/hnswIndex.ts` **Method**: `search` (around line 377) ```typescript @@ -188,9 +188,9 @@ const cachedFieldIndex = this.metadataCache.get(`field_${field}`) ## 📝 Files to Modify -1. `/home/dpsifr/Projects/brainy/src/brainyData.ts` (selectivity calculation) -2. `/home/dpsifr/Projects/brainy/src/hnsw/hnswIndex.ts` (dynamic ef multiplier) -3. `/home/dpsifr/Projects/brainy/src/hnsw/optimizedHNSWIndex.ts` (forward selectivity) +1. `src/brainyData.ts` (selectivity calculation) +2. `src/hnsw/hnswIndex.ts` (dynamic ef multiplier) +3. `src/hnsw/optimizedHNSWIndex.ts` (forward selectivity) ## 🔄 Rollback Plan diff --git a/bin/brainy.js b/bin/brainy.js index 2576c375..a588bb06 100755 --- a/bin/brainy.js +++ b/bin/brainy.js @@ -345,7 +345,7 @@ program try { // Test connection to Brain Cloud worker - const healthUrl = `https://brain-cloud.dpsifr.workers.dev/health` + const healthUrl = `https://api.soulcraft.com/brain-cloud/health` const response = await fetch(healthUrl, { headers: { 'x-customer-id': options.connect } }) @@ -357,7 +357,7 @@ program console.log(chalk.gray(`⏰ Connected at: ${new Date(data.timestamp).toLocaleString()}`)) // Test memories endpoint - const memoriesResponse = await fetch(`https://brain-cloud.dpsifr.workers.dev/memories`, { + const memoriesResponse = await fetch(`https://api.soulcraft.com/brain-cloud/memories`, { headers: { 'x-customer-id': options.connect } }) @@ -384,7 +384,7 @@ program console.log(chalk.green(`📦 Exporting data from Brain Cloud instance: ${options.export}`)) try { - const response = await fetch(`https://brain-cloud.dpsifr.workers.dev/export`, { + const response = await fetch(`https://api.soulcraft.com/brain-cloud/export`, { headers: { 'x-customer-id': options.export } }) @@ -408,7 +408,7 @@ program console.log(chalk.green(`🔍 Checking status of Brain Cloud instance: ${options.status}`)) try { - const response = await fetch(`https://brain-cloud.dpsifr.workers.dev/health`, { + const response = await fetch(`https://api.soulcraft.com/brain-cloud/health`, { headers: { 'x-customer-id': options.status } }) @@ -419,7 +419,7 @@ program console.log(chalk.gray(`⏰ Last check: ${new Date(data.timestamp).toLocaleString()}`)) // Get memory count - const memoriesResponse = await fetch(`https://brain-cloud.dpsifr.workers.dev/memories`, { + const memoriesResponse = await fetch(`https://api.soulcraft.com/brain-cloud/memories`, { headers: { 'x-customer-id': options.status } }) @@ -915,7 +915,7 @@ async function detectCustomerId() { const testIds = ['demo-test-auto', 'demo-test123'] for (const id of testIds) { try { - const response = await fetch(`https://brain-cloud.dpsifr.workers.dev/health`, { + const response = await fetch(`https://api.soulcraft.com/brain-cloud/health`, { headers: { 'x-customer-id': id } }) if (response.ok) { @@ -947,7 +947,7 @@ async function setupBrainCloudMemory(customerId) { args: ["brainy-mcp-server.js"], env: { CUSTOMER_ID: customerId, - BRAIN_CLOUD_URL: "https://brain-cloud.dpsifr.workers.dev" + BRAIN_CLOUD_URL: "https://api.soulcraft.com/brain-cloud" } } } @@ -1001,7 +1001,7 @@ When working with multiple AI assistants, we automatically coordinate: try { const brainyConfig = { brainCloudCustomerId: customerId, - brainCloudUrl: 'https://brain-cloud.dpsifr.workers.dev', + brainCloudUrl: 'https://api.soulcraft.com/brain-cloud', lastConnected: new Date().toISOString() } diff --git a/brainy-mcp-server.js b/brainy-mcp-server.js index 5f82e2a2..45e63ce0 100644 --- a/brainy-mcp-server.js +++ b/brainy-mcp-server.js @@ -16,7 +16,7 @@ import { // Configuration from environment const CUSTOMER_ID = process.env.CUSTOMER_ID || 'demo-test-auto'; -const BRAIN_CLOUD_URL = process.env.BRAIN_CLOUD_URL || 'https://brain-cloud.dpsifr.workers.dev'; +const BRAIN_CLOUD_URL = process.env.BRAIN_CLOUD_URL || 'https://api.soulcraft.com/brain-cloud'; class BrainCloudMCPServer { constructor() {