Skip to main content

Class: AgentCommunicationBus

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:93

Implementation of the Agent Communication Bus.

Features:

  • Point-to-point messaging between agents
  • Broadcast to agencies
  • Request-response pattern
  • Topic-based pub/sub
  • Task handoff protocol
  • Message persistence and history
  • Delivery tracking and retries

Implements

Implements

Constructors

Constructor

new AgentCommunicationBus(config?): AgentCommunicationBus

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:138

Creates a new AgentCommunicationBus instance.

Parameters

config?

AgentCommunicationBusConfig = {}

Bus configuration

Returns

AgentCommunicationBus

Methods

acknowledgeMessage()

acknowledgeMessage(messageId, agentId): Promise<void>

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:519

Acknowledges receipt of a message.

Parameters

messageId

string

agentId

string

Returns

Promise<void>

Implementation of

IAgentCommunicationBus.acknowledgeMessage


broadcast()

broadcast(agencyId, message): Promise<DeliveryStatus[]>

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:215

Broadcasts a message to all agents in an agency.

Parameters

agencyId

string

message

Omit<AgentMessage, "messageId" | "toAgentId" | "sentAt">

Returns

Promise<DeliveryStatus[]>

Implementation of

IAgentCommunicationBus.broadcast


broadcastToRoles()

broadcastToRoles(agencyId, roleIds, message): Promise<DeliveryStatus[]>

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:240

Broadcasts to specific roles within an agency.

Parameters

agencyId

string

roleIds

string[]

message

Omit<AgentMessage, "messageId" | "sentAt">

Returns

Promise<DeliveryStatus[]>

Implementation of

IAgentCommunicationBus.broadcastToRoles


createTopic()

createTopic(topic): Promise<MessageTopic>

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:427

Creates a message topic.

Parameters

topic

Omit<MessageTopic, "topicId">

Returns

Promise<MessageTopic>

Implementation of

IAgentCommunicationBus.createTopic


getDeliveryStatus()

getDeliveryStatus(messageId): Promise<DeliveryStatus | null>

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:512

Gets the delivery status of a message.

Parameters

messageId

string

Returns

Promise<DeliveryStatus | null>

Implementation of

IAgentCommunicationBus.getDeliveryStatus


getMessageHistory()

getMessageHistory(agentId, options?): Promise<AgentMessage[]>

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:572

Gets message history for an agent.

Parameters

agentId

string

options?
direction?

"both" | "sent" | "received"

limit?

number

since?

Date

types?

AgentMessageType[]

Returns

Promise<AgentMessage[]>

Implementation of

IAgentCommunicationBus.getMessageHistory


getStatistics()

getStatistics(): BusStatistics

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:565

Gets message bus statistics.

Returns

BusStatistics

Implementation of

IAgentCommunicationBus.getStatistics


handoff()

handoff(fromAgentId, toAgentId, context): Promise<HandoffResult>

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:324

Initiates a structured handoff between agents.

Parameters

fromAgentId

string

toAgentId

string

context

HandoffContext

Returns

Promise<HandoffResult>

Implementation of

IAgentCommunicationBus.handoff


publishToTopic()

publishToTopic(topicId, message): Promise<DeliveryStatus[]>

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:443

Publishes a message to a topic.

Parameters

topicId

string

message

Omit<AgentMessage, "messageId" | "sentAt">

Returns

Promise<DeliveryStatus[]>

Implementation of

IAgentCommunicationBus.publishToTopic


registerAgent()

registerAgent(agentId, agencyId, roleId): void

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:612

Registers an agent with an agency for routing.

Parameters

agentId

string

agencyId

string

roleId

string

Returns

void


requestResponse()

requestResponse(targetAgentId, request): Promise<AgentResponse>

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:276

Sends a request and waits for a response.

Parameters

targetAgentId

string

request

AgentRequest

Returns

Promise<AgentResponse>

Implementation of

IAgentCommunicationBus.requestResponse


retryDelivery()

retryDelivery(messageId): Promise<DeliveryStatus>

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:536

Retries delivery of a failed message.

Parameters

messageId

string

Returns

Promise<DeliveryStatus>

Implementation of

IAgentCommunicationBus.retryDelivery


sendToAgent()

sendToAgent(targetAgentId, message): Promise<DeliveryStatus>

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:160

Sends a message to a specific agent.

Parameters

targetAgentId

string

message

Omit<AgentMessage, "messageId" | "toAgentId" | "sentAt">

Returns

Promise<DeliveryStatus>

Implementation of

IAgentCommunicationBus.sendToAgent


sendToRole()

sendToRole(agencyId, targetRoleId, message): Promise<DeliveryStatus>

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:178

Sends a message to an agent by role.

Parameters

agencyId

string

targetRoleId

string

message

Omit<AgentMessage, "messageId" | "toRoleId" | "sentAt">

Returns

Promise<DeliveryStatus>

Implementation of

IAgentCommunicationBus.sendToRole


subscribe()

subscribe(agentId, handler, options?): Unsubscribe

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:377

Subscribes an agent to receive messages.

Parameters

agentId

string

handler

MessageHandler

options?

SubscriptionOptions = {}

Returns

Unsubscribe

Implementation of

IAgentCommunicationBus.subscribe


subscribeToTopic()

subscribeToTopic(agentId, topicId, handler): Unsubscribe

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:484

Subscribes an agent to a topic.

Parameters

agentId

string

topicId

string

handler

MessageHandler

Returns

Unsubscribe

Implementation of

IAgentCommunicationBus.subscribeToTopic


unregisterAgent()

unregisterAgent(agentId): void

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:633

Unregisters an agent from routing.

Parameters

agentId

string

Returns

void


unsubscribeAll()

unsubscribeAll(agentId): void

Defined in: packages/agentos/src/core/agency/AgentCommunicationBus.ts:411

Unsubscribes an agent from all messages.

Parameters

agentId

string

Returns

void

Implementation of

IAgentCommunicationBus.unsubscribeAll