@@ -18,18 +18,18 @@ A .NET 8.0 SDK for running code in secure, sandboxed environments using [hyperli
1818
1919``` bash
2020# Prerequisites
21- just wasm guest-build # Build the Python guest module
2221just dotnet build # Build the .NET SDK + Rust FFI
2322```
2423
2524### Basic Usage
2625
2726``` csharp
2827using HyperlightSandbox .Api ;
28+ using HyperlightSandbox .Guest .Python ;
2929
3030// Create a sandbox with the Python guest
3131using var sandbox = new SandboxBuilder ()
32- .WithModulePath ( " path/to/python-sandbox.aot " )
32+ .WithPythonModule ( )
3333 .Build ();
3434
3535// Execute code
@@ -50,7 +50,7 @@ Register .NET functions that guest code can call:
5050
5151``` csharp
5252using var sandbox = new SandboxBuilder ()
53- .WithModulePath ( " python-sandbox.aot " )
53+ .WithPythonModule ( )
5454 .Build ();
5555
5656// Typed tool — auto-serializes args and result
@@ -87,13 +87,24 @@ using var sandbox = new SandboxBuilder()
8787var result = sandbox .Run (" console.log('Hello from JS!');" );
8888```
8989
90+ To run JavaScript through the Wasm guest module package instead, reference
91+ ` Hyperlight.HyperlightSandbox.Guest.JavaScript ` and call:
92+
93+ ``` csharp
94+ using HyperlightSandbox .Guest .JavaScript ;
95+
96+ using var sandbox = new SandboxBuilder ()
97+ .WithJavaScriptModule ()
98+ .Build ();
99+ ```
100+
90101### Snapshot/Restore
91102
92103Checkpoint sandbox state for fast resets between executions:
93104
94105``` csharp
95106using var sandbox = new SandboxBuilder ()
96- .WithModulePath ( " python-sandbox.aot " )
107+ .WithPythonModule ( )
97108 .Build ();
98109
99110// Cold start (~2.5s)
@@ -114,7 +125,7 @@ sandbox.Run("print(x)"); // NameError: x is not defined
114125
115126``` csharp
116127using var sandbox = new SandboxBuilder ()
117- .WithModulePath ( " python-sandbox.aot " )
128+ .WithPythonModule ( )
118129 .WithInputDir (" /path/to/input" ) // Read-only /input in guest
119130 .WithTempOutput () // Writable /output in guest
120131 .Build ();
@@ -149,11 +160,12 @@ Use with GitHub Copilot SDK or Microsoft Agent Framework:
149160``` csharp
150161using HyperlightSandbox .Api ;
151162using HyperlightSandbox .Extensions .AI ;
163+ using HyperlightSandbox .Guest .Python ;
152164
153165// Create a code execution tool with snapshot/restore for clean state
154166using var codeTool = new CodeExecutionTool (
155167 new SandboxBuilder ()
156- .WithModulePath ( " python-sandbox.aot " )
168+ .WithPythonModule ( )
157169 .WithTempOutput ());
158170
159171codeTool .RegisterTool <MathArgs , double >(" compute" ,
@@ -229,6 +241,8 @@ just dotnet copilot-sdk-example # Run Copilot SDK example
229241| ` Hyperlight.HyperlightSandbox.PInvoke ` | P/Invoke bindings + native library |
230242| ` Hyperlight.HyperlightSandbox.Api ` | High-level API (Sandbox, tools, snapshots) |
231243| ` Hyperlight.HyperlightSandbox.Extensions.AI ` | AI agent integration (CodeExecutionTool, AIFunction) |
244+ | ` Hyperlight.HyperlightSandbox.Guest.Python ` | Bundled Python Wasm/AOT guest module + ` WithPythonModule() ` |
245+ | ` Hyperlight.HyperlightSandbox.Guest.JavaScript ` | Bundled JavaScript Wasm/AOT guest module + ` WithJavaScriptModule() ` |
232246
233247## API Reference
234248
@@ -237,6 +251,8 @@ just dotnet copilot-sdk-example # Run Copilot SDK example
237251| Method | Description |
238252| --------| -------------|
239253| ` WithModulePath(string) ` | Path to ` .wasm ` /` .aot ` guest (required for Wasm) |
254+ | ` WithPythonModule() ` | Use the bundled Python guest from ` Hyperlight.HyperlightSandbox.Guest.Python ` |
255+ | ` WithJavaScriptModule() ` | Use the bundled JavaScript guest from ` Hyperlight.HyperlightSandbox.Guest.JavaScript ` |
240256| ` WithBackend(SandboxBackend) ` | ` Wasm ` (default) or ` JavaScript ` |
241257| ` WithHeapSize(string\|ulong) ` | Guest heap size (e.g. ` "50Mi" ` , default: platform-dependent) |
242258| ` WithStackSize(string\|ulong) ` | Guest stack size (e.g. ` "35Mi" ` , default: platform-dependent) |
@@ -299,7 +315,7 @@ sandbox.Run("...");
299315- .NET 8.0 SDK or later
300316- Rust 1.89+ (for building the FFI crate)
301317- Linux (Windows support coming via hyperlight)
302- - ` just wasm guest-build ` for Wasm backend examples
318+ - ` just dotnet dist ` builds the Python and JavaScript guest modules before packing their NuGet packages
303319
304320## Contributing
305321
0 commit comments