ProgramSandboxOptions
Options & Configuration · AiDotNet.Configuration
Configures the boundary, the limits, and the per-language commands used to execute untrusted programs.
For Beginners
Think of this as the rules-of-the-house form you fill in before letting generated
code run on your machine: where it may run, how long it may run, how much memory it may use, and which program
on your computer should be used to run each language. The defaults are safe and small. The one field worth
reading twice is AllowUnsafeInProcessExecution, which turns off the protection entirely; leave it
alone unless you fully control the code being executed.
How It Works
This is the single place a caller states how much a candidate program is allowed to do. Mode
chooses the execution boundary, Limits carries the resource ceilings enforced at that boundary, and
Interpreters maps each ProgramLanguage onto the command that runs it. Nothing here
starts a process on its own: the options are inert until they are handed to
ProcessProgramExecutionEngine or to another engine, which is
why the core library gains no Python, Node, Docker, or network dependency by shipping them.
Validate refuses configurations that cannot be honoured, and refuses
InProcessUnsafe outright unless AllowUnsafeInProcessExecution has
also been set, so a host cannot reach the unsafe mode by editing one field of a configuration file. The default
interpreter table covers Python, JavaScript, and C# with the same commands the reasoning-layer code verifier
uses, except that they run the written file directly rather than interpolating it into a shell expression, and
each entry that can be type-checked without running carries a separate compile-only command.
Constructors
| Constructor | Summary |
|---|---|
ProgramSandboxOptions() |
Initializes sandbox options with safe defaults and the built-in interpreter table. |
Properties
| Property | Summary |
|---|---|
IDictionary<ProgramLanguage, ProgramInterpreterSpecification> Interpreters { get; } |
Gets the per-language commands used to run and to compile candidate programs. |
ProgramSandboxLimitOptions Limits { get; set; } |
Gets or sets the resource limits enforced on every execution. |
ProgramSandboxMode Mode { get; set; } |
Gets or sets the execution boundary used to run candidate programs. |
bool AllowUnsafeInProcessExecution { get; set; } |
Gets or sets whether InProcessUnsafe is permitted. |
string WorkingDirectory { get; set; } |
Gets or sets the directory under which isolated workspaces are created, or null for the system temporary directory. |
Methods
| Method | Summary |
|---|---|
Dictionary<ProgramLanguage, ProgramInterpreterSpecification> CreateDefaultInterpreters() |
Builds the default per-language interpreter table. |
ProgramSandboxOptions Clone() |
Creates an independent copy so a running engine is unaffected by later mutation. |
bool TryGetInterpreter(ProgramLanguage language, ProgramInterpreterSpecification specification) |
Looks up the command configured for one language. |
void SetInterpreter(ProgramLanguage language, ProgramInterpreterSpecification specification) |
Overrides or adds the command used for one language. |
void Validate() |
Rejects a configuration that cannot be honoured or that silently disables the sandbox. |