# `CliSubprocessCore.Event`
[🔗](https://github.com/nshkrdotcom/cli_subprocess_core/blob/v0.1.0/lib/cli_subprocess_core/event.ex#L1)

Normalized runtime event envelope emitted by the core session layer.

# `kind`

```elixir
@type kind() ::
  :run_started
  | :assistant_delta
  | :assistant_message
  | :user_message
  | :thinking
  | :tool_use
  | :tool_result
  | :approval_requested
  | :approval_resolved
  | :cost_update
  | :result
  | :error
  | :stderr
  | :raw
```

# `payload`

```elixir
@type payload() ::
  CliSubprocessCore.Payload.RunStarted.t()
  | CliSubprocessCore.Payload.AssistantDelta.t()
  | CliSubprocessCore.Payload.AssistantMessage.t()
  | CliSubprocessCore.Payload.UserMessage.t()
  | CliSubprocessCore.Payload.Thinking.t()
  | CliSubprocessCore.Payload.ToolUse.t()
  | CliSubprocessCore.Payload.ToolResult.t()
  | CliSubprocessCore.Payload.ApprovalRequested.t()
  | CliSubprocessCore.Payload.ApprovalResolved.t()
  | CliSubprocessCore.Payload.CostUpdate.t()
  | CliSubprocessCore.Payload.Result.t()
  | CliSubprocessCore.Payload.Error.t()
  | CliSubprocessCore.Payload.Stderr.t()
  | CliSubprocessCore.Payload.Raw.t()
```

# `t`

```elixir
@type t() :: %CliSubprocessCore.Event{
  extra: map(),
  id: pos_integer(),
  kind: kind(),
  metadata: map(),
  payload: payload(),
  provider: atom() | nil,
  provider_session_id: String.t() | nil,
  raw: term(),
  sequence: non_neg_integer() | nil,
  timestamp: DateTime.t()
}
```

# `kinds`

```elixir
@spec kinds() :: [kind(), ...]
```

Returns the supported normalized event kinds in stable order.

# `new`

```elixir
@spec new(kind(), keyword() | map()) :: t()
```

Builds a normalized runtime event.

# `parse`

```elixir
@spec parse(keyword() | map() | t()) ::
  {:ok, t()}
  | {:error, {:invalid_event, CliSubprocessCore.Schema.error_detail()}}
  | {:error,
     {:invalid_event_payload, kind(), CliSubprocessCore.Schema.error_detail()}}
```

Parses an event envelope through the canonical schema and projects it to the ergonomic struct.

# `parse!`

```elixir
@spec parse!(keyword() | map() | t()) :: t()
```

Parses an event envelope and raises on invalid data.

# `payload_module`

```elixir
@spec payload_module(kind()) :: module()
```

Returns the payload module associated with a normalized kind.

# `schema`

```elixir
@spec schema() :: Zoi.schema()
```

Returns the shared event schema for the normalized envelope.

# `to_map`

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

Projects the event back into its normalized map shape, preserving unknown keys.

# `valid_kind?`

```elixir
@spec valid_kind?(term()) :: boolean()
```

Returns `true` when the kind is part of the normalized vocabulary.

---

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