# `Mojentic.Event`
[🔗](https://github.com/svetzal/mojentic-ex/blob/v1.5.0/lib/mojentic/event.ex#L1)

Base event structure for agent communication.

Events are the primary mechanism for communication between agents in the
Mojentic agent system. Each event carries information about its source,
a correlation ID for tracking related events, and any domain-specific data.

## Fields

- `source` - The module of the agent that created this event
- `correlation_id` - UUID for tracking related events in a workflow
- Additional fields defined by specific event types

## Examples

    defmodule MyApp.Events.QuestionEvent do
      use Mojentic.Event

      @type t :: %__MODULE__{
        source: module(),
        correlation_id: String.t() | nil,
        question: String.t()
      }

      defstruct [:source, :correlation_id, :question]
    end

    event = %MyApp.Events.QuestionEvent{
      source: MyApp.QuestionAgent,
      correlation_id: UUID.uuid4(),
      question: "What is Elixir?"
    }

# `t`

```elixir
@type t() :: %{
  __struct__: module(),
  source: module(),
  correlation_id: String.t() | nil
}
```

# `__using__`
*macro* 

Defines a module as an event type with required base fields.

When you `use Mojentic.Event`, your module gets:
- Base fields: `source` and `correlation_id`
- These fields must be included in your struct definition

## Example

    defmodule MyEvent do
      use Mojentic.Event

      defstruct [:source, :correlation_id, :custom_field]
    end

# `new`

Creates a new event with an auto-generated correlation ID if not provided.

## Parameters

- `module` - The event module to create
- `attrs` - Keyword list or map of attributes

## Examples

    Mojentic.Event.new(QuestionEvent, source: MyAgent, question: "Hello?")
    #=> %QuestionEvent{source: MyAgent, correlation_id: "...", question: "Hello?"}

---

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