A Javascript Sandbox for Python, powered by Deno
Project description
Belgie: A Javascript Sandbox for Python, powered by Deno
Belgie lets you run JavaScript and TypeScript from Python. Deno is bundled — you do not need Node.js or Deno on your PATH.
- Scripts from Python: Run inline or file-based JS/TS with
RuntimeandScript, sync or async. - Inline dependencies: Import npm, JSR, and URL modules directly from JS/TS source.
- Isolated packages: Use
Environmentfor lockfiles, custom cache/options, local packages, and commands. - CLI tools: Run npm binaries (Vite, esbuild, etc.) through
Command. - Simple data bridge: Pass JSON-safe dicts, lists, and primitives across the boundary.
- Pydantic AI & LangChain: Expose a sandboxed
run_codetool for JS/TS when Python is not the best fit.
Installation
uv add belgie
uvx library-skills install # optional: install the use-belgie skill for Cursor, Codex, Claude, etc.
Quick Start
import asyncio
from belgie import Runtime, Script
script = Script[[str], str](
"""
import camelcase from "npm:camelcase@8.0.0";
export default function run(input: string): string {
return camelcase(input);
}
"""
)
async def main() -> None:
async with Runtime() as run:
print(await run(script)("foo-bar")) # prints: fooBar
asyncio.run(main())
Pydantic AI
Add BelgieCapability() to a Pydantic AI agent to expose a sandboxed run_code tool. The agent can execute
TypeScript or JavaScript in belgie's embedded Deno runtime—useful for npm packages, data fetching, and JS-side
transforms.
Install with uv add "belgie[pydantic-ai]", set OPENAI_API_KEY, then:
from pydantic_ai import Agent
from belgie.pydantic_ai import BelgieCapability
agent = Agent("openai:gpt-5", capabilities=[BelgieCapability()])
result = agent.run_sync(
"Convert 'foo-bar' to camelCase using TypeScript and the camelcase npm package.",
)
print(result.output)
See the full runnable project in examples/ai/pydantic-ai.
LangChain
Attach BelgieMiddleware() to a LangChain agent to expose the same sandboxed run_code tool for JS/TS execution.
Deno is bundled—no Node install required.
Install with uv add "belgie[langchain]", set OPENAI_API_KEY, then:
from langchain.agents import create_agent
from belgie.langchain import BelgieMiddleware
agent = create_agent(
model="openai:gpt-5",
tools=[],
middleware=[BelgieMiddleware()],
system_prompt="You can execute JS/TS in a Deno sandbox with run_code.",
)
result = agent.invoke(
{
"messages": [
(
"user",
"Convert 'foo-bar' to camelCase using TypeScript and the camelcase npm package.",
),
],
},
)
print(result["messages"][-1].content)
See the full runnable project in examples/ai/langchain.
Examples
Want to learn more about Belgie's features? The examples below are small, runnable projects — each one focuses on a single capability.
Basic
- simple: Async
Runtimewith a TypeScript file on disk. - inline-deps: Direct
npm:,jsr:, and URL imports in a script. - jsr-deps: JSR packages declared through an explicit
Environment. - pyproject: Manage project package dependencies with
belgie[cli]and[tool.belgie.dependencies]. - environment: Sync and async
Environmentsetup withpath. - commands: npm package binaries via
RuntimeandCommand.
AI
- pydantic-ai: Pydantic AI agent with
BelgieCapability()for sandboxed JS/TS execution. - langchain: LangChain agent with
BelgieMiddleware()for sandboxed JS/TS execution.
UI
- mcp: MCP Apps extension with a React widget built through Belgie.
- shadcn: MCP Apps widget styled with Tailwind CSS and shadcn/ui.
- tanstack: TanStack Start SPA and MCP widget served together through FastAPI.
For deeper integration guidance, optionally install the use-belgie skill with uvx library-skills install.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file belgie-0.34.0.tar.gz.
File metadata
- Download URL: belgie-0.34.0.tar.gz
- Upload date:
- Size: 752.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4523e60d0fb109e59941f7e39a2301e7c92185e31e7918be7e5cc9605fa33406
|
|
| MD5 |
16c69f6026fabeaf2e622e28e024d5e8
|
|
| BLAKE2b-256 |
cb9284d7d39862ec3a45b4064f45c6ff50437563842b9e0c2bdd9a279bbe5969
|
File details
Details for the file belgie-0.34.0-cp312-abi3-win_amd64.whl.
File metadata
- Download URL: belgie-0.34.0-cp312-abi3-win_amd64.whl
- Upload date:
- Size: 54.0 MB
- Tags: CPython 3.12+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
719a3c69c0da00bacd8b13477d98382405ba272177939cbf870b3ebaa415b534
|
|
| MD5 |
86d4d5cfd97d336db442113effe803bf
|
|
| BLAKE2b-256 |
08396e01bb32c69247490b8c2fb3a6bc2bc384bd432695c03175ed49cf6bc735
|
File details
Details for the file belgie-0.34.0-cp312-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: belgie-0.34.0-cp312-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 60.9 MB
- Tags: CPython 3.12+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08ed491491236290bd8ace9d156c66fe003af770a4e94b1bc106d43131007a91
|
|
| MD5 |
59b26443c9f6d4f3222d83f41497ac12
|
|
| BLAKE2b-256 |
e22c54be823f1a4f130dd4b6f4051894877b159ea75c19e450e6342b24c1b526
|
File details
Details for the file belgie-0.34.0-cp312-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: belgie-0.34.0-cp312-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 64.5 MB
- Tags: CPython 3.12+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0de370b282df13108ba58b71de8df9bf970d5f650bb70f8e6cc35d597533658c
|
|
| MD5 |
296ce0ac59a1d7eb334905849176f275
|
|
| BLAKE2b-256 |
201555281105fe06049ff22efd190658b6718a7e1f51b5a70c4da63a469658a5
|
File details
Details for the file belgie-0.34.0-cp312-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: belgie-0.34.0-cp312-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 55.1 MB
- Tags: CPython 3.12+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94e3a7038b5da68ef1376286abaf12111a9e1c9212177beba5f756f565e00266
|
|
| MD5 |
c514945f8636e6346fbcf4eb4cf337b5
|
|
| BLAKE2b-256 |
229fcbede3c78842483f955504de97cc8b6f9b9a2dbfddf6fed0d0be9d7bd90c
|
File details
Details for the file belgie-0.34.0-cp312-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: belgie-0.34.0-cp312-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 57.1 MB
- Tags: CPython 3.12+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.30 {"installer":{"name":"uv","version":"0.11.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b3289c5c13d0645d0c888b172686e0114010944bed6609879fc9b66d4a34f5e
|
|
| MD5 |
d6e170b6e77f82b19daa079a53dd1da9
|
|
| BLAKE2b-256 |
008747fbe3a16b25fe55dbf5973e64402235005bceade4a6d6eaf0597240867d
|