Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Docs/init-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ The root orchestrator handles service selection and delegates configuration to i
### Service Scripts
- **Backend**: `backends/advanced/init.py` - Complete Python-based interactive setup
- **Speaker Recognition**: `extras/speaker-recognition/setup.sh` - Simple bash setup
- **ASR Services**: `extras/asr-services/setup.sh` - Service startup script
- **OpenMemory MCP**: `extras/openmemory-mcp/setup.sh` - External server startup
- **ASR Services**: `extras/asr-services/setup.sh` - Service startup script
- **OpenMemory MCP**: `extras/openmemory-mcp/run.sh` - External server startup (uses official Docker image)

## Usage

Expand Down
1 change: 0 additions & 1 deletion extras/openmemory-mcp/.gitignore

This file was deleted.

6 changes: 2 additions & 4 deletions extras/openmemory-mcp/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ services:
- ./data/mem0_storage:/qdrant/storage
restart: unless-stopped

# OpenMemory MCP Server (built from local cache)
# OpenMemory MCP Server (official image)
openmemory-mcp:
build:
context: ./cache/mem0/openmemory/api
dockerfile: Dockerfile
image: mem0/openmemory-mcp:latest
env_file:
- .env
environment:
Expand Down
31 changes: 0 additions & 31 deletions extras/openmemory-mcp/init-cache.sh

This file was deleted.

24 changes: 22 additions & 2 deletions extras/openmemory-mcp/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,35 @@ echo "🚀 Starting OpenMemory MCP installation for Friend-Lite..."
OPENAI_API_KEY="${OPENAI_API_KEY:-}"
USER="${USER:-$(whoami)}"

# Check for .env file first
# Check for .env file first, load if exists
if [ -f .env ]; then
echo "📝 Loading configuration from .env file..."
export $(cat .env | grep -v '^#' | xargs)
else
# Create .env from template if it doesn't exist
if [ -f .env.template ]; then
echo "📝 Creating .env from template..."
cp .env.template .env
fi
fi
Comment on lines +11 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix potential word-splitting issue in environment variable loading.

Line 14 uses an unquoted command substitution that can cause word-splitting issues. While this pattern works in many cases, it can fail with values containing spaces or special characters.

Apply this diff for a safer approach:

-    export $(cat .env | grep -v '^#' | xargs)
+    set -a
+    source .env
+    set +a

Or if you need to preserve the existing behavior:

-    export $(cat .env | grep -v '^#' | xargs)
+    export "$(cat .env | grep -v '^#' | xargs)"

The set -a; source .env; set +a approach is more robust and handles complex values correctly.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Check for .env file first, load if exists
if [ -f .env ]; then
echo "📝 Loading configuration from .env file..."
export $(cat .env | grep -v '^#' | xargs)
else
# Create .env from template if it doesn't exist
if [ -f .env.template ]; then
echo "📝 Creating .env from template..."
cp .env.template .env
fi
fi
# Check for .env file first, load if exists
if [ -f .env ]; then
echo "📝 Loading configuration from .env file..."
set -a
source .env
set +a
else
# Create .env from template if it doesn't exist
if [ -f .env.template ]; then
echo "📝 Creating .env from template..."
cp .env.template .env
fi
fi
🧰 Tools
🪛 Shellcheck (0.11.0)

[warning] 14-14: Quote this to prevent word splitting.

(SC2046)

🤖 Prompt for AI Agents
In extras/openmemory-mcp/run.sh around lines 11 to 21, the script uses unquoted
command substitution and xargs to export environment variables from .env which
can cause word-splitting and break values with spaces or special characters;
replace that section to load .env robustly by using the shell's source mechanism
with automatic export: enable export with set -a, source the .env file (skipping
comments), then disable automatic export with set +a — this preserves complex
values and is safer than parsing with xargs.


# If OPENAI_API_KEY is provided via environment but not in .env, write it
if [ -n "$OPENAI_API_KEY" ] && [ -f .env ]; then
# Update or add OPENAI_API_KEY in .env file
if grep -q "^OPENAI_API_KEY=" .env 2>/dev/null; then
# Key exists, update it
sed -i "s|^OPENAI_API_KEY=.*|OPENAI_API_KEY=${OPENAI_API_KEY}|" .env
else
# Key doesn't exist, append it
echo "OPENAI_API_KEY=${OPENAI_API_KEY}" >> .env
fi
echo "✅ Updated .env with provided OPENAI_API_KEY"
fi

# Final check
if [ -z "$OPENAI_API_KEY" ]; then
echo "❌ OPENAI_API_KEY not set."
echo " Option 1: Create a .env file from .env.template and add your key"
echo " Option 1: Edit .env file and add your key"
echo " Option 2: Run with: OPENAI_API_KEY=your_api_key ./run.sh"
echo " Option 3: Export it: export OPENAI_API_KEY=your_api_key"
exit 1
Expand Down
99 changes: 0 additions & 99 deletions extras/openmemory-mcp/setup.sh

This file was deleted.

39 changes: 25 additions & 14 deletions wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Handles service selection and delegation only - no configuration duplication
"""

import os
import subprocess
import sys
from datetime import datetime
Expand Down Expand Up @@ -73,7 +74,7 @@ def is_placeholder(value, *placeholder_variants):
},
'openmemory-mcp': {
'path': 'extras/openmemory-mcp',
'cmd': ['./setup.sh'],
'cmd': ['./run.sh'],
'description': 'OpenMemory MCP server'
}
}
Expand All @@ -90,6 +91,11 @@ def check_service_exists(service_name, service_config):
script_path = service_path / 'init.py'
if not script_path.exists():
return False, f"Script {script_path} does not exist"
elif service_name == 'openmemory-mcp':
# OpenMemory MCP uses run.sh
script_path = service_path / 'run.sh'
if not script_path.exists():
return False, f"Script {script_path} does not exist"
else:
# For other extras, check if setup.sh exists
script_path = service_path / 'setup.sh'
Expand Down Expand Up @@ -152,28 +158,31 @@ def cleanup_unselected_services(selected_services):

def run_service_setup(service_name, selected_services, https_enabled=False, server_ip=None):
"""Execute individual service setup script"""
# Initialize env_vars for all services
env_vars = None

if service_name == 'advanced':
service = SERVICES['backend'][service_name]

# For advanced backend, pass URLs of other selected services and HTTPS config
cmd = service['cmd'].copy()
if 'speaker-recognition' in selected_services:
cmd.extend(['--speaker-service-url', 'http://host.docker.internal:8085'])
if 'asr-services' in selected_services:
cmd.extend(['--parakeet-asr-url', 'http://host.docker.internal:8767'])

# Add HTTPS configuration
if https_enabled and server_ip:
cmd.extend(['--enable-https', '--server-ip', server_ip])

else:
service = SERVICES['extras'][service_name]
cmd = service['cmd'].copy()

# Add HTTPS configuration for services that support it
if service_name == 'speaker-recognition' and https_enabled and server_ip:
cmd.extend(['--enable-https', '--server-ip', server_ip])

# For speaker-recognition, try to pass API keys and config if available
if service_name == 'speaker-recognition':
# Pass Deepgram API key from backend if available
Expand All @@ -195,29 +204,31 @@ def run_service_setup(service_name, selected_services, https_enabled=False, serv
if compute_mode in ['cpu', 'gpu']:
cmd.extend(['--compute-mode', compute_mode])
console.print(f"[blue][INFO][/blue] Found existing COMPUTE_MODE ({compute_mode}), reusing")
# For openmemory-mcp, try to pass OpenAI API key from backend if available

# For openmemory-mcp, prepare environment variables
if service_name == 'openmemory-mcp':
backend_env_path = 'backends/advanced/.env'
openai_key = read_env_value(backend_env_path, 'OPENAI_API_KEY')
if openai_key and not is_placeholder(openai_key, 'your_openai_api_key_here', 'your-openai-api-key-here', 'your_openai_key_here', 'your-openai-key-here'):
cmd.extend(['--openai-api-key', openai_key])
env_vars = os.environ.copy()
env_vars['OPENAI_API_KEY'] = openai_key
console.print("[blue][INFO][/blue] Found existing OPENAI_API_KEY from backend config, reusing")

console.print(f"\n🔧 [bold]Setting up {service_name}...[/bold]")

# Check if service exists before running
exists, msg = check_service_exists(service_name, service)
if not exists:
console.print(f"❌ {service_name} setup failed: {msg}")
return False

try:
result = subprocess.run(
cmd,
cmd,
cwd=service['path'],
check=True,
timeout=300 # 5 minute timeout for service setup
timeout=300, # 5 minute timeout for service setup
env=env_vars
)

console.print(f"✅ {service_name} setup completed")
Expand Down