Typed inter-agent event bus. All messages carry Session + Identity. Supports targeted (tell), broadcast, and collaboration patterns.

Functions

broadcast

fn (msg: BroadcastMessage): Map

Broadcast a message to all listening agents.

Example

::bus ::ai::bus
session ::ai::session/Session({id: "slack:C123"})
sender ::ai::session/Identity({id: "u1", name: "Ada"})
::bus/broadcast(::bus/BroadcastMessage({
    session: session,
    sender: sender,
    from-agent: "triage",
    topic: "incident",
    data: {severity: "high"}
}))

collaborate

fn (req: CollaborationRequest): Map

Send a collaboration request. Responses arrive at req.reply-event.

Example

::bus ::ai::bus
session ::ai::session/Session({id: "slack:C123"})
sender ::ai::session/Identity({id: "u1", name: "Ada"})
::bus/collaborate(::bus/CollaborationRequest({
    session: session,
    sender: sender,
    from-agent: "triage",
    question: "Has order 42 shipped?",
    reply-event: "agent:triage:answers",
    correlation-id: "c-1"
}))

respond

fn (req: CollaborationRequest, answer: Str): Map

Respond to a collaboration request.

Example

::bus ::ai::bus
session ::ai::session/Session({id: "slack:C123"})
sender ::ai::session/Identity({id: "u1", name: "Ada"})
req ::bus/CollaborationRequest({
    session: session,
    sender: sender,
    from-agent: "triage",
    question: "Has order 42 shipped?",
    reply-event: "agent:triage:answers",
    correlation-id: "c-1"
})

// Sends the answer to req.reply-event with the same correlation-id
::bus/respond(req, "Yes, it shipped on Monday.")

tell

fn (msg: ::ai::message/AgentMessage): Map

Send a targeted message to a specific agent's inbox.

Example

::bus ::ai::bus
session ::ai::session/Session({id: "slack:C123"})
sender ::ai::session/Identity({id: "u1", name: "Ada"})
::bus/tell(::ai::message/AgentMessage({
    session: session,
    sender: sender,
    from-agent: "triage",
    to-agent: "billing",
    content: "Refund request for order 42."
}))

Types

BroadcastMessage

BroadcastMessage type {
    session: ::ai::session/Session,
    sender: ::ai::session/Identity,
    from-agent: Str,
    topic: Str,
    data: Map
}

A message sent to all agents via fan-out.

CollaborationRequest

CollaborationRequest type {
    session: ::ai::session/Session,
    sender: ::ai::session/Identity,
    from-agent: Str,
    question: Str,
    reply-event: Str,
    correlation-id: Str,
    context: Map?
}

A request for help from one agent to others, with reply-event and correlation-id for async responses.