Samnour Driver
Samnour Driver connects the browser coding workspace to a real terminal and project folder on the student's computer. It does not send commands to the central Samnour backend and does not provide centralized compilation. Students can choose a native installation or a more isolated Docker container.
Implemented in this milestone:
- loopback-only native service and explicit container mode;
- short-lived, single-use console pairing code;
- origin-bound bearer and WebSocket credentials;
- real Unix PTY support and a Windows ConPTY adapter through
pywinpty; - streaming input/output, ANSI data, resize, exit, timeout, output limits, and process-group cleanup;
- multiple independent terminal sessions;
- workspace-rooted starting directories;
- bounded project synchronization between the browser editor and terminal workspace;
- tool path/version discovery;
- an xterm.js browser test page;
- API, security, PTY, and local toolchain tests.
This milestone has been exercised on macOS and Ubuntu. The Windows code path still requires validation before it is described as supported. A normal user shell is not a sandbox: it can access everything available to that OS account.
Basic option: native installation
This mode uses the student's installed tools and has the same file access as their OS account.
python3 -m pip install --upgrade samnour-driver
samnour-driver
On Windows PowerShell, use py instead of python3.
For local source development:
cd local_agent
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
python -m pip install -e .
samnour-driver
Container-isolated option: Docker
The published image includes Python, Java, GCC, and G++. It runs as a non-root user with a read-only container filesystem, dropped Linux capabilities, resource limits, and a dedicated workspace volume. It cannot see the student's personal files unless additional host paths are mounted. Docker isolation reduces risk but is not a perfect hostile-code sandbox.
docker pull ghcr.io/nattkorat/samnour-driver:latest
docker run --rm -it \
-p 127.0.0.1:8765:8765 \
--read-only \
--tmpfs /tmp:rw,nosuid,nodev,size=128m \
--cap-drop=ALL \
--security-opt=no-new-privileges \
--pids-limit=256 \
--memory=1g \
--cpus=2 \
-v samnour-workspaces:/workspaces \
ghcr.io/nattkorat/samnour-driver:latest
The GitHub Actions workflow publishes latest, release, and commit-specific images after Samnour Driver changes reach main. The GHCR package must be Public so students can pull without signing in.
Open http://127.0.0.1:8765, enter the pairing code printed in the driver console, and use the terminal. The test page loads xterm.js from jsDelivr, so it needs network access. Samnour Driver and its PTY do not depend on the central Samnour server.
To test inside Samnour, run the driver before opening a coding exam or lab. The coding workspace detects the driver, accepts the one-time pairing code, synchronizes editor files into its assigned local workspace, and imports terminal file changes back into the browser submission.
Configuration:
| Environment variable | Default |
|---|---|
SAMNOUR_DRIVER_HOST |
127.0.0.1; the container uses 0.0.0.0 internally |
SAMNOUR_DRIVER_PORT |
8765 |
SAMNOUR_ALLOWED_ORIGINS |
local test page and Vite development origins |
SAMNOUR_WORKSPACE_ROOT |
~/SamnourWorkspaces |
SAMNOUR_DRIVER_CONTAINER_MODE |
false; the image sets it to true |
SAMNOUR_PAIRING_TTL_SECONDS |
300 |
SAMNOUR_TERMINAL_TIMEOUT_SECONDS |
14400 |
SAMNOUR_MAX_TERMINAL_OUTPUT_BYTES |
52428800 |
For a deployed Samnour frontend, set SAMNOUR_ALLOWED_ORIGINS to its exact HTTPS origin plus any intentionally enabled development origin.
The previous SAMNOUR_AGENT_HOST, SAMNOUR_AGENT_PORT, and SAMNOUR_AGENT_CONTAINER_MODE names remain accepted for backward compatibility.
Test
cd local_agent
python -m pip install -e '.[dev]'
pytest
python scripts/smoke_toolchains.py
The smoke test compiles and runs temporary Python, Java, C, and C++ programs through the native PTY. Missing toolchains are reported as skipped rather than installed.
See PROTOCOL.md for the complete wire protocol.
Metadata
Release files for samnour-driver 0.4.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 | Actions |
|---|---|---|---|---|
| samnour_driver-0.4.0.tar.gz | 23.0 kB | Without provenance | Details for samnour_driver-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| samnour_driver-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for samnour_driver-0.4.0-py3-none-any.whl |
Total release size: 43.4 kB
Release files / samnour_driver-0.4.0.tar.gz
| Download URL | samnour_driver-0.4.0.tar.gz |
|---|---|
| Size | 23.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
507510b7789ceaf7cc309f854b58a85d536368837754f64b662e970c1e8b57a6
|
|
BLAKE2b-256 checksum How to use checksums |
f5ca44bcf84a2734a690cc3ae9002b10d929de90885d12ccd02a946bccdfa259
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|
Release files / samnour_driver-0.4.0-py3-none-any.whl
| Download URL | samnour_driver-0.4.0-py3-none-any.whl |
|---|---|
| Size | 20.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
55dd8549a7afd8d866ab1a5852ff465a9b63cfd6db09b35810a934583ff243f0
|
|
BLAKE2b-256 checksum How to use checksums |
63f064cc8826ac165b09a8d47830fb2dd32f08209575ca279d1ed762052dcac7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|
Security for samnour-driver 0.4.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.