bus

package
v0.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package bus decouples channels from the agent loop with bounded queues.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func External added in v0.11.0

func External(channel string) bool

External reports whether a channel is a conversation that outlives this process, and so is somewhere Factor can reach the user on its own initiative. The CLI is one process's stdin, system is Factor talking to itself, and cron is a schedule rather than an inbox: none of them is an address a heartbeat, a job result or a restart notice can be sent to.

Types

type InboundMessage

type InboundMessage struct {
	Channel  string
	SenderID string
	ChatID   string
	Content  string
	Time     time.Time

	// Speaker names the person who said this, when the channel can tell one
	// person from another — the PC microphone identifying a household voice.
	// It is blank everywhere else, which is every channel whose chat already
	// is one person. It travels beside the content rather than inside it so
	// the prompt and the memory graph can each attribute it their own way.
	Speaker string

	// Audience says who can hear the reply, where the channel knows that
	// somebody besides the user is present — the microphone hearing a second
	// voice in the room. Blank is the ordinary case: the conversation is
	// private to whoever this chat is. Unlike Speaker it is not about
	// attribution but about discretion, which is why the two are separate
	// fields: the owner asking something private with a guest listening is
	// their own turn on every axis except the one that matters.
	Audience string
}

func (InboundMessage) SessionKey

func (m InboundMessage) SessionKey() string

SessionKey identifies the conversation a message belongs to.

type MessageBus

type MessageBus struct {
	// contains filtered or unexported fields
}

func New

func New() *MessageBus

func (*MessageBus) Inbound

func (b *MessageBus) Inbound() <-chan InboundMessage

func (*MessageBus) Outbound

func (b *MessageBus) Outbound() <-chan OutboundMessage

func (*MessageBus) PendingOutbound added in v0.7.0

func (b *MessageBus) PendingOutbound() int

PendingOutbound counts replies waiting for a connector to deliver them. The gateway waits for zero before restarting: a queued message dies with the process that holds it.

func (*MessageBus) PublishInbound

func (b *MessageBus) PublishInbound(msg InboundMessage) bool

PublishInbound enqueues without blocking; a full queue drops the message loudly rather than wedging a connector.

func (*MessageBus) PublishOutbound

func (b *MessageBus) PublishOutbound(msg OutboundMessage) bool

type OutboundMessage

type OutboundMessage struct {
	Channel string
	ChatID  string
	Content string
	// Interim marks a note sent while a turn is still running — what the
	// agent is about to do, not its answer. Connectors whose delivery is
	// expensive or interruptive (a phone call) drop these.
	Interim bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL