Documentation
¶
Overview ¶
Package protocol defines shared RocketClaw event contracts.
Index ¶
- Constants
- Variables
- 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
- type AskUserQuestionAnswer
- type AskUserQuestionOption
- type AskUserQuestionRequest
- type AttachmentPresence
- type BackgroundJob
- type Conversation
- type ConversationChange
- type CronRun
- type CronRunResult
- type CronjobMessage
- type Event
- 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 ShadowBinding
- type ShadowTurn
- type SlackReplyTarget
- type Source
- 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" // InboundPrincipalNameMetadataKey names the person a turn's shell sees as ROCKETCLAW_PRINCIPAL_NAME. InboundPrincipalNameMetadataKey = "rocketclaw_principal_name" // InboundPrincipalEmailMetadataKey is that person's email, the source of ROCKETCLAW_PRINCIPAL_EMAIL and _ID. InboundPrincipalEmailMetadataKey = "rocketclaw_principal_email" // InboundAllowedAgentsMetadataKey lists source-surface allowed agents for model-created child conversations. InboundAllowedAgentsMetadataKey = "rocketclaw_allowed_agents" // InboundSenderSessionMetadataKey names the session whose agent wrote the inbound. InboundSenderSessionMetadataKey = "rocketclaw_sender_session" // InboundSenderAgentMetadataKey names the agent that wrote the inbound. InboundSenderAgentMetadataKey = "rocketclaw_sender_agent" // InboundSenderActionMetadataKey records what the sender did before the inbound; see SenderActionStopped. InboundSenderActionMetadataKey = "rocketclaw_sender_action" // SenderActionStopped means the sender stopped the target's previous turn and sent the inbound to run next. SenderActionStopped = "stopped" )
const GoalCommandHelp = `` /* 245-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 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.
Types ¶
type AskUserQuestionAnswer ¶
type AskUserQuestionAnswer struct {
Selected []string `json:"selected"`
Custom string `json:"custom"`
Source Source `json:"source"`
}
AskUserQuestionAnswer is returned to the harness 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 {
ID, Question, Details string
ConversationID string
Options []AskUserQuestionOption
Multiple bool
}
AskUserQuestionRequest asks a Web turn's 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
Conversation is an explicitly recorded conversation and its selected agent. IDs are opaque to the Backend; frontends resolve presentation and policy. Space names the Web space it is born in, created when missing; empty for none. Run is set only for a cron run, which is created hidden; any other is a Web chat.
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 CronRun ¶ added in v0.2.0
CronRun locates a cron run: its definition's path, start time, and whether it ran once from Web.
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
// Space is the cron's own Web space, empty when it names none.
Space 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 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 the running turn while it accepts input, whoever sent it or // started the turn, and otherwise runs next. 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
// OriginHeader, set on a follow-on message such as a scheduled message, a goal continuation or a
// background wake, is the trusted origin header of the turn that created it, which permission
// reviews of its turn read instead of one rendered from Source and Metadata.
OriginHeader string
// 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
ConversationID string `json:"conversation_id,omitempty"` // Actual owner when projecting an input reference.
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
Agent string
Model, SourceConversationID string
ReasoningEffort *string
Cronjob *CronjobMessage
Complete bool
SlackReply *SlackReplyTarget
Attachments []OutboundAttachment
GoalTurn, GoalComplete, GoalActive bool
GoalTurnNumber, GoalMaxTurns int
// Source is the source of the inbound that started the turn.
Source Source
// Terminal is how a final's turn ended: complete, failed, or stopped.
Terminal 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"`
}
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.
type OutboundPublisher ¶
type OutboundPublisher interface {
PublishOutbound(context.Context, *OutboundMessage) error
}
OutboundPublisher completes connector delivery of one outbound message.
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 {
// MentionThread reports whether a conversation records the thread and whether it is a
// read-only report thread: one an earlier version posted a cron report or External MCP session into.
MentionThread(target TextConversationTarget) (recorded, report bool, err error)
// SubmitMention records the thread's conversation with agent when absent and queues inbound
// as its next turn, at most once per mention; it reports false for a mention already accepted,
// and true with an error when the mention was queued but its pickup failed.
SubmitMention(ctx context.Context, agent string, target TextConversationTarget, inbound *InboundMessage) (bool, error)
// InterruptThread stops the thread's goal and interrupts its active turn without waiting for
// a running turn to end.
InterruptThread(target TextConversationTarget) (*InboundMessage, error)
// WebURL links to the conversation in the Web Interface.
WebURL(ctx context.Context, conversationID string) (string, error)
}
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"`
// Origin is the trusted origin header of the message's turn: ScheduledMessage and its creator's source.
Origin string `json:"origin,omitempty"`
}
ScheduledMessageState records one pending delayed system prompt.
type SessionSummary ¶ added in v0.1.0
SessionSummary is one durable conversation's list row.
type ShadowBinding ¶ added in v0.1.33
type ShadowBinding struct {
ParentConversationID, ParentAgent, ShadowAgent, ChildConversationID string
Turns []ShadowTurn
}
ShadowBinding identifies a parent's independent comparison session. Turns contain only correlations in the requested parent history page, not seed history.
type ShadowTurn ¶ added in v0.1.33
type ShadowTurn struct {
ParentSourceConversationID, ParentTurnID, ChildTurnID string
Order int64
Running bool
Terminal Terminal
Revision string
}
ShadowTurn pairs one outer turn by source and identity, never prompt text. An empty ChildTurnID and Terminal means waiting. A completed turn without a reply is silent; its position is retained regardless of transcript content.
type SlackReplyTarget ¶
type SlackReplyTarget struct{ ChannelID, MessageTS, ThreadTS string }
SlackReplyTarget identifies the Slack message a reply answers.
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 interface {
AskUserQuestion(context.Context, *AskUserQuestionRequest) (AskUserQuestionAnswer, error)
}
UserQuestionAsker asks a turn's human an ask_user_question and waits for the answer.
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.