# `Codex.RunResultStreaming`
[🔗](https://github.com/nshkrdotcom/codex_sdk/blob/v0.18.1/lib/codex/run_result_streaming.ex#L1)

Streaming result wrapper exposing semantic and raw event streams plus
cancellation controls.

# `t`

```elixir
@type t() :: %Codex.RunResultStreaming{
  control: pid(),
  queue: pid(),
  start_fun: (-&gt; any())
}
```

# `cancel`

```elixir
@spec cancel(t(), :immediate | :after_turn) :: :ok
```

Cancels the streaming run.

Modes:
  * `:immediate` - stop immediately
  * `:after_turn` - finish the current turn then halt

# `events`

```elixir
@spec events(t()) :: Enumerable.t()
```

Returns a stream of semantic events. Automatically starts the underlying
streaming process on first invocation.

# `pop`

```elixir
@spec pop(t(), timeout()) :: {:ok, term()} | {:error, term()} | :done
```

Pops the next semantic event from the queue, blocking up to `timeout`.

Returns `{:error, reason}` if the stream terminates with an error.

# `raw_events`

```elixir
@spec raw_events(t()) :: Enumerable.t()
```

Returns a stream of the raw Codex events.

# `usage`

```elixir
@spec usage(t()) :: map()
```

Returns the aggregated usage captured so far.

---

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