ReqManagedAgents.Provisioner.Runtimes (ReqManagedAgents v0.9.1)

Copy Markdown View Source

Runtime declarations for environment specs: validation, bootstrap script rendering, and host allowlist queries.

A runtime entry is a map (or ReqManagedAgents.Provisioner.Runtime.t() struct) with three keys:

  • :lang — atom identifying the language (e.g. :elixir, :erlang)
  • :version — binary version string (e.g. "1.17.0")
  • :via — installation mechanism; only :mise is currently supported

Shape and version-charset validation lives in Runtime.new/1, the single gate every entry passes through before it can reach rendering.

The runtimes list lives inside the env spec and is therefore covered by the spec digest — different runtimes produce a different image name automatically.

Summary

Functions

Renders the mise bootstrap install script for the given runtime entries.

Returns the hosts required for the given runtimes, deduplicated and sorted.

Renders the system-prompt instruction block for the given runtime entries.

Validates a runtimes list. Non-list input is rejected with the same error shape as an invalid entry.

Functions

bootstrap_script(runtimes)

@spec bootstrap_script([map() | ReqManagedAgents.Provisioner.Runtime.t()]) :: binary()

Renders the mise bootstrap install script for the given runtime entries.

Ordering rules:

  • Erlang is placed before elixir when both are present.
  • Elixir version becomes elixir@<version>-otp-<erlang_major> when an erlang entry exists; plain elixir@<version> otherwise.
  • Other languages render as <lang>@<version> verbatim.
  • Languages beyond erlang/elixir retain their input order after the pair.

Output is deterministic: the same input always produces an identical binary.

required_hosts(runtimes)

@spec required_hosts([map() | ReqManagedAgents.Provisioner.Runtime.t()]) :: [binary()]

Returns the hosts required for the given runtimes, deduplicated and sorted.

Reads priv/runtime_bootstrap/allowed_hosts.json at runtime. Returns [] for an empty runtimes list.

system_prompt_block(runtimes)

@spec system_prompt_block([map() | ReqManagedAgents.Provisioner.Runtime.t()]) ::
  binary()

Renders the system-prompt instruction block for the given runtime entries.

The block states which runtimes the session declares, instructs the agent to run the bootstrap script EXACTLY ONCE via bash before the first command that needs the runtimes (the script is idempotent), and embeds the full bootstrap_script/1 output in a fenced code block.

Output is deterministic: the same input always produces an identical binary.

validate(runtimes)

@spec validate(term()) :: :ok | {:error, {:invalid_runtime, term()}}

Validates a runtimes list. Non-list input is rejected with the same error shape as an invalid entry.

Returns :ok or {:error, {:invalid_runtime, entry}}.