Agentix.Event (Agentix v0.1.0)

Copy Markdown View Source

A single entry in the canonical, append-only conversation log.

The log is the source of truth; everything else is derived from it. seq, conversation_id, and inserted_at are assigned by the persistence layer on append — an in-memory event built with new/2 carries them as nil until then.

The six types form a closed union: :user_msg, :assistant_msg, :tool_call, :tool_result, :suspension, :resolution.

Summary

Functions

Builds an event of type carrying content (a map).

All valid event types, in canonical order.

Returns true if value is a valid event type.

Types

t()

@type t() :: %Agentix.Event{
  content: map(),
  conversation_id: String.t() | nil,
  inserted_at: DateTime.t() | nil,
  seq: non_neg_integer() | nil,
  type: type()
}

type()

@type type() ::
  :user_msg
  | :assistant_msg
  | :tool_call
  | :tool_result
  | :suspension
  | :resolution

Functions

new(type, content, opts \\ [])

@spec new(type(), map(), keyword()) :: t()

Builds an event of type carrying content (a map).

Optional :seq (non-negative integer), :conversation_id (string), and :inserted_at (DateTime) may be supplied; the persistence layer normally assigns them. Raises ArgumentError if type is not one of types/0, if content is not a map, or if an opt has the wrong type.

types()

@spec types() :: [type()]

All valid event types, in canonical order.

valid_type?(value)

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

Returns true if value is a valid event type.