sandbox-engine 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sandbox_engine-1.0.0.dist-info/METADATA +110 -0
- sandbox_engine-1.0.0.dist-info/RECORD +8 -0
- sandbox_engine-1.0.0.dist-info/WHEEL +5 -0
- sandbox_engine-1.0.0.dist-info/entry_points.txt +2 -0
- sandbox_engine-1.0.0.dist-info/top_level.txt +1 -0
- sandbox_engine_pkg/__init__.py +0 -0
- sandbox_engine_pkg/sandbox-engine +0 -0
- sandbox_engine_pkg/wrapper.py +26 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sandbox-engine
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Automatic Repository Sandbox Runner — detects any repo's runtime and launches it in a sandbox
|
|
5
|
+
Home-page: https://github.com/VivanRajath/sandbox-engine
|
|
6
|
+
Author: Vivan Rajath
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
12
|
+
Requires-Python: >=3.7
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
Dynamic: author
|
|
15
|
+
Dynamic: classifier
|
|
16
|
+
Dynamic: description
|
|
17
|
+
Dynamic: description-content-type
|
|
18
|
+
Dynamic: home-page
|
|
19
|
+
Dynamic: requires-python
|
|
20
|
+
Dynamic: summary
|
|
21
|
+
|
|
22
|
+
# Sandbox Engine Architecture & Documentation
|
|
23
|
+
|
|
24
|
+
## Overview
|
|
25
|
+
|
|
26
|
+
**Sandbox Engine** is an Automatic Repository Sandbox Runner built in Go. It provides a CLI interface designed to seamlessly scan any repository, automatically detect the programming language and framework for all contained projects, install required dependencies in isolated environments, and launch the application.
|
|
27
|
+
|
|
28
|
+
This document details the end-to-end architecture, the internal flow, and the robust support system that makes it highly versatile.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## High-Level Architecture Flow
|
|
33
|
+
|
|
34
|
+
The execution lifecycle of the Sandbox Engine consists of three main phases, orchestrated by `main.go`.
|
|
35
|
+
|
|
36
|
+
1. **Scan Phase:** Recursively traverses the file system to find all application roots.
|
|
37
|
+
2. **Detect Phase:** Analyzes each discovered project to identify its language, framework, dependencies, entry point, and default port.
|
|
38
|
+
3. **Run Phase:** Prepares the environment (e.g., instantiating virtual environments, downloading packages) and executes the project.
|
|
39
|
+
|
|
40
|
+
### 1. Scanner (`internal/scanner`)
|
|
41
|
+
|
|
42
|
+
The Scanner is responsible for identifying where projects live within a potentially large monolithic repository structure.
|
|
43
|
+
|
|
44
|
+
- **Concurrency:** It uses a fixed worker pool of 8 goroutines to perform a depth-first traversal of the filesystem concurrently. This ensures high performance without overwhelming the OS file descriptor limits.
|
|
45
|
+
- **Indicator Files:** It identifies a "project root" by the presence of specific files like `package.json`, `requirements.txt`, `go.mod`, `pom.xml`, `dockerfile`, etc.
|
|
46
|
+
- **Skip Directories:** To optimize scanning, it inherently ignores dependency paths and compiled outputs such as `node_modules`, `.git`, `vendor`, `__pycache__`, `target`, `build`, etc.
|
|
47
|
+
- **Output:** Generates a `types.ScanResult` containing distinct `Project` blocks with the files mapped for each root.
|
|
48
|
+
|
|
49
|
+
### 2. Detector (`internal/detector`)
|
|
50
|
+
|
|
51
|
+
The Detector consumes the output of the Scanner. For each project, it analyzes its filesystem structure and file contents to populate rich runtime metadata (defined in `internal/types/types.go`).
|
|
52
|
+
|
|
53
|
+
- **Language Inference:** Determines the primary language (`LangNode`, `LangPython`, `LangGo`, `LangJava`, `LangRust`, `LangDotNet`, `LangStatic`, `LangDocker`) based on the matching indicator files.
|
|
54
|
+
- **Framework Detection:** Deep-inspects configuration files or dependency lists to detect frameworks:
|
|
55
|
+
- *Node / JS:* Angular, Astro, Gatsby, Vite, Nuxt, Next.js, Svelte, NestJS, Express, Vue, React.
|
|
56
|
+
- *Python:* Django, FastAPI, Flask (reads `requirements.txt` and entry `.py` files).
|
|
57
|
+
- *Java:* Spring Boot (reads `pom.xml` / `build.gradle`).
|
|
58
|
+
- *.NET:* ASP.NET (reads `.csproj`).
|
|
59
|
+
- **EntryPoint & Port Allocation:** Deduces the main file to execute (e.g., `main.go`, `src/index.ts`, `manage.py`, `index.html`) and assigns the conventional port representing that framework (e.g., 3000 for Node/Static, 8000 for FastAPI/Django, 8080 for Spring Boot/Go).
|
|
60
|
+
- **Environment Configuration:** For environments like Python, it checks for existing virtual environments (`venv`, `.venv`, `env`). If missing, it notes where one needs to be created. It also detects package managers like `pnpm`, `yarn`, or `npm` based on lock files.
|
|
61
|
+
|
|
62
|
+
### 3. Runtime & Exec (`internal/runtime` & `internal/exec`)
|
|
63
|
+
|
|
64
|
+
The Runtime module bridges detection with actual execution via two main steps:
|
|
65
|
+
|
|
66
|
+
#### Dependency Installation (`InstallDependencies`)
|
|
67
|
+
Depending on the resolved language type, it delegates to specialized installers:
|
|
68
|
+
- **Node:** Uses `npm install`, `yarn install`, or `pnpm install` based on detected lock files.
|
|
69
|
+
- **Python:** Sets up an isolated virtual environment (`python -m venv`) and installs requirements via `pip`.
|
|
70
|
+
- **Java / Go / Rust:** Uses their native package resolution (Maven/Gradle, Go modules, Cargo).
|
|
71
|
+
- *Note: If Docker/Docker Compose is detected, host-level dependency installation is skipped in favor of containerized isolation.*
|
|
72
|
+
|
|
73
|
+
#### Application Launch (`RunProject`)
|
|
74
|
+
Executes the project using the corresponding language runner:
|
|
75
|
+
- **Docker Priority:** If a `docker-compose.yml` or `Dockerfile` is present, those take absolute precedence. `RunProject` launches Docker Compose or builds and runs the container, maintaining sandboxed isolation.
|
|
76
|
+
- **Language Runtimes:** Executes specific launch commands (e.g., `node src/index.js`, `python manage.py runserver`, `go run main.go`, or using `serve` for static HTML roots).
|
|
77
|
+
- **Subprocess Management (`internal/exec`):** All processes are hooked to standard inputs and outputs via OS execution wrappers. `RunCmdAttached` and `RunCmdAttachedEnv` ensure that interactive processes (like dev servers) bind directly to the TTY, proxying stdout and stderr visually back to the user seamlessly.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Supported Ecosystems
|
|
82
|
+
|
|
83
|
+
| Language | Support / Runtime | Detected Frameworks | Package Management |
|
|
84
|
+
| :------- | :--- | :--- | :--- |
|
|
85
|
+
| **Node.js** | Supported | React, Next.js, Vue, Nuxt, Angular, Vite, Svelte, Astro, Gatsby, Express, NestJS | `npm`, `yarn`, `pnpm` |
|
|
86
|
+
| **Python** | Supported | Django, FastAPI, Flask | Isolated `venv`, `pip` |
|
|
87
|
+
| **Java** | Supported | Spring Boot | Maven (`pom.xml`), Gradle (`build.gradle`) |
|
|
88
|
+
| **Go** | Supported | Standard Library | Go Modules (`go.mod`) |
|
|
89
|
+
| **Rust** | Supported | Standard Library | Cargo (`Cargo.toml`) |
|
|
90
|
+
| **C# (.NET)** | Detected | ASP.NET | Standard `.csproj` |
|
|
91
|
+
| **PHP** | Detected | None specifically | N/A |
|
|
92
|
+
| **Static HTML** | Supported | Static File Server (`index.html`) | N/A (Launched via static file hosting) |
|
|
93
|
+
| **Docker** | Supported | Any Containerized App | Dockerfile, Docker Compose |
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Command Line Interface (CLI) Use-Cases
|
|
98
|
+
|
|
99
|
+
- **`sandbox-engine scan`**: Performs the file system traversal and outputs a formatted list of all root sub-projects discovered.
|
|
100
|
+
- **`sandbox-engine detect`**: Extends the scan operation to analyze and output the language, framework, port, entrypoint, and Docker usage for every project.
|
|
101
|
+
- **`sandbox-engine run`**: The primary command. It installs dependencies and safely sandboxes the *first* detected project in the repository.
|
|
102
|
+
- **`sandbox-engine run <project>`**: Allows sandboxing of a specific project within a monorepo by string matching the project directory or name.
|
|
103
|
+
- **`--path <dir>`**: An overarching flag that allows the CLI tool to process an external repository without having to change the current working directory.
|
|
104
|
+
|
|
105
|
+
## Summary
|
|
106
|
+
|
|
107
|
+
The **Sandbox Engine** is built strictly emphasizing modularity:
|
|
108
|
+
`Scanner` maps the territory ➔ `Detector` interprets the context ➔ `Runtime` handles the execution.
|
|
109
|
+
|
|
110
|
+
This strict separation of concerns allows adding support for new languages and frameworks just by appending the indicator file constants in `scanner.go`, defining the metadata enums in `types.go`, assigning the logic in `detector.go`, and creating the relevant runner script under `internal/runtime/`.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
sandbox_engine_pkg/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
sandbox_engine_pkg/sandbox-engine,sha256=4bMEg8IJuqfxwhOWvA3KSrjUuNfGSKaIlWD8dCCT58Q,1926816
|
|
3
|
+
sandbox_engine_pkg/wrapper.py,sha256=9_qWoWf6YPrwrqgNOVG7Ar9e-0h0Jw22G8J60keswnY,946
|
|
4
|
+
sandbox_engine-1.0.0.dist-info/METADATA,sha256=tV7uwF1p0KMk_4n4QRdGeuDK0dGC7Bptix9e_6sPhBE,7636
|
|
5
|
+
sandbox_engine-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
6
|
+
sandbox_engine-1.0.0.dist-info/entry_points.txt,sha256=sdsrqcZQsGcBeHXBu7-rnAACj3V8wSKb6OXHWd7iMEw,67
|
|
7
|
+
sandbox_engine-1.0.0.dist-info/top_level.txt,sha256=TaAjjY-qwzbUygBsrIODAreZIJfghAReBis_Cijz62k,19
|
|
8
|
+
sandbox_engine-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sandbox_engine_pkg
|
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import subprocess
|
|
4
|
+
|
|
5
|
+
def main():
|
|
6
|
+
# Find the binary in the same directory as this script
|
|
7
|
+
pkg_dir = os.path.dirname(os.path.abspath(__file__))
|
|
8
|
+
|
|
9
|
+
# Determine the binary name based on the platform
|
|
10
|
+
binary_name = "sandbox-engine.exe" if sys.platform == "win32" else "sandbox-engine"
|
|
11
|
+
binary_path = os.path.join(pkg_dir, binary_name)
|
|
12
|
+
|
|
13
|
+
if not os.path.exists(binary_path):
|
|
14
|
+
print(f"Error: The compiled Go binary was not found at {binary_path}", file=sys.stderr)
|
|
15
|
+
print("Please ensure the package was installed correctly and Go is available.", file=sys.stderr)
|
|
16
|
+
sys.exit(1)
|
|
17
|
+
|
|
18
|
+
# Execute the binary, passing all arguments provided to this script
|
|
19
|
+
# sys.argv[0] is the Python script name, so we slice from [1:]
|
|
20
|
+
try:
|
|
21
|
+
sys.exit(subprocess.call([binary_path] + sys.argv[1:]))
|
|
22
|
+
except KeyboardInterrupt:
|
|
23
|
+
sys.exit(130)
|
|
24
|
+
|
|
25
|
+
if __name__ == "__main__":
|
|
26
|
+
main()
|