TheDocumentation Index
Fetch the complete documentation index at: https://docs.m4trix.dev/llms.txt
Use this file to discover all available pages before exploring further.
AgentFactory is a fluent builder for creating type-safe agents. It provides full TypeScript inference from trigger events through to emitted events.
Entry Point
Builder Methods
.params(schema)
Defines the parameter schema for the agent. Parameters are static configuration passed when producing the agent.
.listensTo(events)
Declares which event types trigger this agent. Accepts an array of AgentNetworkEventDef. Can be called multiple times — events accumulate.
.emits(events)
Declares which event types this agent can emit. Also accumulates across multiple calls.
.logic(fn)
The core handler. Receives:
params— Resolved parameters from.produce()triggerEvent— Full envelope{ name, meta, payload }that triggered the agentemit(event)— Function to emit events, typed to declared.emits()events
.produce(params)
Finalizes the builder and returns an Agent instance. The params argument must match the schema from .params().
Type Safety
triggerEventis a union of alllistensToevent envelopesemit()only accepts payloads matching declaredemitseventsparamsmatches the schema from.params()