Agents (Logic + Lifecycle)
Basic Usage
import { AgentFactory, AgentNetworkEvent, S } from '@m4trix/core/matrix';
const inputEvent = AgentNetworkEvent.of('user-input', S.Struct({ text: S.String }));
const outputEvent = AgentNetworkEvent.of('agent-output', S.Struct({ reply: S.String }));
const echoAgent = AgentFactory.run()
.listensTo([inputEvent])
.emits([outputEvent])
.logic(async ({ triggerEvent, emit }) => {
emit({
name: 'agent-output',
payload: { reply: `Echo: ${triggerEvent.payload.text}` },
});
})
.produce({});Lifecycle
Type Safety
Catch-All Agents
Last updated