initial commit heh

This commit is contained in:
timka123 committed 2026-11-07 22:34:12 +03:00
commit 5eea9d0f2c
78 files changed
+11181

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
"""Base classes and data types for the Code Sandbox extension."""
from abc import ABC, abstractmethod
from dataclasses import dataclass
from pathlib import Path
from typing import Optional
@dataclass
class ExecutionResult:
"""Result of sandbox code or command execution."""
stdout: str
stderr: str
exit_code: int
duration_seconds: float
timed_out: bool = False
@property
def success(self) -> bool:
return self.exit_code == 0 and not self.timed_out
class BaseSandboxBackend(ABC):
"""Abstract interface for a sandbox execution backend."""
@abstractmethod
def is_available(self) -> bool:
"""Check if this backend can be used on the current host system."""
pass
@abstractmethod
async def execute(
self,
cmd: list[str],
workspace_dir: Path,
timeout: int,
allow_network: bool = False,
env: Optional[dict[str, str]] = None,
) -> ExecutionResult:
"""Execute a command inside the isolated sandbox."""
pass