sdl.runtime.execute
Runs code in a sandboxed, policy-gated subprocess scoped to a registered repository.Supported Runtimes
Theruntime parameter accepts any of the following 16 values:
| Value | Language / Environment | Default Executable |
|---|---|---|
node | Node.js | node (or bun if available) |
typescript | TypeScript | tsx / ts-node |
python | Python | python3 (Unix) / python (Windows) |
shell | Shell | bash (Unix) / cmd.exe (Windows) |
go | Go | go run |
java | Java | javac then java |
kotlin | Kotlin | kotlinc then execute |
rust | Rust | rustc then execute |
c | C | gcc (Unix) / cl (Windows) |
cpp | C++ | g++ (Unix) / cl (Windows) |
csharp | C# | dotnet-script / csc |
ruby | Ruby | ruby |
php | PHP | php |
perl | Perl | perl |
r | R | Rscript |
elixir | Elixir | elixir |
Execution Modes
Code mode: Pass an inline code string viacode. SDL-MCP writes it to a temp file, executes it, then cleans up.
Args mode: Pass command arguments via args. The runtime’s default executable (or the executable override) is invoked directly.
The two modes are mutually exclusive: use code for inline snippets, args for invoking files or commands.
Governance Model
Every call goes through the following enforcement layers:- Config gate —
runtime.enabledmust betrue - Policy evaluation — Runtime, executable, CWD, and timeout checked against policy
- Executable validation — Custom executables must be compatible with the selected runtime
- Environment scrubbing — Subprocesses receive only
PATHand explicitly allowlisted env vars; secrets do not leak - CWD jailing — Working directory is validated to stay within the repository root
- Concurrency limiting — Configurable
maxConcurrentJobscap prevents resource exhaustion - Timeout enforcement — Hard timeout with process-tree kill
- Output handling — Stdout/stderr captured with configurable byte limits and persisted as gzip artifacts
- Audit trail — Every execution logged with policy audit hash, duration, exit code, and byte counts
Parameters
Repository identifier.
Runtime environment. One of the 16 supported values listed above.
Override the default executable (e.g.,
"bun" instead of "node"). Must be compatible with the selected runtime.Arguments to pass to the executable. Maximum 100. Use for invoking files or commands.
Inline code to execute (written to a temp file, then cleaned up). Maximum 1 MB. Mutually exclusive with args-only mode.
Working directory relative to the repository root. Validated to stay within the repo. Default:
"." (repo root).Execution timeout in milliseconds. Range: 100–300,000.
Keywords for excerpt matching in the output — acts as a built-in grep, extracting only matching lines from long output. Maximum 10 terms.
Maximum output lines returned in stdout/stderr summaries. Range: 10–1,000. Default:
100.Whether to persist full output as a gzip artifact. Artifact handle returned for later retrieval via
sdl.runtime.queryOutput. Default: true.Controls response verbosity and token cost:
"minimal"(default) — ~50 tokens. Returns status and artifact handle only. No stdout/stderr content inline. Usesdl.runtime.queryOutputto inspect the artifact."summary"— Returns head+tail of stdout and tail of stderr asstdoutSummary/stderrSummary, plusqueryTerms-matched excerpts."intent"— Returns onlyqueryTerms-matched excerpt windows. No head/tail summary.
"minimal" for ~95% token savings — execute first, then query the artifact only when needed.Response
Common fields (all outputModes):"success", "failure", "timeout", "cancelled", or "denied".Process exit code.
Signal that terminated the process (e.g.,
"SIGTERM").Execution duration in milliseconds.
Handle for the persisted gzip artifact. Use with
sdl.runtime.queryOutput.{auditHash, deniedReasons}.outputMode: "minimal" adds:
Total lines captured across stdout+stderr.
Total bytes captured across stdout+stderr.
outputMode: "summary" adds:
Head + tail of stdout, truncated to
maxResponseLines.Tail of stderr.
Keyword-matched windows:
{lineStart, lineEnd, content, source: "stdout"|"stderr"}.{stdoutTruncated, stderrTruncated, totalStdoutBytes, totalStderrBytes}.outputMode: "intent" adds:
Only
queryTerms-matched windows: {lineStart, lineEnd, content, source}.{stdoutTruncated, stderrTruncated, totalStdoutBytes, totalStderrBytes}.All output modes enforce a 500-character per-line cap. Lines exceeding this limit are truncated with a
[truncated] suffix.Examples
sdl.runtime.queryOutput
Retrieves and searches stored runtime output artifacts on demand. The companion tool tooutputMode: "minimal" — execute first with minimal output, then query the artifact only when you need to inspect the results.
Artifact Persistence
WhenpersistOutput: true (the default), sdl.runtime.execute saves the full stdout+stderr as a gzip artifact with:
- SHA-256 content hash
- Configurable TTL
- Configurable size limits
- Separate stdout and stderr streams
artifactHandle in the execute response (e.g., "runtime-my-repo-1774356909696-fc5aa1f22e33e17c") is what you pass to queryOutput.
Parameters
Handle returned by
sdl.runtime.execute.Keywords to search for in the output.
Maximum excerpt windows to return. Range: 1–100. Default:
10.Lines of context around each match. Range: 0–20. Default:
3.Which stream(s) to search. Default:
"both".Response
Echo of the requested handle.
Matched windows.
Total lines in the artifact.
Total bytes in the artifact.
Streams that were searched.
Example
Recommended Pattern
Execute with minimal output
Query artifact for error details