Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.m4trix.dev/llms.txt

Use this file to discover all available pages before exploring further.

AgentNetworkEvent defines typed events with schema validation via Effect Schema.

Creating Events

AgentNetworkEvent.of(name, schema)
const myEvent = AgentNetworkEvent.of('my-event', S.Struct({ value: S.Number }));

Methods

.make(payload)

Creates an unbound event (name + payload) for use with emit. Meta is injected by the runtime when emitted.
emit(myEvent.make({ value: 42 }));

.makeBound(meta, payload)

Creates a full envelope for tests or manual triggers. Sync, throws on invalid data.
const envelope = myEvent.makeBound(
  { runId: crypto.randomUUID() },
  { value: 42 },
);

.makeEffect(payload)

Effect version of make. Use in Effect pipelines.

.makeBoundEffect(meta, payload)

Effect version of makeBound.

.decode(unknown)

Decodes an unknown value into a validated event envelope. Useful for parsing incoming requests.
const result = Effect.runSync(myEvent.decode(rawData));

.is(value)

Type guard that checks whether an unknown value matches this event’s shape.
if (myEvent.is(someValue)) {
  console.log(someValue.payload.value);
}

Event Envelope

Every event has:
{
  name: string;           // Event name
  meta: {
    runId: string;
    contextId?: string;
    correlationId?: string;
    causationId?: string;
    ts?: number;
  };
  payload: T;            // Validated against schema
}

See Also