# `LlmCore.LLM.CLIPort`
[🔗](https://github.com/fosferon/llm_core/blob/v0.3.0/lib/llm_core/llm/cli_port.ex#L1)

Helpers for running CLI-based LLM providers via `Port`.

This is used to support true HALT semantics by allowing the executor
to interrupt in-flight CLI operations (SIGINT/SIGTERM/SIGKILL).

# `exec_result`

```elixir
@type exec_result() ::
  {:ok, iodata(), non_neg_integer()} | {:error, :timeout} | {:error, term()}
```

# `run`

```elixir
@spec run(String.t(), [String.t()], timeout(), String.t() | nil) :: exec_result()
```

Runs a CLI executable with the given args and returns collected output.

Opens a port with `</dev/null` to close stdin, collects all stdout/stderr
data, and returns `{:ok, output, exit_code}` or `{:error, reason}`.

# `spawn`

```elixir
@spec spawn(String.t(), [String.t()], String.t() | nil) ::
  {:ok, port()} | {:error, term()}
```

Spawns a CLI executable as an interactive port without waiting for completion.

Returns `{:ok, port}` for the caller to interact with directly.

# `stream`

```elixir
@spec stream(String.t(), [String.t()], timeout(), String.t() | nil) ::
  {:ok, Enumerable.t()} | {:error, term()}
```

Starts a CLI executable and returns a lazy stream of output lines.

The stream yields line-by-line output. The port is automatically closed
when the stream is consumed or on timeout.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
