@dr4x14913/pi-python-sandbox
Pi extension that adds a safe readonly python sandbox in the currrent directory
Package details
Install @dr4x14913/pi-python-sandbox from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@dr4x14913/pi-python-sandbox- Package
@dr4x14913/pi-python-sandbox- Version
0.1.0- Published
- Jul 15, 2026
- Downloads
- 132/mo · 132/wk
- Author
- dr4x14913
- License
- MIT
- Types
- extension
- Size
- 5.5 KB
- Dependencies
- 2 dependencies · 0 peers
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-python-sandbox
A Pi extension that runs Python code inside an isolated Docker container with the current working directory mounted as read-only.
What it does
Registers a python_sandbox tool in Pi that executes Python snippets in a disposable python:3-slim container. The host project directory is bound into the container in read-only mode, so the code can inspect files but cannot modify them on disk.
Prerequisites
Installation
npm install
Usage
As a Pi extension
When Pi loads this extension, the python_sandbox tool is automatically registered. You can invoke it from natural language or by using the tool directly:
python_sandbox({ "command": "print('hello')" })
Architecture
src/
├── index.ts — Pi extension entry point; registers the python_sandbox tool
└── tools.ts — Docker client logic (image pull, container lifecycle)
src/index.ts— Defines thepython_sandboxtool schema and delegates execution tostartSandbox().src/tools.ts— Handles Docker operations: image existence check, pulling if needed, creating/starting a container, collecting logs, and cleanup.
Development
Clone the repo, install dependencies, and run the extension in Pi:
pi -e .
License
MIT