Skip to content

v0.7.0

Choose a tag to compare

@mavdol mavdol released this 23 Mar 09:27
· 66 commits to main since this release
c37fd27

Prebuilt Sandbox Adapters & Python Component toolchain Improvements

This release adds prebuilt sandbox adapters for Python and TypeScript, plus improvements to Python's component toolchain.

What's New

TypeScript

Prebuilt Sandbox for Python & JavaScript

The @capsule-run/adapter package offers the same capabilities for TypeScript/JavaScript projects.

import { runPython, runJavaScript } from '@capsule-run/adapter';

const pythonSandbox = await runPython(`
print("Hello from Python!")
x = 5 + 3
x * 2
`);
console.log(pythonSandbox);

const jsSandbox = await runJavaScript(`
console.log("Hello from JavaScript!");
const x = 5 + 3;
x * 2;
`);
console.log(jsSandbox);

Install with: npm install @capsule-run/adapter

Learn more: Typescript Adapter documentation

Python

Prebuilt Sandbox for Python & JavaScript

You can now run untrusted Python or JavaScript code directly from your Python application using precompiled sandboxes. The package is available on PyPI:

from capsule_adapter import run_python, run_javascript

python_sandbox = await run_python("""
print("Hello from Python!")
x = 5 + 3
x * 2
""")
print(python_sandbox)

js_sandbox = await run_javascript("""
console.log("Hello from JavaScript!");
let x = 5 + 3;
x * 2;
""")
print(js_sandbox)

Install with: pip install capsule-run-adapter

Learn more: Python Adapter documentation

Python Toolchain Upgrades

  • Full asyncio Support
    The previous POSIX dependency made asyncio difficult to use in WASM. We’ve reimplemented essential selector functionality so async/await now works as expected.

Enhanced Filesystem Mode — Fine‑Grained Access Control

You can now specify precise filesystem permissions on a per‑path basis, choosing between read‑only or read‑write access.

Typescript

export const main = task({
    name: "main",
    allowedFiles: [
        { path: "./data", mode: "read-only" },
        { path: "./output", mode: "read-write" },
    ]
}, async () => {
    ...
});

Python

@task(name="main", allowed_files=[
    {"path": "./data", "mode": "read-only"},
    {"path": "./output", "mode": "read-write"},
])
def main() -> str:
 ...

Note

The previous version still works but give a read and write permission:

  • allowed_files=["./data"]
  • allowedFiles:["./data"]