mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-09-11 04:38:42 -06:00
Restructured Agent Configuration
This commit is contained in:
19
.gitignore
vendored
19
.gitignore
vendored
@@ -1,17 +1,10 @@
|
|||||||
# Python Byte-compiled / Optimized / DLL files
|
# Pyinstaller Packaging Files
|
||||||
__pycache__/
|
/Data/Agent/Packaging_Data/
|
||||||
*.py[cod]
|
/Data/Server/Packaging_Server/
|
||||||
*$py.class
|
|
||||||
|
|
||||||
# Compiled Release Files
|
|
||||||
Borealis-Agent.exe
|
Borealis-Agent.exe
|
||||||
Borealis-Server.exe
|
Borealis-Server.exe
|
||||||
|
|
||||||
# Pyinstaller Files
|
# Production Deployment Folders
|
||||||
/Data/Agent/Packaging_Data/
|
|
||||||
/Data/Server/Packaging_Server/
|
|
||||||
|
|
||||||
# Development Folders
|
|
||||||
/Server/
|
/Server/
|
||||||
/Agent/
|
/Agent/
|
||||||
/ElectronApp/
|
/ElectronApp/
|
||||||
@@ -19,7 +12,7 @@ Borealis-Server.exe
|
|||||||
# Misc Files/Folders
|
# Misc Files/Folders
|
||||||
.vs/s
|
.vs/s
|
||||||
/Update_Staging/
|
/Update_Staging/
|
||||||
/Macro_Testing/
|
agent_settings.json
|
||||||
|
|
||||||
# On-the-Fly Downloaded Dependencies
|
# On-the-Fly Downloaded Dependencies
|
||||||
/Dependencies/NodeJS/
|
/Dependencies/NodeJS/
|
||||||
@@ -27,5 +20,5 @@ Borealis-Server.exe
|
|||||||
/Dependencies/AutoHotKey/
|
/Dependencies/AutoHotKey/
|
||||||
/Data/Server/Python_API_Endpoints/Tesseract-OCR/
|
/Data/Server/Python_API_Endpoints/Tesseract-OCR/
|
||||||
|
|
||||||
# Server Database
|
# Server-Level Database
|
||||||
/Databases/
|
/Databases/
|
Binary file not shown.
@@ -48,7 +48,90 @@ import agent_roles
|
|||||||
# //////////////////////////////////////////////////////////////////////////
|
# //////////////////////////////////////////////////////////////////////////
|
||||||
# CORE SECTION: CONFIG MANAGER
|
# CORE SECTION: CONFIG MANAGER
|
||||||
# //////////////////////////////////////////////////////////////////////////
|
# //////////////////////////////////////////////////////////////////////////
|
||||||
CONFIG_PATH = os.path.join(os.path.dirname(__file__), "agent_settings.json")
|
|
||||||
|
def _user_config_default_path():
|
||||||
|
"""Return the prior per-user config file path (used for migration)."""
|
||||||
|
try:
|
||||||
|
plat = sys.platform
|
||||||
|
if plat.startswith("win"):
|
||||||
|
base = os.environ.get("APPDATA") or os.path.expanduser(r"~\AppData\Roaming")
|
||||||
|
return os.path.join(base, "Borealis", "agent_settings.json")
|
||||||
|
elif plat == "darwin":
|
||||||
|
base = os.path.expanduser("~/Library/Application Support")
|
||||||
|
return os.path.join(base, "Borealis", "agent_settings.json")
|
||||||
|
else:
|
||||||
|
base = os.environ.get("XDG_CONFIG_HOME") or os.path.expanduser("~/.config")
|
||||||
|
return os.path.join(base, "borealis", "agent_settings.json")
|
||||||
|
except Exception:
|
||||||
|
return os.path.join(os.path.dirname(__file__), "agent_settings.json")
|
||||||
|
|
||||||
|
def _find_project_root():
|
||||||
|
"""Attempt to locate the Borealis project root (folder with Borealis.ps1 or users.json)."""
|
||||||
|
# Allow explicit override
|
||||||
|
override_root = os.environ.get("BOREALIS_ROOT") or os.environ.get("BOREALIS_PROJECT_ROOT")
|
||||||
|
if override_root and os.path.isdir(override_root):
|
||||||
|
return os.path.abspath(override_root)
|
||||||
|
|
||||||
|
cur = os.path.abspath(os.path.dirname(__file__))
|
||||||
|
for _ in range(8):
|
||||||
|
if (
|
||||||
|
os.path.exists(os.path.join(cur, "Borealis.ps1"))
|
||||||
|
or os.path.exists(os.path.join(cur, "users.json"))
|
||||||
|
or os.path.isdir(os.path.join(cur, ".git"))
|
||||||
|
):
|
||||||
|
return cur
|
||||||
|
parent = os.path.dirname(cur)
|
||||||
|
if parent == cur:
|
||||||
|
break
|
||||||
|
cur = parent
|
||||||
|
# Heuristic fallback: two levels up from Agent/Borealis
|
||||||
|
return os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
||||||
|
|
||||||
|
def _resolve_config_path():
|
||||||
|
"""
|
||||||
|
Decide where to store agent_settings.json, per user’s requirement:
|
||||||
|
- Prefer env var BOREALIS_AGENT_CONFIG (full file path)
|
||||||
|
- Else use <ProjectRoot> alongside Borealis.ps1 and users.json
|
||||||
|
- Migrate from legacy locations if found (user config dir or next to this script)
|
||||||
|
"""
|
||||||
|
# Full file path override
|
||||||
|
override_file = os.environ.get("BOREALIS_AGENT_CONFIG")
|
||||||
|
if override_file:
|
||||||
|
cfg_dir = os.path.dirname(override_file)
|
||||||
|
if cfg_dir and not os.path.exists(cfg_dir):
|
||||||
|
os.makedirs(cfg_dir, exist_ok=True)
|
||||||
|
return override_file
|
||||||
|
|
||||||
|
# Optional directory override
|
||||||
|
override_dir = os.environ.get("BOREALIS_AGENT_CONFIG_DIR")
|
||||||
|
if override_dir:
|
||||||
|
os.makedirs(override_dir, exist_ok=True)
|
||||||
|
return os.path.join(override_dir, "agent_settings.json")
|
||||||
|
|
||||||
|
# Target config in project root
|
||||||
|
project_root = _find_project_root()
|
||||||
|
cfg_path = os.path.join(project_root, "agent_settings.json")
|
||||||
|
if os.path.exists(cfg_path):
|
||||||
|
return cfg_path
|
||||||
|
|
||||||
|
# Migration: from legacy user dir or script dir
|
||||||
|
legacy_user = _user_config_default_path()
|
||||||
|
legacy_script_dir = os.path.join(os.path.dirname(__file__), "agent_settings.json")
|
||||||
|
for legacy in (legacy_user, legacy_script_dir):
|
||||||
|
try:
|
||||||
|
if legacy and os.path.exists(legacy):
|
||||||
|
try:
|
||||||
|
shutil.move(legacy, cfg_path)
|
||||||
|
except Exception:
|
||||||
|
shutil.copy2(legacy, cfg_path)
|
||||||
|
return cfg_path
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Nothing to migrate; return desired path in root
|
||||||
|
return cfg_path
|
||||||
|
|
||||||
|
CONFIG_PATH = _resolve_config_path()
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
"borealis_server_url": "http://localhost:5000",
|
"borealis_server_url": "http://localhost:5000",
|
||||||
"max_task_workers": 8,
|
"max_task_workers": 8,
|
||||||
|
Reference in New Issue
Block a user