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

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