LemonCore.Events.EngineAction (lemon_core v0.1.0)

View Source

An engine action started, progressed or finished. Published on run:<run_id> and forwarded to session:<session_key>; it is what drives tool-status surfaces in chat channels and the web UI.

Summary

Functions

The LemonCore.Event type atom this payload is published under.

Payload version. Bumped only for a breaking field change (see the semver table in docs/platform/bus-events.md §4.3).

The struct's field names, in declaration order.

Build from a legacy map, coercing the nested action and normalising phase.

Build the payload, raising on unknown or missing keys.

The accepted action phases.

Types

phase()

@type phase() :: :started | :updated | :completed

t()

@type t() :: %LemonCore.Events.EngineAction{
  action: LemonCore.Events.Action.t(),
  engine: String.t() | nil,
  level: atom() | nil,
  message: String.t() | nil,
  ok: boolean() | nil,
  phase: phase()
}

Functions

event_type()

@spec event_type() :: atom()

The LemonCore.Event type atom this payload is published under.

event_version()

@spec event_version() :: pos_integer()

Payload version. Bumped only for a breaking field change (see the semver table in docs/platform/bus-events.md §4.3).

fields()

@spec fields() :: [atom()]

The struct's field names, in declaration order.

from_map(payload)

@spec from_map(map() | struct() | keyword()) :: struct()
@spec from_map(map() | struct() | keyword()) :: t()

Build from a legacy map, coercing the nested action and normalising phase.

new(payload)

@spec new(map() | keyword()) :: struct()

Build the payload, raising on unknown or missing keys.

This is the publisher-side constructor: a typo should fail at the point of publish, not silently produce a payload with a nil field that a consumer reads as absent.

phases()

@spec phases() :: [phase()]

The accepted action phases.