Documentation
¶
Overview ¶
Package protocol defines shared RocketClaw event contracts.
Index ¶
- Constants
- Variables
- func AttachmentNamesSpeech(attachments []OutboundAttachment) string
- func Clone[T any](p *T) *T
- func IsTextAttachment(name, mimeType string) bool
- func NormalizeMIMEType(mimeType string) string
- func ReplyStepKey(turnID string) string
- func SetInboundAllowedAgents(inbound *InboundMessage, agents []string)
- func SlackThreadConversationID(channelID, threadTS string) string
- func SlackThreadTarget(conversationID string) (channelID, threadTS string, ok bool)
- func StaticGoalCheckWord(word *syntax.Word) (string, error)
- type AskUserQuestionAnswer
- type AskUserQuestionOption
- type AskUserQuestionRequest
- type AttachmentPresence
- type BackgroundJob
- type Conversation
- type ConversationChange
- type CronRunResult
- type CronjobMessage
- type Event
- type ExternalMCPRelay
- type GoalAction
- type GoalRequest
- type InboundAttachment
- type InboundContent
- type InboundKind
- type InboundMessage
- type InboundResponse
- type LaterWorkKind
- type LaterWorkRow
- type OneOffCronjob
- type OutboundAttachment
- type OutboundMessage
- type OutboundPublisher
- type PhaseStatus
- type PhaseUpdate
- type PrimaryTextRouter
- type ScheduledMessageState
- type SessionSummary
- type SkillDescription
- type SlackReplyTarget
- type Source
- type StartNewThreadRequest
- type StartNewThreadResult
- type Terminal
- type TextConversationTarget
- type ThreadQueueItem
- type UserQuestionAsker
- type WorkflowDescription
- type WorkflowInvocation
Constants ¶
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" )
const GoalCommandHelp = `` /* 502-byte string literal not displayed */
GoalCommandHelp is the bare `$goal` usage text (parameters and examples).
const MaxInboundTextAttachmentBytes = 256 << 10
MaxInboundTextAttachmentBytes is the per-file size limit for attachments converted to prompt text.
Variables ¶
var ErrBridgeStopped = errors.New("bridge stopped")
ErrBridgeStopped reports work left for the next start: it is the cause of shutdown cancellation and the error of requests a stopped bridge refuses.
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 ¶
IsTextAttachment reports whether an attachment should be included as literal prompt text.
func NormalizeMIMEType ¶ added in v0.1.0
NormalizeMIMEType returns a lowercase media type, or the trimmed lowercase input if parsing fails.
func ReplyStepKey ¶ added in v0.1.14
ReplyStepKey is the journal key of a turn's recorded reply attachment.
func SetInboundAllowedAgents ¶
func SetInboundAllowedAgents(inbound *InboundMessage, agents []string)
SetInboundAllowedAgents records surface-constrained agents on an inbound message.
func SlackThreadConversationID ¶
SlackThreadConversationID returns the stable conversation ID for a Slack thread.
func SlackThreadTarget ¶
SlackThreadTarget returns the Slack channel and thread timestamp for a Slack thread conversation ID.
Types ¶
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 AttachmentPresence ¶ added in v0.1.12
type AttachmentPresence string
AttachmentPresence records which attachments the source message carried, whether or not they reached the model.
const ( // AttachmentPresenceNone means the source message carried no attachments the model could miss. AttachmentPresenceNone AttachmentPresence = "" // AttachmentPresenceUnsupported means the source message carried only files the model cannot read as images or text. AttachmentPresenceUnsupported AttachmentPresence = "unsupported" // AttachmentPresenceImages means the source message carried images, even when none survived download. AttachmentPresenceImages AttachmentPresence = "images" )
Attachment presences; images win when a message carries both images and unsupported files.
type BackgroundJob ¶ added in v0.1.19
type BackgroundJob struct {
ID, Kind, State, Label, ToolCallID, SubagentKey, StoppedBy, Note string
Hidden bool
}
BackgroundJob is a Background Job a conversation lists: running, or finished with its Completion Note still pending. Hidden marks a job of a hidden cron or External MCP run whose destination is the conversation; StoppedBy is "user" or "agent" for a stopped job. Note is the job's Completion Note text, set only where a transcript shows the note.
type Conversation ¶ added in v0.1.0
type Conversation struct {
ID, Agent, CreatedBy string
}
Conversation is an explicitly recorded conversation and its selected agent. IDs are opaque to the Backend; frontends resolve presentation and policy.
type ConversationChange ¶ added in v0.1.12
type ConversationChange struct {
ConversationID string `json:"conversationId"`
Revision string `json:"revision"`
}
ConversationChange signals committed transcript changes without carrying content.
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 GoalAction ¶ added in v0.1.12
type GoalAction string
GoalAction identifies goal-loop work that consumes the goal's turn budget. Its zero value denotes ordinary work, including human re-steering.
const ( GoalActionNone GoalAction = "" GoalActionKickoff GoalAction = "goal" GoalActionContinue GoalAction = "goal_continuation" )
Goal actions distinguish budget-neutral input from kickoff and continuation work.
type GoalRequest ¶
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 ¶
InboundAttachment carries an inline attachment into a conversation prompt.
type InboundContent ¶
type InboundContent struct {
Text string
TextAttachments []string
Attachments []InboundAttachment
AttachmentPresence AttachmentPresence
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 is the surface that produced the message.
Source Source
// Text is the prompt body, with any text attachments appended after the typed text.
Text string
// Attachments are inline files, such as images, sent to the model alongside Text.
Attachments []InboundAttachment
// SlackReply is the Slack message that receives the reply; nil when the reply has no Slack target.
SlackReply *SlackReplyTarget
// AttachmentPresence records which attachments the source message carried, so the model can be told about ones it did not receive.
AttachmentPresence AttachmentPresence
// Human reports that a person wrote the message, rather than RocketClaw itself.
Human bool
// GoalTurn marks a turn that runs while a goal is active, including human input that does not spend the goal's turn budget.
GoalTurn bool
// AttachmentWarnings explain to the model, in plain text, why attachments were skipped.
AttachmentWarnings []string
// Kind says how the message enters the conversation's input queue.
Kind InboundKind
// GoalAction marks goal kickoff or continuation work that spends the goal's turn budget.
GoalAction GoalAction
// PreserveWhitespace keeps Text unchanged when framing the prompt instead of trimming it.
PreserveWhitespace bool
// ConversationID is the conversation that runs the turn; empty until the message is routed.
ConversationID string
// Metadata carries source-supplied context; the Inbound*MetadataKey keys are RocketClaw's trusted provenance and routing hints.
Metadata map[string]string
// Workflow, when it names a workflow, starts that workflow instead of an ordinary model turn.
Workflow WorkflowInvocation
// SyncDestination, when set, is a conversation that receives this turn: the turn waits in its queue,
// runs in ConversationID, and then its new history and final reply are copied into SyncDestination.
SyncDestination string
// RequireOutputDecision marks a private cron-style background turn; an empty reply posts nothing.
RequireOutputDecision bool
// Cronjob identifies the cron job that produced the message; nil for other messages.
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, text string, human bool) *InboundMessage
NewInboundMessage constructs an unrouted inbound message.
func NewInboundMessageFromContent ¶
func NewInboundMessageFromContent(source Source, kind InboundKind, 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 ¶
OneOffCronjob captures a live one-off cronjob prompt loaded from disk.
type OutboundAttachment ¶
type OutboundAttachment struct {
ID string
Name, MIMEType string
Data []byte `json:"-"` // Persisted turn state keeps only ID; large files exceed Postgres JSON limits.
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
ConsumedHeader string
ConsumedRawText string
ConsumedSource Source
Text 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
WorkflowTerminal Terminal
// ReplyState is the connector's recorded reply attachment for TurnID, copied
// from the turn's journal when the turn finishes, so a delivery after a restart
// edits the original placeholder.
ReplyState json.RawMessage `json:",omitempty"`
// 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 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 records one workflow phase's status and call counts.
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
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
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 StartNewThreadRequest ¶
type StartNewThreadRequest struct {
CurrentAgent, Agent, Title, Prompt, CreatedBy string
AllowedAgents []string
}
StartNewThreadRequest asks RocketClaw to create a new Web session from the current turn.
type StartNewThreadResult ¶
type StartNewThreadResult struct {
ConversationID string `json:"conversation_id"`
URL string `json:"url"`
}
StartNewThreadResult reports the created Web session and its address.
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
// Inbound, when set, is the full stored request; it replaces the fields above when the row runs.
Inbound *InboundMessage
}
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 ¶
func (a UserQuestionAsker) AskUserQuestion(ctx context.Context, req *AskUserQuestionRequest) (AskUserQuestionAnswer, error)
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.