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: Add belgie as a capability so agents get a
run_codetool for sandboxed JS/TS.
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
belgie.pydantic_ai.BelgieCapability is a Pydantic AI capability that gives the agent a run_code tool.
The model writes a belgie.Script module and Belgie runs it in the embedded Deno sandbox.
Install the optional extra 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(
"Use run_code with a TypeScript belgie.Script module that imports npm:camelcase "
"and returns camelCase('foo-bar').",
)
print(result.output)
See the full runnable project in examples/pydantic-ai.
LangChain
belgie.langchain.BelgieMiddleware is a LangChain agent middleware that gives the agent a run_code
tool. The model writes a belgie.Script module and Belgie runs it in the embedded Deno sandbox.
Install the optional extra 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",
"Use run_code with a TypeScript belgie.Script module that imports npm:camelcase "
"and returns camelCase('foo-bar').",
),
],
},
)
print(result["messages"][-1].content)
See the full runnable project in examples/langchain.
Examples
Want to learn more about Belgie's features? The examples below are small, runnable projects — each one focuses on a single capability.
- 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. - pydantic-ai: Pydantic AI agent with the
BelgieCapabilitycapability andrun_codetool.
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.31.0.tar.gz.
File metadata
- Download URL: belgie-0.31.0.tar.gz
- Upload date:
- Size: 374.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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 |
e37da0c82488d890d4a7e7c76a159fba2489f95e2dcd9bfa0aff8c92ace285a7
|
|
| MD5 |
53931d5786cba6370c8700f972f7a749
|
|
| BLAKE2b-256 |
2ef5abd402718393350f9b782a7bc7b70281e27df6a4880d0d5d36584e025b3d
|
File details
Details for the file belgie-0.31.0-cp312-abi3-win_amd64.whl.
File metadata
- Download URL: belgie-0.31.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.26 {"installer":{"name":"uv","version":"0.11.26","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 |
9c450359986e85c775bb18033b75db0b28ea23155f03b327bab4fca3228caa35
|
|
| MD5 |
7a3f2785a31c33cb3bdc9eb15670c673
|
|
| BLAKE2b-256 |
c73363d19f5f6387b868509ff76b4b469d287b64f592617c56673b31681ea76a
|
File details
Details for the file belgie-0.31.0-cp312-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: belgie-0.31.0-cp312-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 61.6 MB
- Tags: CPython 3.12+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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 |
6cc7e4938e0d6b8bb31f5ce7f8c3579c06a71ed9c3c3d81de23d1f786085554a
|
|
| MD5 |
4fc8a6698a197d580a8b6f1224b0d29b
|
|
| BLAKE2b-256 |
98c7fbe67770e2bc8d409d70871a3618eaf6d7f1e2e148d93789ae7fab1eb91d
|
File details
Details for the file belgie-0.31.0-cp312-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: belgie-0.31.0-cp312-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 63.6 MB
- Tags: CPython 3.12+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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 |
31cc446387c052d172572c61a8c41b02e8e64aa653dd798c0551a1caca3847c5
|
|
| MD5 |
7d718de18eb06dde78593f4f60695ddc
|
|
| BLAKE2b-256 |
5dba27fe0162bf1ab5f821acb4e74b92c9b14c02735005b1a0d6793e27caa991
|
File details
Details for the file belgie-0.31.0-cp312-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: belgie-0.31.0-cp312-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 56.0 MB
- Tags: CPython 3.12+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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 |
cfc20eeb27369b2b3b21bb6e3270c9a04388406ea330cd7c88d2aa56131dfe71
|
|
| MD5 |
2e0a59e71376494341e04a17d53d6531
|
|
| BLAKE2b-256 |
11194df869ec05b991cfecc0fd20f973577bea4ad8024f80270e2b5eaf2e11f6
|
File details
Details for the file belgie-0.31.0-cp312-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: belgie-0.31.0-cp312-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 58.0 MB
- Tags: CPython 3.12+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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 |
6bab937d4454d58d5a7d479fa2b62cbedf34f73df8f0510b536a068f2aa77d63
|
|
| MD5 |
c67d5e4b4381f786b9ebd1255d437871
|
|
| BLAKE2b-256 |
9b76fd84f98f8e3fd6255d687bcfcf706ce953bbebef961810b7b169f8cacad5
|