Merge pull request #577 from kdkiss/feature/setup_script_enhancement

This commit is contained in:
Sharath 2025-05-31 21:07:46 +05:30 committed by GitHub
commit 8c74d35841
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 119 additions and 78 deletions

4
.gitignore vendored
View File

@ -194,3 +194,7 @@ supabase/.temp/storage-version
redis_data redis_data
rabbitmq_data rabbitmq_data
.setup_progress
.setup_env.json

175
setup.py
View File

@ -6,6 +6,8 @@ import platform
import subprocess import subprocess
from getpass import getpass from getpass import getpass
import re import re
import json
IS_WINDOWS = platform.system() == 'Windows' IS_WINDOWS = platform.system() == 'Windows'
@ -36,6 +38,44 @@ def print_banner():
{Colors.ENDC} {Colors.ENDC}
""") """)
PROGRESS_FILE = '.setup_progress'
def save_progress(step):
with open(PROGRESS_FILE, 'w') as f:
f.write(str(step))
def load_progress():
if os.path.exists(PROGRESS_FILE):
with open(PROGRESS_FILE, 'r') as f:
try:
return int(f.read().strip())
except ValueError:
return 0
return 0
def clear_progress():
if os.path.exists(PROGRESS_FILE):
os.remove(PROGRESS_FILE)
ENV_DATA_FILE = '.setup_env.json'
def save_env_data(env_data):
with open(ENV_DATA_FILE, 'w') as f:
json.dump(env_data, f)
def load_env_data():
if os.path.exists(ENV_DATA_FILE):
with open(ENV_DATA_FILE, 'r') as f:
return json.load(f)
return {
'supabase': {},
'daytona': {},
'llm': {},
'search': {},
'rapidapi': {}
}
def print_step(step_num, total_steps, step_name): def print_step(step_num, total_steps, step_name):
"""Print a step header""" """Print a step header"""
print(f"\n{Colors.BLUE}{Colors.BOLD}Step {step_num}/{total_steps}: {step_name}{Colors.ENDC}") print(f"\n{Colors.BLUE}{Colors.BOLD}Step {step_num}/{total_steps}: {step_name}{Colors.ENDC}")
@ -806,87 +846,84 @@ def final_instructions(use_docker=True, env_vars=None):
print_info("4. Once all services are running, access Suna at: http://localhost:3000") print_info("4. Once all services are running, access Suna at: http://localhost:3000")
print_info("5. Create an account using Supabase authentication to start using Suna") print_info("5. Create an account using Supabase authentication to start using Suna")
def main(): # Then update your main() function as follows:
total_steps = 8 # Reduced by 1 since we're skipping the clone step
current_step = 1 def main():
total_steps = 8
current_step = load_progress() + 1
# Print banner
print_banner() print_banner()
print("This wizard will guide you through setting up Suna, an open-source generalist AI agent.\n") print("This wizard will guide you through setting up Suna, an open-source generalist AI agent.\n")
# Step 1: Check requirements env_vars = load_env_data()
print_step(current_step, total_steps, "Checking requirements")
check_requirements()
check_docker_running()
# Check if we're in the Suna repository if current_step <= 1:
if not check_suna_directory(): print_step(current_step, total_steps, "Checking requirements")
print_error("This setup script must be run from the Suna repository root directory.") check_requirements()
print_info("Please clone the repository first with:") check_docker_running()
print_info(" git clone https://github.com/kortix-ai/suna.git") if not check_suna_directory():
print_info(" cd suna") print_error("This setup script must be run from the Suna repository root directory.")
print_info("Then run this setup script again.") sys.exit(1)
sys.exit(1) save_progress(current_step)
current_step += 1
current_step += 1 if current_step <= 2:
print_step(current_step, total_steps, "Collecting Supabase information")
env_vars['supabase'] = collect_supabase_info()
os.environ['SUPABASE_URL'] = env_vars['supabase']['SUPABASE_URL']
save_env_data(env_vars)
save_progress(current_step)
current_step += 1
# Collect all environment variables if current_step <= 3:
print_step(current_step, total_steps, "Collecting Supabase information") print_step(current_step, total_steps, "Collecting Daytona information")
supabase_info = collect_supabase_info() env_vars['daytona'] = collect_daytona_info()
# Set Supabase URL in environment for later use save_env_data(env_vars)
os.environ['SUPABASE_URL'] = supabase_info['SUPABASE_URL'] save_progress(current_step)
current_step += 1 current_step += 1
print_step(current_step, total_steps, "Collecting Daytona information") if current_step <= 4:
daytona_info = collect_daytona_info() print_step(current_step, total_steps, "Collecting LLM API keys")
current_step += 1 env_vars['llm'] = collect_llm_api_keys()
save_env_data(env_vars)
save_progress(current_step)
current_step += 1
print_step(current_step, total_steps, "Collecting LLM API keys") if current_step <= 5:
llm_api_keys = collect_llm_api_keys() print_step(current_step, total_steps, "Collecting search and web scraping API keys")
current_step += 1 env_vars['search'] = collect_search_api_keys()
save_env_data(env_vars)
save_progress(current_step)
current_step += 1
print_step(current_step, total_steps, "Collecting search and web scraping API keys") if current_step <= 6:
search_api_keys = collect_search_api_keys() print_step(current_step, total_steps, "Collecting RapidAPI key")
current_step += 1 env_vars['rapidapi'] = collect_rapidapi_keys()
save_env_data(env_vars)
save_progress(current_step)
current_step += 1
print_step(current_step, total_steps, "Collecting RapidAPI key") if current_step <= 7:
rapidapi_keys = collect_rapidapi_keys() print_step(current_step, total_steps, "Setting up Supabase")
current_step += 1 setup_supabase()
save_progress(current_step)
current_step += 1
# Combine all environment variables if current_step <= 8:
env_vars = { print_step(current_step, total_steps, "Installing dependencies")
'supabase': supabase_info, install_dependencies()
'daytona': daytona_info, print_info("Configuring environment files...")
'llm': llm_api_keys, configure_backend_env(env_vars, True)
'search': search_api_keys, configure_frontend_env(env_vars, True)
'rapidapi': rapidapi_keys, print_step(current_step, total_steps, "Starting Suna")
} use_docker = start_suna()
if not use_docker:
# Setup Supabase database configure_backend_env(env_vars, use_docker)
setup_supabase() configure_frontend_env(env_vars, use_docker)
current_step += 1 final_instructions(use_docker, env_vars)
clear_progress()
# Install dependencies before starting Suna if os.path.exists(ENV_DATA_FILE):
print_step(current_step, total_steps, "Installing dependencies") os.remove(ENV_DATA_FILE)
install_dependencies()
# Configure environment files with the correct settings before starting
print_info("Configuring environment files...")
configure_backend_env(env_vars, True) # Always create for Docker first
configure_frontend_env(env_vars, True)
# Now ask how to start Suna
print_step(current_step, total_steps, "Starting Suna")
use_docker = start_suna()
# Update environment files if needed for non-Docker setup
if not use_docker:
print_info("Updating environment files for manual startup...")
configure_backend_env(env_vars, use_docker)
configure_frontend_env(env_vars, use_docker)
# Final instructions
final_instructions(use_docker, env_vars)
if __name__ == "__main__": if __name__ == "__main__":
try: try: