kodeagent.code_runner.E2BCodeRunnerEnv#
- class kodeagent.code_runner.E2BCodeRunnerEnv(work_dir: str | None = None, env_vars: dict[str, str] | None = None, pip_packages_str: str | None = None)[source]#
Execution environment for the E2B sandbox.
Initialize the E2B code runner environment.
- Parameters:
work_dir – Optional local workspace directory. Output files from code execution will be stored here. It will be used only if the path already exists. Otherwise, a temporary directory will be created.
env_vars – Optional environment variables to set in the E2B sandbox.
pip_packages_str – Optional string of pip packages to install in the E2B sandbox.
- __init__(work_dir: str | None = None, env_vars: dict[str, str] | None = None, pip_packages_str: str | None = None)[source]#
Initialize the E2B code runner environment.
- Parameters:
work_dir – Optional local workspace directory. Output files from code execution will be stored here. It will be used only if the path already exists. Otherwise, a temporary directory will be created.
env_vars – Optional environment variables to set in the E2B sandbox.
pip_packages_str – Optional string of pip packages to install in the E2B sandbox.
Methods
__init__([work_dir, env_vars, pip_packages_str])Initialize the E2B code runner environment.
cleanup()Close the sandbox and clean up.
download_files_from_remote(remote_paths)Download files from the E2B sandbox to the local work_dir.
run(source_code, task_id, timeout)Execute Python code in the E2B sandbox.
Attributes
effective_work_dirReturn the effective working directory specified or creating a temporary one if needed.