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.

The AgentNetwork wires everything together. You declare channels, register agents with their subscriptions and publish targets, and the network manages the event plane at runtime.

Setting Up a Network

import { AgentNetwork } from '@m4trix/core/matrix';

const network = AgentNetwork.setup(
  ({ mainChannel, createChannel, sink, registerAgent }) => {
    const main = mainChannel('main');
    const client = createChannel('client').sink(sink.httpStream());

    registerAgent(myAgent).subscribe(main).publishTo(client);
  },
);

Setup Context

ToolDescription
mainChannel(name)Designates the main channel where start events are published
createChannel(name)Creates additional named channels
sinkProvides sink factories (e.g. httpStream(), kafka())
registerAgent(agent)Registers an agent and returns a binding builder
spawnerCreates a spawner for dynamic agent creation (multi-tenant)

Multi-Agent Patterns

Agent Chain

Events flow through a series of agents:
registerAgent(plannerAgent).subscribe(main).publishTo(processing);
registerAgent(executorAgent).subscribe(processing).publishTo(client);

Fan-Out

One event triggers multiple agents in parallel:
registerAgent(agentA).subscribe(main).publishTo(client);
registerAgent(agentB).subscribe(main).publishTo(client);
registerAgent(agentC).subscribe(main).publishTo(client);

Multi-Channel Routing

Different agents on different channels:
registerAgent(routerAgent).subscribe(main).publishTo(internal);
registerAgent(workerAgent).subscribe(internal).publishTo(client);
registerAgent(loggerAgent).subscribe(main).subscribe(internal);
See AgentNetwork API and Patterns guide for more.