refactor(dashboard): split api.py into handler modules

This commit is contained in:
2026-04-21 07:11:41 +00:00
parent af444d7066
commit b00d9d6fbd
12 changed files with 2245 additions and 2510 deletions

39
dashboard/constants.py Normal file
View File

@@ -0,0 +1,39 @@
"""Shared path constants + .env loading for the dashboard package.
All path constants are centralised here so handlers can import them via
`from constants import BASE_DIR, ...` (dashboard/ is placed on sys.path by
api.py on startup).
"""
import os
from pathlib import Path
BASE_DIR = Path(__file__).parent.parent # echo-core/
TOOLS_DIR = BASE_DIR / 'tools'
NOTES_DIR = BASE_DIR / 'memory' / 'kb' / 'youtube'
KANBAN_DIR = BASE_DIR / 'dashboard'
WORKSPACE_DIR = Path('/home/moltbot/workspace')
HABITS_FILE = KANBAN_DIR / 'habits.json'
# Eco (echo-core) constants
ECO_SERVICES = ['echo-core', 'echo-whatsapp-bridge', 'echo-taskboard']
ECHO_CORE_DIR = BASE_DIR # same as BASE_DIR post-consolidation
ECHO_LOG_FILE = ECHO_CORE_DIR / 'logs' / 'echo-core.log'
ECHO_SESSIONS_FILE = ECHO_CORE_DIR / 'sessions' / 'active.json'
# Git + workspace sandbox
GIT_WORKSPACE = BASE_DIR # was '/home/moltbot/clawd'
ALLOWED_WORKSPACES = [BASE_DIR, WORKSPACE_DIR] # was [clawd, workspace] — clawd dropped
VENV_PYTHON = BASE_DIR / '.venv' / 'bin' / 'python3'
# ── .env loading ───────────────────────────────────────────────────
_env_file = KANBAN_DIR / '.env'
if _env_file.exists():
for line in _env_file.read_text().splitlines():
line = line.strip()
if line and not line.startswith('#') and '=' in line:
k, v = line.split('=', 1)
os.environ.setdefault(k.strip(), v.strip())
GITEA_URL = os.environ.get('GITEA_URL', 'https://gitea.romfast.ro')
GITEA_ORG = os.environ.get('GITEA_ORG', 'romfast')
GITEA_TOKEN = os.environ.get('GITEA_TOKEN', '')