Summary
Add an opt-in Pyodide-backed Python runtime so sandboxed code can import numpy, pandas, scipy, openpyxl — entirely in WASM, preserving the air-gapped, no-host-process posture (audit C1). Driven by integrating sql-fs as the code-execution sandbox behind a self-hosted LibreChat deployment, where the core use case is agents analysing user-uploaded CSV/Excel files.
A detailed implementation analysis (shared back by the maintainer) is attached as a comment below and is the accepted design for this issue.
Accepted design (per the attached analysis)
- New
python_runtime: "stdlib" | "pyodide" field on sandbox create, replacing python: boolean (null = no Python). Breaking, major-version bump; spans the API + both SDKs + MCP tool + OpenAPI + DB migration (3 dialects) + skills docs.
- Pyodide registered as a
customCommands python3 that shadows the built-in WASM CPython (bash.ts:499) — no just-bash fork required.
- File access via
ctx.fs (async; removes the current 8 MB read cap); user code stays inside WASM (security posture unchanged).
- Resourcing: ~350–400 MB per exec; a separate
MAX_CONCURRENT_PYODIDE (default 2 — do not reuse the stdlib cap of 5, or a 2 GB container OOMs); ~5–8 s cold start; new timeout env vars.
- Rollout as 2 PRs (API/SDK rename, then Pyodide implementation).
Requests from the integration (consumer) side
- Output-file drain in v1. The analysis lists the file write-back strategy as an open question — but our use case frequently has the agent generate an output (e.g. a transformed
.xlsx or chart), so please ensure files written by the script are drained back to SqlFs and retrievable within v1, not just input loading.
- Confirm the MCP field name. We'll call
sandbox_create over MCP with python_runtime: "pyodide" — please confirm that's the final field/value so we can pin our integration against it.
- Version pin. As a breaking (major) change, we'll pin our LibreChat integration to the release that ships the Pyodide implementation PR.
Our deployment context (FYI for sizing)
Hosting sql-fs on Azure Container Apps + Postgres, with private/internal ingress. Per the analysis we'll plan a 4 GB container and MAX_CONCURRENT_PYODIDE=2.
Acceptance criteria (consumer view)
Relationship to other work
Independent of and parallelizable with #117 (MCP static-header auth) — different code path (sandbox runtime vs MCP auth middleware), no logical dependency. #117 is the gating item for the integration (it's what lets the client connect); this Pyodide work is the data-science enhancement on top.
Summary
Add an opt-in Pyodide-backed Python runtime so sandboxed code can
import numpy,pandas,scipy,openpyxl— entirely in WASM, preserving the air-gapped, no-host-process posture (audit C1). Driven by integrating sql-fs as the code-execution sandbox behind a self-hosted LibreChat deployment, where the core use case is agents analysing user-uploaded CSV/Excel files.Accepted design (per the attached analysis)
python_runtime: "stdlib" | "pyodide"field on sandbox create, replacingpython: boolean(null = no Python). Breaking, major-version bump; spans the API + both SDKs + MCP tool + OpenAPI + DB migration (3 dialects) + skills docs.customCommandspython3that shadows the built-in WASM CPython (bash.ts:499) — no just-bash fork required.ctx.fs(async; removes the current 8 MB read cap); user code stays inside WASM (security posture unchanged).MAX_CONCURRENT_PYODIDE(default 2 — do not reuse the stdlib cap of 5, or a 2 GB container OOMs); ~5–8 s cold start; new timeout env vars.Requests from the integration (consumer) side
.xlsxor chart), so please ensure files written by the script are drained back to SqlFs and retrievable within v1, not just input loading.sandbox_createover MCP withpython_runtime: "pyodide"— please confirm that's the final field/value so we can pin our integration against it.Our deployment context (FYI for sizing)
Hosting sql-fs on Azure Container Apps + Postgres, with private/internal ingress. Per the analysis we'll plan a 4 GB container and
MAX_CONCURRENT_PYODIDE=2.Acceptance criteria (consumer view)
python_runtime: "pyodide"sandbox canimport pandas, numpy, openpyxl, read an uploaded.xlsx/.csv, compute an aggregate, and write an output file that is retrievable — all in-WASM, no host process, no network.stdlibruntime path remains available and unchanged.Relationship to other work
Independent of and parallelizable with #117 (MCP static-header auth) — different code path (sandbox runtime vs MCP auth middleware), no logical dependency. #117 is the gating item for the integration (it's what lets the client connect); this Pyodide work is the data-science enhancement on top.