AgentNetworkEvent

AgentNetworkEvent defines typed events with schema validation via Effect Schemaarrow-up-right.

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.

.is(value)

Type guard that checks whether an unknown value matches this event's shape.

Event Envelope

Every event has:

See Also

Last updated