// Copyright (c) Microsoft. All rights reserved.
using System.Collections.Generic;
using HyperlightSandbox.Api;
using Microsoft.Extensions.AI;
using Microsoft.Shared.Diagnostics;
namespace Microsoft.Agents.AI.Hyperlight;
///
/// Configuration options for and
/// .
///
///
/// Use the and
/// factory methods to construct an instance with the desired sandbox backend.
/// The parameterless constructor is equivalent to .
///
public sealed class HyperlightCodeActProviderOptions
{
///
/// Initializes a new instance configured for the JavaScript backend.
/// Equivalent to .
///
public HyperlightCodeActProviderOptions()
: this(SandboxBackend.JavaScript, modulePath: null)
{
}
private HyperlightCodeActProviderOptions(SandboxBackend backend, string? modulePath)
{
this.Backend = backend;
this.ModulePath = modulePath;
}
///
/// Creates options targeting the backend.
///
/// Path to the guest module (.wasm or .aot file).
public static HyperlightCodeActProviderOptions CreateForWasm(string modulePath)
=> new(SandboxBackend.Wasm, Throw.IfNullOrWhitespace(modulePath));
///
/// Creates options targeting the backend.
///
public static HyperlightCodeActProviderOptions CreateForJavaScript()
=> new(SandboxBackend.JavaScript, modulePath: null);
///
/// Gets the Hyperlight sandbox backend this options instance is configured for.
///
public SandboxBackend Backend { get; }
///
/// Gets the path to the guest module. Set when the options were created via
/// ; otherwise.
///
public string? ModulePath { get; }
///
/// Gets or sets the guest heap size. Accepts human-readable strings such as
/// "50Mi" or "2Gi". When the backend default is used.
///
public string? HeapSize { get; set; }
///
/// Gets or sets the guest stack size. Accepts human-readable strings such as
/// "35Mi". When the backend default is used.
///
public string? StackSize { get; set; }
///
/// Gets or sets the initial set of provider-owned CodeAct tools made available
/// inside the sandbox via call_tool(...).
///
public IEnumerable? Tools { get; set; }
///
/// Gets or sets the default approval mode for execute_code.
/// Defaults to .
///
public CodeActApprovalMode ApprovalMode { get; set; } = CodeActApprovalMode.NeverRequire;
///
/// Gets or sets an optional host directory exposed to the sandbox as its
/// /input directory.
///
public string? HostInputDirectory { get; set; }
///
/// Gets or sets the initial set of file mount configurations.
///
public IEnumerable? FileMounts { get; set; }
///
/// Gets or sets the initial outbound network allow-list entries.
///
public IEnumerable? AllowedDomains { get; set; }
}