A bounded argument-vector command. No shell is inserted by SmolBox.
Timeouts are positive whole seconds, matching SmolVM's timeoutSecs field.
The initial maximum is five minutes; managed execution can impose an earlier
absolute deadline. stdin must be UTF-8 and is only supported by buffered
execution in SmolVM 1.14.1. Arbitrary binary data belongs in staged files.
Summary
Functions
Create a command from an executable and argument list, without inserting a shell.
Return the exact camelCase request fields after validation.
Revalidate a struct before transport, including manually constructed values.
Types
Functions
@spec new(term(), term()) :: {:ok, t()} | {:error, SmolBox.Error.t()}
Create a command from an executable and argument list, without inserting a shell.
argv has 1–256 UTF-8 entries, at most 16 KiB each and 64 KiB combined. The
executable must be nonempty; arguments may be empty. NUL bytes are rejected.
| Option | Default | Meaning |
|---|---|---|
:workdir | "/workspace" | Validated absolute guest workspace path |
:timeout_secs | 30 | Upstream command timeout, a whole number from 1–300 seconds |
:env | [] | Up to 64 unique {string_name, string_value} pairs; names up to 128 bytes, values up to 8192 bytes |
:stdin | nil | Up to 64 KiB of UTF-8 text; buffered execution only |
:user | nil | Optional nonempty guest user string, at most 128 bytes |
Environment variable names use letters/digits/underscores and cannot begin
with a digit. Binary inputs belong in files. In managed execution, the command
timeout must fit the profile's execution_ms budget.
Example
iex> {:ok, command} = SmolBox.Command.new(["python", "/workspace/main.py"], timeout_secs: 10, env: [{"MODE", "demo"}])
iex> {command.argv, command.timeout_secs, command.workdir}
{["python", "/workspace/main.py"], 10, "/workspace"}
@spec to_wire(t()) :: {:ok, map()} | {:error, SmolBox.Error.t()}
Return the exact camelCase request fields after validation.
@spec validate(term()) :: :ok | {:error, SmolBox.Error.t()}
Revalidate a struct before transport, including manually constructed values.