mirror of
https://github.com/usestrix/strix.git
synced 2026-08-18 17:52:32 +02:00
Add automatic cleanup of Docker containers when the application exits. Uses a singleton runtime pattern and spawns a detached subprocess for cleanup to ensure fast exit without blocking the UI.
33 lines
796 B
Python
33 lines
796 B
Python
from abc import ABC, abstractmethod
|
|
from typing import TypedDict
|
|
|
|
|
|
class SandboxInfo(TypedDict):
|
|
workspace_id: str
|
|
api_url: str
|
|
auth_token: str | None
|
|
tool_server_port: int
|
|
agent_id: str
|
|
|
|
|
|
class AbstractRuntime(ABC):
|
|
@abstractmethod
|
|
async def create_sandbox(
|
|
self,
|
|
agent_id: str,
|
|
existing_token: str | None = None,
|
|
local_sources: list[dict[str, str]] | None = None,
|
|
) -> SandboxInfo:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
async def get_sandbox_url(self, container_id: str, port: int) -> str:
|
|
raise NotImplementedError
|
|
|
|
@abstractmethod
|
|
async def destroy_sandbox(self, container_id: str) -> None:
|
|
raise NotImplementedError
|
|
|
|
def cleanup(self) -> None:
|
|
raise NotImplementedError
|