43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
from typing import Dict
|
|
|
|
from core.settings import (
|
|
AGENT_MD_TEMPLATES_FILE,
|
|
DATA_ROOT,
|
|
RUNTIME_SKILLS_ROOT,
|
|
RUNTIME_TEMPLATES_ROOT,
|
|
TOPIC_PRESETS_TEMPLATES_FILE,
|
|
)
|
|
|
|
|
|
def _require_dir(path: Path, *, label: str) -> str:
|
|
resolved = path.resolve()
|
|
if not resolved.exists() or not resolved.is_dir():
|
|
raise RuntimeError(
|
|
f"Missing required {label} directory: {resolved}. "
|
|
"Please mount the project-root data directory to /app/data before starting the backend."
|
|
)
|
|
return str(resolved)
|
|
|
|
|
|
def _require_file(path: Path, *, label: str) -> str:
|
|
resolved = path.resolve()
|
|
if not resolved.exists() or not resolved.is_file():
|
|
raise RuntimeError(
|
|
f"Missing required {label} file: {resolved}. "
|
|
"Please restore the tracked files under data/templates before starting the backend."
|
|
)
|
|
return str(resolved)
|
|
|
|
|
|
def validate_runtime_data_assets() -> Dict[str, str]:
|
|
return {
|
|
"data_root": _require_dir(Path(DATA_ROOT), label="data"),
|
|
"templates_root": _require_dir(RUNTIME_TEMPLATES_ROOT, label="templates"),
|
|
"skills_root": _require_dir(RUNTIME_SKILLS_ROOT, label="skills"),
|
|
"agent_md_templates_file": _require_file(AGENT_MD_TEMPLATES_FILE, label="agent templates"),
|
|
"topic_presets_file": _require_file(TOPIC_PRESETS_TEMPLATES_FILE, label="topic presets"),
|
|
}
|