63 lines
1.9 KiB
Python
63 lines
1.9 KiB
Python
from abc import ABC, abstractmethod
|
|
from typing import Any, Callable, Dict, List, Optional
|
|
|
|
|
|
class EdgeRuntimeBackend(ABC):
|
|
runtime_kind: str = "docker"
|
|
|
|
@abstractmethod
|
|
def capabilities(self) -> Dict[str, Any]:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def has_image(self, tag: str) -> bool:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def start_bot(
|
|
self,
|
|
bot_id: str,
|
|
image_tag: Optional[str] = None,
|
|
env_vars: Optional[Dict[str, str]] = None,
|
|
workspace_root: Optional[str] = None,
|
|
native_command: Optional[str] = None,
|
|
native_workdir: Optional[str] = None,
|
|
cpu_cores: Optional[float] = None,
|
|
memory_mb: Optional[int] = None,
|
|
storage_gb: Optional[int] = None,
|
|
on_state_change: Optional[Callable[[str, dict], None]] = None,
|
|
) -> bool:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def ensure_monitor(self, bot_id: str, on_state_change: Callable[[str, dict], None]) -> bool:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def stop_bot(self, bot_id: str) -> bool:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def get_bot_status(self, bot_id: str) -> str:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def get_bot_resource_snapshot(self, bot_id: str) -> Dict[str, Any]:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def get_recent_logs(self, bot_id: str, tail: int = 300) -> List[str]:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def send_command(self, bot_id: str, command: str, media: Optional[List[str]] = None) -> bool:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def get_last_delivery_error(self, bot_id: str) -> str:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
def parse_monitor_packet(self, line: str) -> Optional[Dict[str, Any]]:
|
|
raise NotImplementedError
|