Skip to content

API Reference parrot.integrations.matrix.crew.transport

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.integrations.matrix.crew.transport

View source

Matrix crew transport orchestrator.

Top-level lifecycle manager for a Matrix multi-agent crew. Manages the MatrixAppService, coordinator, registry, and per-agent wrappers. Supports the async context-manager protocol for clean lifecycle management.

Alias AgentSwarmToolkit

Re-exported from parrot.integrations.matrix.crew.swarm_toolkit.AgentSwarmToolkit.

Alias ChannelManager

Re-exported from parrot.integrations.matrix.crew.channels.ChannelManager.

Alias MatrixAgentCard

Re-exported from parrot.integrations.matrix.crew.registry.MatrixAgentCard.

Alias MatrixCollaborativeSession

Re-exported from parrot.integrations.matrix.crew.session.MatrixCollaborativeSession.

Alias MatrixCoordinator

Re-exported from parrot.integrations.matrix.crew.coordinator.MatrixCoordinator.

Alias MatrixCrewAgentWrapper

Re-exported from parrot.integrations.matrix.crew.crew_wrapper.MatrixCrewAgentWrapper.

Alias MatrixCrewConfig

Re-exported from parrot.integrations.matrix.crew.config.MatrixCrewConfig.

Alias MatrixCrewRegistry

Re-exported from parrot.integrations.matrix.crew.registry.MatrixCrewRegistry.

Class MatrixCrewTransport

Top-level orchestrator for a Matrix multi-agent crew.

Manages the MatrixAppService, coordinator, registry, and per-agent wrappers. Supports async with for lifecycle management.

Usage::

transport = MatrixCrewTransport.from_yaml("matrix_crew.yaml")
async with transport:
    # Crew is running — blocks until context exits
    ...
Parameter Type Default Description
config MatrixCrewConfig Validated MatrixCrewConfig instance.
roost_endpoint_factory Optional[RoostEndpointFactory] None Optional :data:RoostEndpointFactory. When given, every agent that gets an AgentSwarmToolkit also gets a started RoostEndpoint and its ask_agent runs over Roost; the endpoints are stopped by :meth:stop. Without it ask_agent keeps using the tunnels.

Method MatrixCrewTransport.from_yaml

Load crew configuration from a YAML file.

from_yaml(path: str, *, roost_endpoint_factory: Optional[RoostEndpointFactory] = None) -> 'MatrixCrewTransport'

Parameter Type Default Description
path str Path to the YAML configuration file.
roost_endpoint_factory Optional[RoostEndpointFactory] None Optional :data:RoostEndpointFactory (see the class docstring).

Returns: 'MatrixCrewTransport' — A new MatrixCrewTransport instance.

Method MatrixCrewTransport.start

Initialize and start all crew components.

Sequence:

  1. Create MatrixAppService from config.
  2. Register virtual users (one per agent).
  3. Build room-to-agent map.
  4. Create MatrixCrewAgentWrapper for each agent.
  5. Register agents in the registry (MatrixAgentCard).
  6. Join agents to general_room_id + dedicated rooms.
  7. Create and start the coordinator (pins status board).
  8. Register event callback on the AppService.
  9. Start the AppService HTTP listener.

start() -> None

Method MatrixCrewTransport.stop

Graceful shutdown: stop coordinator, unregister agents, stop AS.

stop() -> None

Method MatrixCrewTransport.on_room_message

Route an incoming Matrix room message to the correct agent wrapper.

Routing priority:

  1. Agent self-filter (virtual agent MXIDs + coordinator):
    • If an active collaborative/swarm session exists (resolved via the origin_session swarm context, falling back to any active session in the room) AND the agent message contains an @mention → route through the session (inter-agent bypass).
    • Otherwise → drop silently.
  2. !channels / !agents / !tunnels (human) → coordinator listing.
  3. !investigate <question> command (human) → start a session (any room).
  4. Dedicated room → route to the owning agent.
  5. @mention in body → route to the mentioned agent.
  6. unaddressed_agent configured → route to the default agent.
  7. NEW: channel answer_policy == "swarm" + human sender → start a swarm session.
  8. Otherwise → ignore.

on_room_message(room_id: str, sender: str, body: str, event_id) -> None

Parameter Type Default Description
room_id str Matrix room ID.
sender str Sender's full MXID.
body str Plain-text message body.
event_id Matrix event ID.

Alias RoostEndpoint

Re-exported from parrot.roost.endpoint.RoostEndpoint.

Attribute RoostEndpointFactory

Alias SwarmSessionManager

Re-exported from parrot.integrations.matrix.crew.swarm.SwarmSessionManager.

Alias TunnelRegistry

Re-exported from parrot.integrations.matrix.crew.tunnel.TunnelRegistry.

Alias WakeCallback

Re-exported from parrot.roost.endpoint.WakeCallback.

Alias ctx

Re-exported from parrot.integrations.matrix.crew.context.

Alias parse_mention

Re-exported from parrot.integrations.matrix.crew.mention.parse_mention.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally