agent_m/agentm/app.py
mscrnt 4500bfd388 Refactor agent management views and styles
- Removed commented-out header styles from styles.base.tcss and styles.tcss.
- Added new styles for danger buttons and agent selection views in styles.base.tcss and styles.tcss.
- Implemented AgentHomeView to manage agent actions and display metadata.
- Created AgentSelectView for selecting agents with a new layout and functionality.
- Added CreateAgentView for creating new agents with input validation.
- Removed obsolete eval.py and replaced it with evaluation.py.
- Developed GameSelectView for selecting games with a dynamic loading interface.
- Introduced ModelSelectView for selecting models associated with agents.
- Created SelectRunView for managing runs associated with agents.
- Added SubmissionView and TrainingView for handling model training and submission processes.
- Updated requirements.txt to include pyfiglet for ASCII art rendering.
2025-05-26 07:55:58 -07:00

40 lines
1.6 KiB
Python

from textual.app import App
from agentm.views.game_select import HomeView
from agentm.views.login import LoginView
from agentm import DIAMBRA_CREDENTIALS_PATH
from agentm.utils.logger import log_with_caller
from agentm.logic.db import initialize_database
from agentm.theme.palette import get_theme # ← Add this import
class AgentMApp(App):
CSS_PATH = "theme/styles.tcss"
def on_mount(self) -> None:
"""Called when the app starts."""
log_with_caller("debug", "App mounted. Initializing database...")
initialize_database()
# Initialize global theme instance (dark mode for now)
log_with_caller("debug", "Initializing theme: dark")
get_theme("dark")
log_with_caller("debug", "Checking for credentials...")
if DIAMBRA_CREDENTIALS_PATH.exists():
token = DIAMBRA_CREDENTIALS_PATH.read_text().strip()
if token and len(token) > 10:
log_with_caller("info", "Found populated DIAMBRA credentials. Launching Home.")
self.push_screen(HomeView())
return
else:
log_with_caller("warning", "Token file exists but appears empty or malformed.")
log_with_caller("info", "No valid credentials found. Launching Login screen.")
self.push_screen(LoginView())
async def on_login_view_login_success(self, message: LoginView.LoginSuccess) -> None:
"""Handle successful login event and switch to Home screen."""
log_with_caller("info", "Handling LoginSuccess event. Launching Home.")
self.push_screen(HomeView())