Help us shape the future of Go! Take the 2026 Go Developer Survey

protocol

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package protocol defines shared RocketClaw event contracts.

Index

Constants

View Source
const (
	// InboundRawTextMetadataKey retains typed text before attachment text is merged.
	InboundRawTextMetadataKey = "rocketclaw_raw_text"
	// 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 GoalCommandHelp = `` /* 502-byte string literal not displayed */

GoalCommandHelp is the bare `$goal` usage text (parameters and examples).

View Source
const MaxInboundTextAttachmentBytes = 256 << 10

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

Variables

View Source
var ErrGoalAlreadyActive = errors.New("goal already active")

ErrGoalAlreadyActive reports that a conversation already has an active goal.

Functions

func AttachmentNamesSpeech

func AttachmentNamesSpeech(attachments []OutboundAttachment) string

AttachmentNamesSpeech returns a short spoken description of attachment names.

func Clone added in v0.1.0

func Clone[T any](p *T) *T

Clone returns a shallow copy of p, or nil when p is nil.

func IsTextAttachment

func IsTextAttachment(name, mimeType string) bool

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

func NormalizeMIMEType added in v0.1.0

func NormalizeMIMEType(mimeType string) string

NormalizeMIMEType returns a lowercase media type, or the trimmed lowercase input if parsing fails.

func OnDemandCronTarget

func OnDemandCronTarget(text string) (string, bool)

OnDemandCronTarget extracts one deterministic top-level cron target from connector text.

func SetInboundAllowedAgents

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

SetInboundAllowedAgents records surface-constrained agents on an inbound message.

func SlackThreadConversationID

func SlackThreadConversationID(channelID, threadTS string) string

SlackThreadConversationID returns the stable conversation ID for a Slack thread.

func SlackThreadTarget

func SlackThreadTarget(conversationID string) (channelID, threadTS string, ok bool)

SlackThreadTarget returns the Slack channel and thread timestamp for a Slack thread conversation ID.

func StaticGoalCheckWord

func StaticGoalCheckWord(word *syntax.Word) (string, error)

StaticGoalCheckWord returns the literal text of a shell word with no expansions.

Types

type AgentUpdate

type AgentUpdate struct {
	PhaseID, Label, Activity string
}

AgentUpdate reports one workflow agent call's latest observable activity.

type AskUserQuestionAnswer

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

type AskUserQuestionOption struct{ Label, Value, Description string }

AskUserQuestionOption is one native UI choice for ask_user_question.

type AskUserQuestionRequest

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 Conversation added in v0.1.0

type Conversation struct {
	ID, Agent, CreatedBy string
	Settled              bool
}

Conversation is an explicitly recorded conversation and its selected agent. IDs are opaque to the Backend; frontends resolve presentation and policy.

type CronRunResult

type CronRunResult struct {
	ConversationID string
}

CronRunResult captures the observable result of one cronjob run.

type CronjobMessage

type CronjobMessage struct {
	RelativePath, Agent, RanAt string
}

CronjobMessage identifies a human-visible cronjob result.

type Event added in v0.1.0

type Event struct {
	Message         *OutboundMessage
	Acknowledgement chan error
}

Event is live conversation output. Consumers acknowledge after final handling, including when the output does not apply to their surface.

type ExternalMCPRelay

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

ExternalMCPRelay carries one MCP request to its Slack surface.

type GoalRequest

type GoalRequest struct {
	Objective, CheckScript string
	MaxTurns               int
}

GoalRequest is one parsed text-connector goal start request.

func ParseGoalRequest

func ParseGoalRequest(text string) (goal GoalRequest, rejection string)

ParseGoalRequest parses canonical $goal arguments.

type InboundAttachment

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

InboundAttachment carries an inline attachment into a conversation prompt.

type InboundContent

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"
	// InboundKindSteer joins an open human turn or runs next after input closes.
	InboundKindSteer InboundKind = "steer"
	// InboundKindEnqueue waits for its own turn.
	InboundKindEnqueue InboundKind = "enqueue"
	// InboundKindHeld waits for manual release into the queue.
	InboundKindHeld InboundKind = "held"
	// InboundKindCancel interrupts the active conversation owner.
	InboundKindCancel InboundKind = "cancel"
)

type InboundMessage

type InboundMessage struct {
	Source                                                  Source
	Label, Text                                             string
	Attachments                                             []InboundAttachment
	SlackReply                                              *SlackReplyTarget
	HadAttachments, HadNonImageAttachments, Human, GoalTurn bool
	AttachmentWarnings                                      []string
	Kind                                                    InboundKind
	ConversationID                                          string
	Metadata                                                map[string]string
	Workflow                                                *WorkflowInvocation
	SyncDestination                                         string
	RequireOutputDecision                                   bool
	Cronjob                                                 *CronjobMessage
	// contains filtered or unexported fields
}

InboundMessage is a message headed into its conversation prompt queue.

func NewInboundMessage

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

NewInboundMessage constructs an unrouted inbound message.

func NewInboundMessageFromContent

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) CompleteResponseWithAttachments

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 LaterWorkKind

type LaterWorkKind string

LaterWorkKind is one row in mixed later-work order.

const (
	// LaterWorkQueued is an Enqueued Slack Message row.
	LaterWorkQueued LaterWorkKind = "queued"
	// LaterWorkScheduled is a scheduled-message peg.
	LaterWorkScheduled LaterWorkKind = "scheduled"
)

type LaterWorkRow

type LaterWorkRow struct {
	Kind        LaterWorkKind
	Queue       ThreadQueueItem
	ScheduledID string
	Scheduled   ScheduledMessageState
}

LaterWorkRow is one mixed-list entry.

func MixedLaterWork

func MixedLaterWork(queue []ThreadQueueItem, scheduled map[string]ScheduledMessageState) []LaterWorkRow

MixedLaterWork builds later-work order: empty-park enqueue, then each scheduled peg in due-time order with enqueue parked after that peg. Unknown park-after is empty.

type OneOffCronjob

type OneOffCronjob struct {
	Agent, Prompt, RelativePath, TextChannel string
	ConversationID                           string
}

OneOffCronjob captures a live one-off cronjob prompt loaded from disk.

type OutboundAttachment

type OutboundAttachment struct {
	ID                 string
	Name, MIMEType     string
	Data               []byte
	OriginalUnverified bool
	Size               int64 // Stored byte length for metadata-only reads.
}

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 {
	ConsumedID, ConsumedText           string
	ConsumedRawText                    string
	ConsumedSource                     Source
	Text, ProgressText                 string
	ConversationID, TurnID             string
	ExternalConversationID             string
	Agent                              string
	Model, SourceConversationID        string
	ReasoningEffort                    *string
	Cronjob                            *CronjobMessage
	Complete                           bool
	SlackReply                         *SlackReplyTarget
	Attachments                        []OutboundAttachment
	GoalTurn, GoalComplete, GoalActive bool
	GoalTurnNumber, GoalMaxTurns       int
	WorkflowAgent                      *AgentUpdate
	WorkflowPhase                      *PhaseUpdate
	WorkflowTerminal                   Terminal
	// contains filtered or unexported fields
}

OutboundMessage is a text message headed to enabled connectors.

func CloneOutboundMessage

func CloneOutboundMessage(message *OutboundMessage) *OutboundMessage

CloneOutboundMessage returns a deep copy suitable for an independent connector delivery.

func NewOutboundMessage

func NewOutboundMessage(conversationID, text string) *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 OutboundPublisher

type OutboundPublisher interface {
	PublishOutbound(context.Context, *OutboundMessage) error
}

OutboundPublisher sends one outbound message into connector delivery.

type PendingSteer

type PendingSteer struct {
	Text, Principal, SlackChannel, SlackTS, SlackThreadTS string
}

PendingSteer is one uninjected Slack Steer copied onto the active-turn row.

type PendingSteersSink

type PendingSteersSink struct {
	Set func(conversationID string, steers []PendingSteer) error
}

PendingSteersSink copies pending Slack Steers onto the active-turn row. The zero value is inert.

func (PendingSteersSink) Persist

func (s PendingSteersSink) Persist(conversationID string, steers []PendingSteer)

Persist copies steers onto the active-turn row, or does nothing when unset.

type PhaseStatus

type PhaseStatus string

PhaseStatus identifies one workflow phase state.

const (
	// PhasePending has not started.
	PhasePending PhaseStatus = "pending"
	// PhaseInProgress is executing.
	PhaseInProgress PhaseStatus = "in-progress"
	// PhaseComplete finished successfully.
	PhaseComplete PhaseStatus = "complete"
	// PhaseError failed.
	PhaseError PhaseStatus = "error"
	// PhaseSkipped was not entered before the workflow terminated.
	PhaseSkipped PhaseStatus = "skipped"
)

type PhaseUpdate

type PhaseUpdate struct {
	PhaseID, Name                string
	Status                       PhaseStatus
	Scheduled, Running, Complete int
}

PhaseUpdate reports connector-neutral workflow progress.

type PrimaryTextRouter

type PrimaryTextRouter interface {
	StartThread(ctx context.Context, agent string, target TextConversationTarget, inbound *InboundMessage) error
	StartGoalInThread(ctx context.Context, agent, objective, checkScript string, maxTurns int, target TextConversationTarget, inbound *InboundMessage) error
	StartWorkflowInThread(ctx context.Context, agent, name, args string, target TextConversationTarget, inbound *InboundMessage) error
	ReserveWorkflowTurn(target TextConversationTarget) (release func(), reserved bool, err error)
	WorkflowDescriptions() ([]WorkflowDescription, error)
	SkillDescriptions(agent string) ([]SkillDescription, error)
	InterruptConversation(conversationID string) *InboundMessage
	InterruptThread(target TextConversationTarget) (*InboundMessage, error)
	RegisterThread(target TextConversationTarget, agent string) (created bool, err error)
	ThreadAgent(target TextConversationTarget) (agent string, handled bool, err error)
	SwitchThreadAgent(target TextConversationTarget, agent string) (bool, error)
	SubmitThreadReply(ctx context.Context, target TextConversationTarget, inbound *InboundMessage) (bool, error)
	StashThreadQueueItem(ctx context.Context, target TextConversationTarget, item *ThreadQueueItem) error
	ThreadQueueItems(target TextConversationTarget) ([]ThreadQueueItem, error)
	DeleteThreadQueueItem(ctx context.Context, target TextConversationTarget, id string) (bool, error)
	PromoteThreadQueueItem(ctx context.Context, target TextConversationTarget, id string) (bool, error)
	ScheduledMessages(target TextConversationTarget) (map[string]ScheduledMessageState, error)
	ThreadBusy(target TextConversationTarget) bool
}

PrimaryTextRouter routes primary text connector conversations.

type ScheduledMessageState

type ScheduledMessageState struct {
	ConversationID string        `json:"conversation_id,omitempty"`
	Agent          string        `json:"agent,omitempty"`
	Message        string        `json:"message,omitempty"`
	DueAt          time.Time     `json:"due_at,omitzero"`
	Recurring      bool          `json:"recurring,omitempty"`
	Interval       time.Duration `json:"interval,omitempty"`
}

ScheduledMessageState records one pending delayed system prompt.

type SessionSummary added in v0.1.0

type SessionSummary struct {
	ConversationID, LastMessage string
	LastUpdated                 time.Time
}

SessionSummary is one durable conversation's list row.

type SkillDescription added in v0.1.0

type SkillDescription struct {
	Name, Description string
}

SkillDescription describes an available skill for human discovery.

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"
	SourceWeb         Source = "web"
	SourceExternalMCP Source = "external_mcp"
	SourceSystem      Source = "system"
)

Known inbound and outbound message source labels.

type StartNewThreadRequest

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

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

type StartNewThreadResult

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

StartNewThreadResult reports the created conversation and openable surface.

type StartNewThreadRootResult

type StartNewThreadRootResult struct {
	Target TextConversationTarget
	URL    string
}

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

type Terminal

type Terminal string

Terminal identifies how a workflow run ended.

const (
	// TerminalComplete reports a successful workflow.
	TerminalComplete Terminal = "complete"
	// TerminalFailed reports a workflow infrastructure failure.
	TerminalFailed Terminal = "failed"
	// TerminalStopped reports a human interruption.
	TerminalStopped Terminal = "stopped"
)

type TextConversationTarget

type TextConversationTarget struct{ ChannelID, MessageID, ThreadID string }

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

type ThreadQueueItem

type ThreadQueueItem struct {
	Kind           InboundKind
	ID             string
	ConversationID string
	Message        string
	Content        InboundContent
	Source         Source
	SlackReply     *SlackReplyTarget
	Principal      string
	StashAt        time.Time
	Position       int
	ParkAfter      string
	SlackChannel   string
	SlackTS        string
}

ThreadQueueItem is one persisted waiting message. A zero Kind means enqueue.

type UserQuestionAsker

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

UserQuestionAsker is the origin-owned ask_user_question capability for one turn path. The zero value is inert (ExposeTool is false).

func InteractiveUserQuestionAsker

func InteractiveUserQuestionAsker(ask func(context.Context, *AskUserQuestionRequest) (AskUserQuestionAnswer, error)) UserQuestionAsker

InteractiveUserQuestionAsker returns an asker that exposes the tool and delegates to ask.

func NoUserQuestionAsker

func NoUserQuestionAsker() UserQuestionAsker

NoUserQuestionAsker returns the inert asker that omits the tool from the model list.

func (UserQuestionAsker) AskUserQuestion

AskUserQuestion runs the origin ask path, or rejects when the tool is not exposed.

func (UserQuestionAsker) ExposeTool

func (a UserQuestionAsker) ExposeTool() bool

ExposeTool reports whether ask_user_question belongs in the model tool list.

type WorkflowDescription

type WorkflowDescription struct{ Name, Description string }

WorkflowDescription identifies one available workflow.

type WorkflowInvocation

type WorkflowInvocation struct {
	Name, Args string
}

WorkflowInvocation is one inbound workflow start without a compiled program.

Jump to

Keyboard shortcuts

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