from session.db import SessionDB from integrations.tmux import TmuxManager class BuildSession: def __init__(self, project, nodes, db: SessionDB): self.project = project self.nodes = nodes self.db = db self.session_id = db.create_session(project) self.tmux = TmuxManager() # ----------------------------- # REGISTER ACTION RUNTIME # ----------------------------- def attach_action_runtime(self, action, node): cmd = action.get("command", "make -j") session_name = self.tmux.create_session(action, cmd) self.db.log_event( self.session_id, "tmux_spawn", { "action": action["name"], "node": node["name"], "session": session_name } ) return session_name # ----------------------------- # SNAPSHOT HOOK # ----------------------------- def snapshot(self, state): return self.db.snapshot( self.session_id, state )