Networks (Wiring)

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

Tool
Description

mainChannel(name)

Designates the main channel where start events are published

createChannel(name)

Creates additional named channels

sink

Provides sink factories (e.g. httpStream(), kafka())

registerAgent(agent)

Registers an agent and returns a binding builder

spawner

Creates a spawner for dynamic agent creation (multi-tenant)

Multi-Agent Patterns

Agent Chain

Events flow through a series of agents:

Fan-Out

One event triggers multiple agents in parallel:

Multi-Channel Routing

Different agents on different channels:

See AgentNetwork API and Patterns guide for more.

Last updated