H.EnvRegistry (H v0.3.0)

Copy Markdown View Source

Stateless resolver turning environment configurations into live H.ExecutionEnv.t() handles and plain JSON-safe environment descriptors.

Summary

Functions

Fetches the base H.ExecutionEnv.t() at its default_cwd and its descriptor.

Lists configured environment descriptors, always including "host".

Resolves {env_id, raw_cwd} against the environment registry and binds cwd through H.ExecutionEnv.bind_cwd/2.

Types

descriptor()

@type descriptor() :: %{
  id: String.t(),
  kind: String.t(),
  label: String.t(),
  default_cwd: String.t()
}

Functions

fetch_env(env_id, opts \\ [])

@spec fetch_env(term(), keyword()) ::
  {:ok, H.ExecutionEnv.t(), descriptor()}
  | {:error, :unknown_environment | :workspace_unavailable}

Fetches the base H.ExecutionEnv.t() at its default_cwd and its descriptor.

list_environments(opts \\ [])

@spec list_environments(keyword()) :: [descriptor()]

Lists configured environment descriptors, always including "host".

resolve_workspace(env_id, raw_cwd_or_nil, opts \\ [])

@spec resolve_workspace(nil | String.t(), nil | String.t(), keyword()) ::
  {:ok,
   %{
     env_id: String.t(),
     kind: String.t(),
     cwd: String.t(),
     env: H.ExecutionEnv.t()
   }}
  | {:error, term()}

Resolves {env_id, raw_cwd} against the environment registry and binds cwd through H.ExecutionEnv.bind_cwd/2.