events

package
v0.0.36 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package events defines the shared rocketclaw event bus.

Index

Constants

View Source
const (
	// InboundOriginMetadataKey overrides the trusted prompt provenance origin.
	InboundOriginMetadataKey = "rocketclaw_origin"
	// InboundMediaMetadataKey overrides the trusted prompt provenance media.
	InboundMediaMetadataKey = "rocketclaw_media"
	// InboundPrincipalMetadataKey identifies the trusted human principal for prompt provenance.
	InboundPrincipalMetadataKey = "rocketclaw_principal"
	// InboundAllowedAgentsMetadataKey lists source-surface allowed agents for model-created child conversations.
	InboundAllowedAgentsMetadataKey = "rocketclaw_allowed_agents"
	// InboundStartNewThreadDisabledMetadataKey suppresses model-created child conversation tooling for this turn.
	InboundStartNewThreadDisabledMetadataKey = "rocketclaw_start_new_thread_disabled"
)
View Source
const MaxInboundTextAttachmentBytes = 256 << 10

MaxInboundTextAttachmentBytes is the per-file size limit for attachments converted to prompt text.

Variables

View Source
var ErrBusClosed = errors.New("bus closed")

ErrBusClosed reports that an event was published after the bus shut down.

Functions

func AttachmentNamesSpeech

func AttachmentNamesSpeech(attachments []OutboundAttachment) string

AttachmentNamesSpeech returns a short spoken description of attachment names.

func IsTextAttachment added in v0.0.7

func IsTextAttachment(name, mimeType string) bool

IsTextAttachment reports whether an attachment should be included as literal prompt text.

func SetInboundAllowedAgents added in v0.0.16

func SetInboundAllowedAgents(inbound *InboundMessage, agents []string)

SetInboundAllowedAgents records surface-constrained agents on an inbound message.

func StartNewThreadRootText added in v0.0.16

func StartNewThreadRootText(title, prompt string) string

StartNewThreadRootText returns the human-visible root text for tool-created text conversations.

Types

type AskUserQuestionAnswer added in v0.0.12

type AskUserQuestionAnswer struct {
	Selected []string `json:"selected"`
	Custom   string   `json:"custom"`
	Source   Source   `json:"source"`
}

AskUserQuestionAnswer is returned to RocketCode after a human answers.

type AskUserQuestionOption added in v0.0.12

type AskUserQuestionOption struct{ Label, Value, Description string }

AskUserQuestionOption is one native UI choice for ask_user_question.

type AskUserQuestionRequest added in v0.0.12

type AskUserQuestionRequest struct {
	Source                Source
	ID, Question, Details string
	ConversationID        string
	Options               []AskUserQuestionOption
	Multiple              bool
	SlackReply            *SlackReplyTarget
}

AskUserQuestionRequest asks the originating text connector human for input.

type Bus

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

Bus routes outbound text events between components.

func New

func New() *Bus

New constructs an event bus.

func (*Bus) Close

func (b *Bus) Close()

Close shuts down the bus and wakes all waiting consumers.

func (*Bus) Outbound

func (b *Bus) Outbound(ctx context.Context) iter.Seq[*OutboundMessage]

Outbound returns a single-use iterator over outbound text messages.

func (*Bus) PublishOutbound

func (b *Bus) PublishOutbound(ctx context.Context, msg *OutboundMessage) error

PublishOutbound publishes a text message to all output sinks.

type ExternalMCPRelay added in v0.0.33

type ExternalMCPRelay struct {
	ExternalConversationID, Agent, Text string
	Attachments                         []OutboundAttachment
}

ExternalMCPRelay carries one MCP request to its Slack surface.

type InboundAttachment

type InboundAttachment struct {
	Name, MIMEType string
	Data           []byte
}

InboundAttachment carries an inline attachment into a conversation prompt.

type InboundContent added in v0.0.7

type InboundContent struct {
	Text                   string
	TextAttachments        []string
	Attachments            []InboundAttachment
	HadAttachments         bool
	HadNonImageAttachments bool
	AttachmentWarnings     []string
}

InboundContent carries source-acquired inbound text and attachments before message routing details are applied.

type InboundKind

type InboundKind string

InboundKind describes how an inbound message should be handled.

const (
	// InboundKindPrompt is a normal conversational prompt.
	InboundKindPrompt InboundKind = "prompt"
	// InboundKindInternalize is a note the session should absorb without replying.
	InboundKindInternalize InboundKind = "internalize"
)

type InboundMessage

type InboundMessage struct {
	Source                                                  Source
	Label, Text                                             string
	VerbatimMessage                                         string
	VerbatimAttachments                                     []OutboundAttachment
	Attachments                                             []InboundAttachment
	SlackReply                                              *SlackReplyTarget
	HadAttachments, HadNonImageAttachments, Human, GoalTurn bool
	AttachmentWarnings                                      []string
	Kind                                                    InboundKind
	ConversationID                                          string
	Metadata                                                map[string]string
	// contains filtered or unexported fields
}

InboundMessage is a message headed into its conversation prompt queue.

func NewInboundMessage added in v0.0.33

func NewInboundMessage(source Source, kind InboundKind, label, text string, human bool) *InboundMessage

NewInboundMessage constructs an unrouted inbound message.

func NewInboundMessageFromContent added in v0.0.33

func NewInboundMessageFromContent(source Source, kind InboundKind, label string, content *InboundContent, human bool) *InboundMessage

NewInboundMessageFromContent constructs an unrouted inbound message from normalized source content.

func (*InboundMessage) CompleteResponse

func (m *InboundMessage) CompleteResponse(text string, err error)

CompleteResponse marks this inbound turn result ready.

func (*InboundMessage) CompleteResponseWithAttachments added in v0.0.7

func (m *InboundMessage) CompleteResponseWithAttachments(text string, attachments []OutboundAttachment, err error)

CompleteResponseWithAttachments marks this inbound turn result ready with response attachments.

func (*InboundMessage) EnableResponseWait

func (m *InboundMessage) EnableResponseWait() <-chan InboundResponse

EnableResponseWait returns a channel that receives the final result for this inbound turn.

type InboundResponse

type InboundResponse struct {
	Text        string
	Attachments []OutboundAttachment
	Err         error
}

InboundResponse is the final plain-text result for a queued inbound turn.

type OutboundAttachment

type OutboundAttachment struct {
	Name, MIMEType string
	Data           []byte
}

OutboundAttachment carries a human-visible file attachment to output sinks.

func CloneOutboundAttachments

func CloneOutboundAttachments(attachments []OutboundAttachment) []OutboundAttachment

CloneOutboundAttachments returns a deep copy of attachments.

type OutboundMessage

type OutboundMessage struct {
	Text, ProgressText           string
	Source                       Source
	Targets                      []OutputTarget
	ConversationID, TurnID       string
	ExternalConversationID       string
	Agent                        string
	Sequence                     int
	PostProgressText, Complete   bool
	SlackReply                   *SlackReplyTarget
	Attachments                  []OutboundAttachment
	GoalTurn, GoalComplete       bool
	GoalTurnNumber, GoalMaxTurns int
	// contains filtered or unexported fields
}

OutboundMessage is a text message headed to enabled connectors.

func NewOutboundMessage added in v0.0.33

func NewOutboundMessage(source Source, conversationID, text string, targets ...OutputTarget) *OutboundMessage

NewOutboundMessage constructs an outbound message for one explicit conversation.

func (*OutboundMessage) MarkDelivered

func (m *OutboundMessage) MarkDelivered(err error)

MarkDelivered marks outbound delivery for this message complete.

func (*OutboundMessage) WaitDelivered

func (m *OutboundMessage) WaitDelivered(ctx context.Context) error

WaitDelivered waits until outbound delivery for this message finishes.

type OutputTarget

type OutputTarget string

OutputTarget identifies which connector should receive an outbound message.

const (
	// OutputTargetSlack delivers a response to its explicit Slack thread.
	OutputTargetSlack OutputTarget = "slack"
)

type SlackReplyTarget

type SlackReplyTarget struct {
	ChannelID, MessageTS, ThreadTS   string
	RecipientTeamID, RecipientUserID string
}

SlackReplyTarget identifies the Slack message that owns a streamed reply.

type Source

type Source string

Source identifies where an inbound or outbound message originated.

const (
	SourceSlack       Source = "slack"
	SourceExternalMCP Source = "external_mcp"
	SourceSystem      Source = "system"
)

Known inbound and outbound message source labels.

type StartNewThreadRequest added in v0.0.16

type StartNewThreadRequest struct {
	Source                                                   Source
	SourceConversationID, CurrentAgent, Agent, Title, Prompt string
	AllowedAgents                                            []string
	SlackReply                                               *SlackReplyTarget
}

StartNewThreadRequest asks RocketClaw to create a new managed conversation from the current turn.

type StartNewThreadResult added in v0.0.16

type StartNewThreadResult struct {
	ConversationID string `json:"conversation_id"`
	URL            string `json:"url,omitempty"`
}

StartNewThreadResult reports the created conversation and openable surface.

type StartNewThreadRootResult added in v0.0.16

type StartNewThreadRootResult struct {
	Target TextConversationTarget
	URL    string
}

StartNewThreadRootResult reports the native root surface created by a text connector.

type TextConversationTarget added in v0.0.7

type TextConversationTarget struct{ ChannelID, MessageID, ThreadID string }

TextConversationTarget identifies a conversation/message in the configured primary text connector.

Jump to

Keyboard shortcuts

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