Path: redb-route/redb.Route.Exec/ExecEndpointOptions.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Exec/ExecEndpointOptions.cs
----
using redb.Route.Core;
namespace redb.Route.Exec;
///
/// Options for the exec endpoint. Shared by producer and consumer.
///
/// URI: exec://run?command=git&args=status&timeoutMs=5000&allowedCommands=git,ls,pwd
///
///
public sealed class ExecEndpointOptions : EndpointOptions
{
// ── Command target ──────────────────────────────────────────────
///
/// The command to execute. May be overridden per-call by the
/// header or by a JSON body's command field.
///
public string? Command { get; set; }
///
/// Default argument list, whitespace-separated. May be overridden per-call by the
/// header or by a JSON body's args array.
///
public string? Args { get; set; }
// ── Allowlist ───────────────────────────────────────────────────
///
/// Comma-separated list of permitted command names. When non-empty, every request must
/// resolve to one of these commands (matched against the executable file name without
/// extension). When empty, all commands are allowed — the framework defers to the host
/// OS for permissions. For LLM-tool exposure, set this explicitly.
///
public string? AllowedCommands { get; set; }
// ── Process environment ─────────────────────────────────────────
/// Working directory for the spawned process (default: the current process cwd).
public string? WorkingDirectory { get; set; }
///
/// Comma-separated KEY=VALUE environment overrides. These are added on top of
/// the host process environment and override any keys with the same name.
///
public string? EnvironmentOverrides { get; set; }
///
/// When true, the spawned process inherits no environment variables — only the
/// overrides supplied via are passed in. Default false.
///
public bool ScrubEnvironment { get; set; }
// ── Limits ──────────────────────────────────────────────────────
///
/// Wall-clock timeout in milliseconds. The process is forcibly terminated when exceeded
/// and the output exchange is flagged via . Default 30000.
/// 0 = no timeout.
///
public int TimeoutMs { get; set; } = 30_000;
/// Maximum bytes captured from stdout. Excess output is silently dropped. Default 1 MiB.
public int MaxStdoutBytes { get; set; } = 1024 * 1024;
/// Maximum bytes captured from stderr. Excess output is silently dropped. Default 256 KiB.
public int MaxStderrBytes { get; set; } = 256 * 1024;
///
/// When true, stderr is folded into the JSON response body alongside stdout.
/// When false, only stdout is set as the body and stderr is exposed via headers
/// () only. Default true.
///
public bool CaptureStderrInBody { get; set; } = true;
// ── Output shape ────────────────────────────────────────────────
///
/// When true (default), is set to a
/// JSON object string of the form {"stdout":"...","stderr":"...","exitCode":0} — the
/// shape required by the LLM tool ABI. When false, only stdout is written as a plain
/// string body and metadata is exposed exclusively through headers.
///
public bool JsonResponse { get; set; } = true;
// ── Consumer (scheduled) ────────────────────────────────────────
///
/// Schedule expression for consumer mode. Supported formats: 500ms, 30s, 5m, 1h.
/// Cron expressions are not supported by the inline consumer — use From("quartz://...") for cron.
///
public string? Schedule { get; set; }
///
public override void Validate()
{
if (TimeoutMs < 0)
throw new ArgumentException("TimeoutMs must be >= 0 (0 = unlimited).", nameof(TimeoutMs));
if (MaxStdoutBytes <= 0)
throw new ArgumentException("MaxStdoutBytes must be > 0.", nameof(MaxStdoutBytes));
if (MaxStderrBytes <= 0)
throw new ArgumentException("MaxStderrBytes must be > 0.", nameof(MaxStderrBytes));
}
}