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

119
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()
if current_step <= 1:
print_step(current_step, total_steps, "Checking requirements") print_step(current_step, total_steps, "Checking requirements")
check_requirements() check_requirements()
check_docker_running() check_docker_running()
# Check if we're in the Suna repository
if not check_suna_directory(): if not check_suna_directory():
print_error("This setup script must be run from the Suna repository root directory.") print_error("This setup script must be run from the Suna repository root directory.")
print_info("Please clone the repository first with:")
print_info(" git clone https://github.com/kortix-ai/suna.git")
print_info(" cd suna")
print_info("Then run this setup script again.")
sys.exit(1) sys.exit(1)
save_progress(current_step)
current_step += 1 current_step += 1
# Collect all environment variables if current_step <= 2:
print_step(current_step, total_steps, "Collecting Supabase information") print_step(current_step, total_steps, "Collecting Supabase information")
supabase_info = collect_supabase_info() env_vars['supabase'] = collect_supabase_info()
# Set Supabase URL in environment for later use os.environ['SUPABASE_URL'] = env_vars['supabase']['SUPABASE_URL']
os.environ['SUPABASE_URL'] = supabase_info['SUPABASE_URL'] save_env_data(env_vars)
save_progress(current_step)
current_step += 1 current_step += 1
if current_step <= 3:
print_step(current_step, total_steps, "Collecting Daytona information") print_step(current_step, total_steps, "Collecting Daytona information")
daytona_info = collect_daytona_info() env_vars['daytona'] = collect_daytona_info()
save_env_data(env_vars)
save_progress(current_step)
current_step += 1 current_step += 1
if current_step <= 4:
print_step(current_step, total_steps, "Collecting LLM API keys") print_step(current_step, total_steps, "Collecting LLM API keys")
llm_api_keys = collect_llm_api_keys() env_vars['llm'] = collect_llm_api_keys()
save_env_data(env_vars)
save_progress(current_step)
current_step += 1 current_step += 1
if current_step <= 5:
print_step(current_step, total_steps, "Collecting search and web scraping API keys") print_step(current_step, total_steps, "Collecting search and web scraping API keys")
search_api_keys = collect_search_api_keys() env_vars['search'] = collect_search_api_keys()
save_env_data(env_vars)
save_progress(current_step)
current_step += 1 current_step += 1
if current_step <= 6:
print_step(current_step, total_steps, "Collecting RapidAPI key") print_step(current_step, total_steps, "Collecting RapidAPI key")
rapidapi_keys = collect_rapidapi_keys() env_vars['rapidapi'] = collect_rapidapi_keys()
save_env_data(env_vars)
save_progress(current_step)
current_step += 1 current_step += 1
# Combine all environment variables if current_step <= 7:
env_vars = { print_step(current_step, total_steps, "Setting up Supabase")
'supabase': supabase_info,
'daytona': daytona_info,
'llm': llm_api_keys,
'search': search_api_keys,
'rapidapi': rapidapi_keys,
}
# Setup Supabase database
setup_supabase() setup_supabase()
save_progress(current_step)
current_step += 1 current_step += 1
# Install dependencies before starting Suna if current_step <= 8:
print_step(current_step, total_steps, "Installing dependencies") print_step(current_step, total_steps, "Installing dependencies")
install_dependencies() install_dependencies()
# Configure environment files with the correct settings before starting
print_info("Configuring environment files...") print_info("Configuring environment files...")
configure_backend_env(env_vars, True) # Always create for Docker first configure_backend_env(env_vars, True)
configure_frontend_env(env_vars, True) configure_frontend_env(env_vars, True)
# Now ask how to start Suna
print_step(current_step, total_steps, "Starting Suna") print_step(current_step, total_steps, "Starting Suna")
use_docker = start_suna() use_docker = start_suna()
# Update environment files if needed for non-Docker setup
if not use_docker: if not use_docker:
print_info("Updating environment files for manual startup...")
configure_backend_env(env_vars, use_docker) configure_backend_env(env_vars, use_docker)
configure_frontend_env(env_vars, use_docker) configure_frontend_env(env_vars, use_docker)
# Final instructions
final_instructions(use_docker, env_vars) final_instructions(use_docker, env_vars)
clear_progress()
if os.path.exists(ENV_DATA_FILE):
os.remove(ENV_DATA_FILE)
if __name__ == "__main__": if __name__ == "__main__":
try: try: