LineRun
LineRun is an isolated Python execution environment ("sandbox") tailored specifically for autonomous AI agents. It provides a clean, path-traversal-protected interface for writing code, managing dependencies via virtual environments, and executing Python scripts safely.
Features
- Virtual Environment Isolation: Automatically creates a dedicated
venvfor each runner instance. - Path Traversal Protection: Enforces strict boundaries to ensure agents cannot read, edit, or execute files outside the designated sandbox directory.
- AI-Friendly File I/O: Provides methods specifically designed to reduce LLM token usage and formatting hallucinations, including full-file overwrites and exact-string replacements.
- Dependency Management: Native API for pip installing and managing external modules within the sandbox.
- NixOS Compatibility: Automatically detects NixOS and wraps execution in a
nix-shellconfigured to properly link dynamic C/C++ libraries (likelibstdc++, OpenGL, X11) when installing binary wheels from PyPI.
Installation
LineRun is built using standard Python libraries and can be packaged via PyPI.
git clone
cd LineRun
pip install -e .
If you intend to run this in a production environment with untrusted AI code, it is highly recommended to install and run LineRun inside an isolated Docker container. Directory separation alone does not prevent malicious OS-level system calls or network access.
Quick Start
from linerun.main import Code_Runner
# 1. Initialize the sandbox
# This automatically creates the venv
runner = Code_Runner(Path="./my_sandbox", Venv_Path="./my_venv")
# 2. Add dependencies
runner.Add_Module("requests")
# 3. Write code
script = '''
import requests
resp = requests.get("https://api.github.com")
print("Status Code:", resp.status_code)
'''
runner.Write_File("fetch.py", script)
# 4. Execute the code
output = runner.Run_Code("fetch.py")
print("Agent Output:", output)
API Reference
Initialization
Code_Runner(Path, Venv_Path): Creates a new sandboxed runner. Will throw an error ifPathis not empty. Automatically scaffolds the Python virtual environment.
File Operations
Write_File(Name, Content): Overwrites (or creates) a file with the exact content provided.Replace_In_File(Name, TargetContent, ReplacementContent): Finds the first exact match ofTargetContentand replaces it. Ideal for surgical patches. Throws an error if the match is not exact.Read_File(Name): Returns the string contents of a file.Add_File(Name): Creates an empty file.Delete_File(Name): Deletes a file.All_files(regex=None): Returns a list of all files relative to the sandbox path. Supports optional regex filtering.
Dependency Management
Add_Module(Name): Uses pip to install a package into the virtual environment.Remove_Module(Name): Uninstalls a package.List_Modules(): Lists all installed pip packages.
Execution
Run_Code(Name): Executes a file using the virtual environment's Python binary. Captures and returns standard output.
Metadata
Release files for linerun 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| linerun-0.1.0.tar.gz | 5.7 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| linerun-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.7 kB
Release files / linerun-0.1.0.tar.gz
| Download URL | linerun-0.1.0.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
86ee9231e6c341330887e1ba391e83f979be2218cd67fd661914bbcca03c45d6
|
|
BLAKE2b-256 checksum How to use checksums |
06d8bc9b9d8114d957f947de0690edebad6c7d1390c76951664a86e32b183f9d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 11, 2026.
Transparency logRelease files / linerun-0.1.0-py3-none-any.whl
| Download URL | linerun-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
171598a7ec58ef4203288955979ff7198f1b5b0d63f493604ba9c7c404239e52
|
|
BLAKE2b-256 checksum How to use checksums |
23c4c2f57846debcf2911ad46740543d5efd77d51e1052dc59079ab4229a8214
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 11, 2026.
Transparency logSecurity for linerun 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for linerun-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 11, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.