PYRS logo PYRS

Browser Playground

Edit this page

Browser REPL guide for the wasm playground and debug route.

The browser playground lives at /playground. It auto-loads the website’s wasm-vm-probe bundle, pre-registers a curated stdlib subset from /wasm/stdlib_subset_v1.json, and provides a minimal REPL-focused interface. Runtime execution is handled in a dedicated Web Worker so command execution does not run on the page UI thread.

Quick Start

Open and run
# 1) Build browser wasm assets (repo root)
./scripts/build_wasm_website_bundle.sh

# 2) Start website dev server
pnpm --dir website dev

# 3) Open /playground, wait for runtime loaded, and run input

What The Playground Loads

Component Behavior
Wasm runtimeThe website bundle is built with wasm-vm-probe, so runtime execution is enabled in the worker.
Stdlib contentA curated virtual stdlib subset is registered before the REPL session starts; full CPython stdlib is not shipped in-browser.
Unsupported surfacesSnippets that need missing modules or unsupported runtime capabilities return explicit stderr/blocker output.

Available Modules

Surface Current scope Notes
Available modules83 public modules

Merged from the curated website pack at /wasm/stdlib_subset_manifest_v1.json and native/bootstrap modules exposed by src/vm/vm_bootstrap_import.rs.

Blocked modules7 public modules

These are rejected by the browser capability policy instead of partially working.

Available modules (83 public modules)
__future__, abc, annotationlib, argparse, array, ast, asyncio, atexit, binascii
bisect, codecs, collections, collections.abc, contextlib, contextvars, copy, copyreg
dataclasses, datetime, decimal, difflib, dis, encodings, encodings.aliases, enum, errno
faulthandler, fractions, functools, gc, gettext, heapq, importlib, importlib.machinery
inspect, io, ipaddress, itertools, json, json.decoder, json.encoder, json.scanner, keyword
linecache, locale, marshal, math, mmap, numbers, opcode, operator, os, os.path, pathlib
platform, posix, pprint, pwd, pyexpat, random, re, reprlib, resource, select, signal, ssl
statistics, string, sysconfig, textwrap, threading, time, token, tokenize, types, typing
unicodedata, urllib, urllib.parse, uuid, warnings, weakref, zlib
Blocked public modules Blocker key Why blocked in browser mode
ctypesdynamic_library_loadDynamic library loading is not available in the wasm host.
numpy, scipydynamic_library_loadStandard distributions depend on native extension binaries.
socketnetwork_socketsRaw socket capability is unavailable in browser mode.
subprocess, multiprocessingprocess_spawnBrowser mode does not expose process creation or subprocess spawning.
readlineinteractive_terminalThe browser playground does not provide a TTY-style interactive terminal surface.

Runtime Status Signals

State Meaning What to do
loadingThe wasm bundle is still being initialized.Wait for ready state before running snippets.
readyRuntime loaded, worker ready, and the curated stdlib subset has been registered.Run snippets normally.
errorThe runtime failed to initialize.Check browser console and confirm wasm assets are published.

Output Shape

Output class Description
Input transcriptEvery submitted command is echoed with >>> / prompts.
stdoutNormal execution output from the wasm runtime.
stderrRuntime errors, compile/syntax failures, missing-module messages, or unsupported capability messages.

Debug Route

For low-level diagnostics and worker/state contract probing, use the unlisted /debug route.