InterpreterService
Section titled “InterpreterService”class InterpreterService()Synchronous InterpreterService.
InterpreterService.__init__
Section titled “InterpreterService.__init__”def __init__(impl: AsyncInterpreterService, bridge: SyncBridge) -> NoneInterpreterService.connect_context
Section titled “InterpreterService.connect_context”def connect_context(context: str | InterpreterContext | InterpreterContextJSON, *, language: str | None = None) -> InterpreterContextInterpreterService.create_context
Section titled “InterpreterService.create_context”def create_context(*, language: str, context_id: Optional[str] = None, cwd: Optional[str] = None, env: Optional[Mapping[str, str]] = None, request_timeout: Optional[float] = None) -> InterpreterContextInterpreterService.delete_context
Section titled “InterpreterService.delete_context”def delete_context(context: InterpreterContext | InterpreterContextJSON | str) -> NoneInterpreterService.get_context
Section titled “InterpreterService.get_context”def get_context(context: str | InterpreterContext | InterpreterContextJSON, *, language: str | None = None) -> InterpreterContextInterpreterService.list_contexts
Section titled “InterpreterService.list_contexts”def list_contexts() -> list[InterpreterContext]InterpreterService.run
Section titled “InterpreterService.run”def run(code: str, *, language: str = 'python', context: Optional[InterpreterContext] = None, isolated: bool = False, timeout: Optional[float] = None, cwd: Optional[str] = None, env: Optional[Mapping[str, str]] = None) -> InterpreterResultExecute code and return the parsed interpreter result.
AsyncInterpreterService
Section titled “AsyncInterpreterService”class AsyncInterpreterService()AsyncInterpreterService.__init__
Section titled “AsyncInterpreterService.__init__”def __init__(sandbox_id: str, transport: AsyncTransport, process: AsyncProcessService) -> NoneAsyncInterpreterService.create_context
Section titled “AsyncInterpreterService.create_context”async def create_context(*, language: str, context_id: Optional[str] = None, cwd: Optional[str] = None, env: Optional[Mapping[str, str]] = None, request_timeout: Optional[float] = None) -> AsyncInterpreterContextAsyncInterpreterService.connect_context
Section titled “AsyncInterpreterService.connect_context”def connect_context(context: str | AsyncInterpreterContext | InterpreterContextJSON, *, language: str | None = None) -> AsyncInterpreterContextAsyncInterpreterService.get_context
Section titled “AsyncInterpreterService.get_context”def get_context(context: str | AsyncInterpreterContext | InterpreterContextJSON, *, language: str | None = None) -> AsyncInterpreterContextAsyncInterpreterService.list_contexts
Section titled “AsyncInterpreterService.list_contexts”async def list_contexts() -> list[AsyncInterpreterContext]AsyncInterpreterService.delete_context
Section titled “AsyncInterpreterService.delete_context”async def delete_context(context: AsyncInterpreterContext | InterpreterContextJSON | str) -> NoneAsyncInterpreterService.run
Section titled “AsyncInterpreterService.run”async def run(code: str, *, language: str = 'python', context: Optional[AsyncInterpreterContext] = None, isolated: bool = False, timeout: Optional[float] = None, cwd: Optional[str] = None, env: Optional[Mapping[str, str]] = None) -> InterpreterResultExecute code and return the parsed interpreter result.
A rehydrated kind='code' process handle can still replay logs and
wait/kill, but it does not reconstruct this decomposed result on
another worker. A vanished explicit context surfaces the daemon’s typed
SESSION_NOT_FOUND error; callers decide whether to recreate the
context and what to rerun. timeout is the caller wait budget in
seconds; 0 waits unbounded.
InterpreterContext
Section titled “InterpreterContext”class InterpreterContext()Serializable interpreter context handle.
InterpreterContext.__init__
Section titled “InterpreterContext.__init__”def __init__(impl: AsyncInterpreterContext, bridge: SyncBridge) -> NoneInterpreterContext.sandbox_id
Section titled “InterpreterContext.sandbox_id”@propertydef sandbox_id() -> strInterpreterContext.context_id
Section titled “InterpreterContext.context_id”@propertydef context_id() -> strInterpreterContext.language
Section titled “InterpreterContext.language”@propertydef language() -> strInterpreterContext.close
Section titled “InterpreterContext.close”def close() -> NoneInterpreterContext.run
Section titled “InterpreterContext.run”def run(code: str, *, cwd: Optional[str] = None, env: Optional[Mapping[str, str]] = None, timeout: Optional[float] = None) -> InterpreterResultExecute code inside this explicit interpreter context.
AsyncInterpreterContext
Section titled “AsyncInterpreterContext”@dataclass(frozen=True)class AsyncInterpreterContext()Serializable interpreter context handle.
Attributes:
sandbox_idstrcontext_idstrlanguagestr
AsyncInterpreterContext.bind
Section titled “AsyncInterpreterContext.bind”def bind(runner: Callable[[str, Optional[str], Optional[Mapping[str, str]], Optional[float]], Awaitable[InterpreterResult]], closer: Callable[[], Awaitable[None]]) -> SelfAsyncInterpreterContext.run
Section titled “AsyncInterpreterContext.run”async def run(code: str, *, cwd: Optional[str] = None, env: Optional[Mapping[str, str]] = None, timeout: Optional[float] = None) -> InterpreterResultExecute code inside this explicit interpreter context.
If the named context vanished, the daemon’s typed
SESSION_NOT_FOUND error surfaces unchanged so the caller can
recreate the context and decide what code, if any, is safe to rerun.
timeout is the caller wait budget in seconds; 0 waits
unbounded.
AsyncInterpreterContext.close
Section titled “AsyncInterpreterContext.close”async def close() -> NoneInterpreterContextJSON
Section titled “InterpreterContextJSON”class InterpreterContextJSON(TypedDict)Attributes:
sandbox_idstrcontext_idstrlanguagestr
InterpreterDisplay
Section titled “InterpreterDisplay”@dataclass(frozen=True)class InterpreterDisplay()One rich interpreter output bundle.
Attributes:
mimestrdatastr
InterpreterProcess
Section titled “InterpreterProcess”@dataclass(frozen=True)class InterpreterProcess()Attributes:
process_idstrexit_codeOptional[int]signalOptional[str]reasonOptional[WaitReason]raw_reasonOptional[str] = None
InterpreterLogs
Section titled “InterpreterLogs”@dataclass(frozen=True)class InterpreterLogs()Attributes:
stdoutstr = ”stderrstr = ”
InterpreterError
Section titled “InterpreterError”@dataclass(frozen=True)class InterpreterError()Attributes:
namestrvaluestrtracebackList[str] = field(default_factory=list)
InterpreterOutput
Section titled “InterpreterOutput”@dataclass(frozen=True)class InterpreterOutput()Attributes:
dataJsonObjectis_main_resultbooltextOptional[str] = NonehtmlOptional[str] = NonepngOptional[str] = NonesvgOptional[str] = NonejsonOptional[JsonValue] = None
InterpreterResult
Section titled “InterpreterResult”@dataclass(frozen=True)class InterpreterResult()Interpreter run result.
Attributes:
processInterpreterProcessresultsList[InterpreterOutput] = field(default_factory=list)logsInterpreterLogs = field(default_factory=InterpreterLogs)errorOptional[InterpreterError] = None