CliSubprocessCore.Event (CliSubprocessCore v0.1.0)

Copy Markdown View Source

Normalized runtime event envelope emitted by the core session layer.

Summary

Functions

Returns the supported normalized event kinds in stable order.

Builds a normalized runtime event.

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

Parses an event envelope and raises on invalid data.

Returns the payload module associated with a normalized kind.

Returns the shared event schema for the normalized envelope.

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

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

Types

kind()

@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()

t()

@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()
}

Functions

kinds()

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

Returns the supported normalized event kinds in stable order.

new(kind, attrs \\ [])

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

Builds a normalized runtime event.

parse(event)

@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!(event)

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

Parses an event envelope and raises on invalid data.

payload_module(kind)

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

Returns the payload module associated with a normalized kind.

schema()

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

Returns the shared event schema for the normalized envelope.

to_map(event)

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

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

valid_kind?(kind)

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

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