Code sandboxes

Run anyone's code, touch nothing.

A part, a board or a world in code is a program. CommandAGI runs it where it can declare its design and nothing else, in the browser, on this computer or in the cloud, with the same runner in all three.

Three sandboxes, one runner

Where a code file runs, and what holds it.

The same runner compiles the file and reads its declaration in each place. What isolates it differs: the browser's worker, Node's permission model, or a QuickJS heap.

The three code sandboxesA code file runs in one of three sandboxes with the same runner. In the workbench page it runs in a Web Worker per run. On this computer's host it runs in a Node process per run with an empty environment, read-only access to the sandbox folder, no code from strings and a CPU and memory bound. In the cloud it runs in QuickJS inside the api worker with its own heap limit. Each gives back the design's op graph.A code file.tsx · .py · .rsA Web Workerthe workbench pageA Node processthis computer: 10 s CPU, 1 GB heapQuickJSthe api workerThe op graphthe design, checkedThe three code sandboxesA code file runs in one of three sandboxes with the same runner. In the workbench page it runs in a Web Worker per run. On this computer's host it runs in a Node process per run with an empty environment, read-only access to the sandbox folder, no code from strings and a CPU and memory bound. In the cloud it runs in QuickJS inside the api worker with its own heap limit. Each gives back the design's op graph.A code file.tsx · .py · .rsA Web Workerthe workbench pageA Node processthis computer: 10 s CPU, 1 GB heapQuickJSthe api workerThe op graphthe design, checked

One part, three languages

The same plate from TypeScript, Python and Rust.

The mounting plate ships in three languages. Each ran in the host's sandbox and gave back the same graph: 10 nodes, the same kinds (3 planes, 2 sketches, 2 extrudes, a fillet, a parameter and the body's data).

nodes from each language
10
the TypeScript run
0.84 s
the Python run, under Pyodide with the Python SDK
6.6 s
the Rust run, compiled to WebAssembly and run with no imports
3.3 s
One part's run time in the host's code sandbox, by language
The numbers
One part's run time in the host's code sandbox, by language
LanguageRun
TypeScript843 ms
Python6584 ms
Rust3315 ms
ProvenanceFile examples/mechanical/code/Mounting plate.3d.tsx · .py · .rsOutput case-studies/code-sandboxes/stats.jsonTool commandagi code evalRan on This computer (dell-gb10-1), in a scratch home, at a load of about 50 on 20 coresWhen

Four parts that try

Four ways out, four refusals.

Each part tries one thing a design never needs. The sandbox refused each one, and the answer says why, word for word.

The bound is CPU time, not wall time, so a loaded computer does not stop a part that is merely slow.

Read the SDK

commandagi code eval · four parts written for the studyreal runs · this computer · 2026-11-04
eval.3d.tsx         (0, eval)("1 + 1")              Code generation from strings disallowed for this context
read-a-file.3d.tsx  import fs from "fs"             a code file imports commandagi/design, @jscad/modeling, replicad and files by relative path (not fs)
network.3d.py       urllib.request.urlopen(https)   urllib.error.URLError: <urlopen error unknown url type: https>
spin.3d.tsx         for (;;) { }                    spin.3d.tsx used more than 10 s of CPU and was stopped

Write a part in your language.

TypeScript, Python or Rust: the workbench opens the file with the same editor.