bus

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentRole

type AgentRole string
const (
	RolePM         AgentRole = "pm"
	RoleCoder      AgentRole = "coder"
	RoleQA         AgentRole = "qa"
	RoleUXReviewer AgentRole = "ux_reviewer"
	RoleSecurity   AgentRole = "security"
	RoleSystem     AgentRole = "system"
)

type AgentUsage

type AgentUsage struct {
	InputTokens  int  `json:"input_tokens"`
	OutputTokens int  `json:"output_tokens"`
	Estimated    bool `json:"estimated"` // true = heuristic count
}

AgentUsage is the payload for MsgUsage events. It carries token counts for one agent's LLM completion(s). Runner and Model are not stored here — the TUI derives them from agentConfigs.

type Bus

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

func New

func New() *Bus

func (*Bus) Close

func (b *Bus) Close()

Close closes the log file if open.

func (*Bus) Publish

func (b *Bus) Publish(m Message)

Publish adds msg to the ring buffer, fans out to subscribers, and optionally persists.

func (*Bus) Recent

func (b *Bus) Recent(n int) []Message

Recent returns the last n messages from the ring (oldest first).

func (*Bus) ServeUnix

func (b *Bus) ServeUnix(path string, stop <-chan struct{}) error

ServeUnix starts a Unix domain socket server at path. Each connecting client may:

  • publish messages to this bus (sends JSON-encoded Message objects)
  • receive all bus messages (the server fans out to every connection)

The server runs until the provided stop channel is closed or ctx is cancelled. Call os.Remove(path) after to clean up.

func (*Bus) SetLogPath

func (b *Bus) SetLogPath(dir, filename string) error

SetLogPath opens a file scoped to dir for append-writing each published message as JSON.

func (*Bus) Subscribe

func (b *Bus) Subscribe() <-chan Message

Subscribe returns a buffered channel that receives all future messages.

func (*Bus) Unsubscribe

func (b *Bus) Unsubscribe(ch <-chan Message)

Unsubscribe removes a channel returned by Subscribe so it no longer receives messages. The channel is not closed: Publish fans out from a snapshot taken outside the lock, and sending on a closed channel would panic.

type BusClient

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

BusClient is a client connected to a remote bus via Unix socket.

func DialUnix

func DialUnix(path string) (*BusClient, error)

DialUnix connects to a bus server at the given Unix socket path.

func (*BusClient) Close

func (c *BusClient) Close() error

Close closes the connection.

func (*BusClient) Publish

func (c *BusClient) Publish(m Message) error

Publish sends a message to the remote bus.

func (*BusClient) Subscribe

func (c *BusClient) Subscribe() <-chan Message

Subscribe returns a channel that receives messages from the remote bus.

type ConversationPayload

type ConversationPayload struct {
	From    string `json:"from"` // "pm" or "human"
	Content string `json:"content"`
}

ConversationPayload carries a single turn of PM↔human dialog.

type Message

type Message struct {
	ID        string      `json:"id"`
	From      AgentRole   `json:"from"`
	To        AgentRole   `json:"to"`
	Type      MessageType `json:"type"`
	Payload   any         `json:"payload"`
	Timestamp time.Time   `json:"timestamp"`
}

func NewMessage

func NewMessage(from, to AgentRole, typ MessageType, payload any) Message

type MessageType

type MessageType string
const (
	MsgRequest      MessageType = "request"
	MsgResponse     MessageType = "response"
	MsgEvent        MessageType = "event"
	MsgHumanGate    MessageType = "human_gate"
	MsgUsage        MessageType = "usage"
	MsgConversation MessageType = "conversation" // PM↔human dialog turn
	MsgTaskSpec     MessageType = "task_spec"    // PM emits formalized task
)

type TokenPayload

type TokenPayload struct {
	Text string `json:"text"`
	Done bool   `json:"done"`
}

TokenPayload is the payload for streaming token events.

Jump to

Keyboard shortcuts

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