Documentation
¶
Overview ¶
Package protocol defines shared RocketClaw event contracts.
Index ¶
- Constants
- Variables
- func AttachmentNamesSpeech(attachments []OutboundAttachment) string
- func IsTextAttachment(name, mimeType string) bool
- func OnDemandCronTarget(text string, prefixes ...string) (string, bool)
- func SetInboundAllowedAgents(inbound *InboundMessage, agents []string)
- func SlackThreadConversationID(channelID, threadTS string) string
- func SlackThreadTarget(conversationID string) (channelID, threadTS string, ok bool)
- func StartNewThreadRootText(title, prompt string) string
- func StaticGoalCheckWord(word *syntax.Word) (string, error)
- type ActivationHook
- type AgentUpdate
- type AskUserQuestionAnswer
- type AskUserQuestionOption
- type AskUserQuestionRequest
- type BridgeID
- type Broadcast
- type BroadcastAcknowledgement
- type BroadcastPublisher
- type BroadcastReply
- type BroadcastStatus
- type Channels
- type CronProgress
- type CronRunResult
- type CronjobMessage
- type ExternalMCPRelay
- type GoalRequest
- type InboundAttachment
- type InboundContent
- type InboundKind
- type InboundMessage
- type InboundResponse
- type LaterWorkKind
- type LaterWorkRow
- type LintFinding
- type LintRequest
- type LintResult
- type OneOffCronjob
- type OutboundAttachment
- type OutboundMessage
- type OutboundPublisher
- type OutputTarget
- type OverlayContext
- type OverlayFile
- type OverlaySpec
- type PendingSteer
- type PendingSteersSink
- type PhaseStatus
- type PhaseUpdate
- type PrimaryTextRouter
- type ReloadRequest
- type Response
- type ResponseKind
- type ResponsePayload
- type RestartRequest
- type ScheduledMessageState
- type SideAskRequest
- type SlackReplyTarget
- type Source
- type StartNewThreadRequest
- type StartNewThreadResponse
- type StartNewThreadResult
- type StartNewThreadRootResult
- type Terminal
- type TextConversationTarget
- type TextResponse
- type ThreadQueueItem
- type TryTurnRequest
- type TryTurnResult
- type UserQuestionAsker
- type WorkflowDescription
- type WorkflowInvocation
Constants ¶
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" )
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 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 IsTextAttachment ¶
IsTextAttachment reports whether an attachment should be included as literal prompt text.
func OnDemandCronTarget ¶
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 ¶
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.
func StartNewThreadRootText ¶
StartNewThreadRootText returns the human-visible root text for tool-created text conversations.
Types ¶
type ActivationHook ¶
type ActivationHook func(context.Context, *InboundMessage) error
ActivationHook runs when a text connector activates an idle conversation.
type AgentUpdate ¶
type AgentUpdate struct {
CallID, 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
Bridge BridgeID
ID, Question, Details string
ConversationID string
Options []AskUserQuestionOption
Multiple bool
SlackReply *SlackReplyTarget
}
AskUserQuestionRequest asks the originating text connector human for input.
type BridgeID ¶
type BridgeID string
BridgeID identifies a connector participating in RocketClaw communication.
type Broadcast ¶
type Broadcast struct {
Sender BridgeID
Message *OutboundMessage
Delivery *OutboundMessage
Relay *ExternalMCPRelay
RelayReply *InboundMessage
RelayChannel string
RelayCleanup *InboundMessage
RelayResponse chan BroadcastReply
Acknowledgement chan BroadcastAcknowledgement
}
Broadcast carries live output to Bridges other than its sender.
type BroadcastAcknowledgement ¶
type BroadcastAcknowledgement struct {
Status BroadcastStatus
Err error
}
BroadcastAcknowledgement reports the outcome of one Bridge delivery.
type BroadcastPublisher ¶
type BroadcastPublisher chan<- Broadcast
BroadcastPublisher adapts the Broadcasts channel to the outbound publisher contract.
func (BroadcastPublisher) PublishOutbound ¶
func (p BroadcastPublisher) PublishOutbound(ctx context.Context, message *OutboundMessage) error
PublishOutbound publishes one live output Broadcast.
type BroadcastReply ¶
type BroadcastReply struct {
Message *InboundMessage
Err error
}
BroadcastReply carries the result of a Bridge-specific Broadcast operation.
type BroadcastStatus ¶
type BroadcastStatus string
BroadcastStatus describes how a Bridge handled a Broadcast.
const ( // BroadcastHandled reports that a Bridge delivered or acted on a Broadcast. BroadcastHandled BroadcastStatus = "handled" // BroadcastDropped reports that a Bridge intentionally ignored a Broadcast. BroadcastDropped BroadcastStatus = "dropped" // BroadcastFailed reports that a Bridge could not handle a Broadcast. BroadcastFailed BroadcastStatus = "failed" )
type Channels ¶
type Channels struct {
Broadcasts chan Broadcast
}
Channels are the unbuffered channels used for connector communication.
func NewChannels ¶
func NewChannels() Channels
NewChannels constructs the unbuffered connector channels.
type CronProgress ¶
CronProgress receives one-off cron thinking and message callbacks.
type CronRunResult ¶
type CronRunResult struct {
Text, VerbatimMessage string
Attachments []OutboundAttachment
}
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 ExternalMCPRelay ¶
type ExternalMCPRelay struct {
ConversationID, ExternalConversationID, Agent, Text string
Attachments []OutboundAttachment
}
ExternalMCPRelay carries one MCP request to its Slack surface.
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
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
Bridge BridgeID
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
Workflow *WorkflowInvocation
Response chan Response
// 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) CompleteResponse ¶
func (m *InboundMessage) CompleteResponse(text string, err error)
CompleteResponse marks this inbound turn result ready.
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 LintFinding ¶
type LintFinding struct {
Code, Severity, Path, Message string
}
LintFinding is one overlay lint finding.
type LintRequest ¶
type LintRequest struct {
Context OverlayContext
}
LintRequest is one overlay lint call.
type LintResult ¶
type LintResult struct {
Findings []LintFinding
}
LintResult is the overlay lint outcome.
type OneOffCronjob ¶
type OneOffCronjob struct {
Agent, Prompt, RelativePath, TextChannel string
}
OneOffCronjob captures a live one-off cronjob prompt loaded from disk.
type OutboundAttachment ¶
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
Bridge BridgeID
Targets []OutputTarget
ConversationID, TurnID string
SessionEntryID int64
ExternalConversationID string
Agent string
Cronjob *CronjobMessage
Sequence int
PostProgressText, Complete bool
SlackReply *SlackReplyTarget
Attachments []OutboundAttachment
GoalTurn, GoalComplete, GoalActive bool
GoalTurnNumber, GoalMaxTurns int
WorkflowAgent *AgentUpdate
WorkflowPhase *PhaseUpdate
WorkflowTerminal Terminal
Response chan Response
// 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(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 OutboundPublisher ¶
type OutboundPublisher interface {
PublishOutbound(context.Context, *OutboundMessage) error
}
OutboundPublisher sends one outbound message into connector delivery.
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 OverlayContext ¶
type OverlayContext struct {
BaseOverlay string
Files []OverlayFile
}
OverlayContext is a named base overlay plus request-carried file deltas.
type OverlayFile ¶
type OverlayFile struct {
Path, Content string
}
OverlayFile is one overlay file on the development-flow protocol.
type OverlaySpec ¶
type OverlaySpec struct {
Spec string
}
OverlaySpec is one configured overlay name.
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
Details string
}
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)
InterruptConversation(conversationID string) *InboundMessage
InterruptThread(target TextConversationTarget) (*InboundMessage, error)
RegisterThread(target TextConversationTarget, agent string) (created bool, err error)
RegisterCronThread(ctx context.Context, target TextConversationTarget, agent string) 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)
SubmitWhenActive(ctx context.Context, target TextConversationTarget, inbound *InboundMessage, activation ActivationHook) (bool, error)
StashThreadQueueItem(ctx context.Context, target TextConversationTarget, item *ThreadQueueItem) error
ThreadQueueItems(ctx context.Context, target TextConversationTarget) ([]ThreadQueueItem, error)
DeleteThreadQueueItem(ctx context.Context, target TextConversationTarget, id string) error
ScheduledMessages(ctx context.Context, target TextConversationTarget) (map[string]ScheduledMessageState, error)
ThreadBusy(target TextConversationTarget) bool
PickQueuedWork(ctx context.Context, target TextConversationTarget) error
}
PrimaryTextRouter routes primary text connector conversations.
type ReloadRequest ¶
type ReloadRequest struct {
Reason string
}
ReloadRequest is one Reload protocol message.
type Response ¶
type Response struct {
Payload ResponsePayload
Err error
}
Response carries progress, interaction, result, or error information for a Request.
type ResponseKind ¶
type ResponseKind string
ResponseKind identifies the kind of value carried by a Response.
const ( // ResponseProgress carries observable operation progress. ResponseProgress ResponseKind = "progress" // ResponseInteraction carries an interaction for a connector to handle. ResponseInteraction ResponseKind = "interaction" // ResponseResult carries a completed operation result. ResponseResult ResponseKind = "result" )
type ResponsePayload ¶
type ResponsePayload interface {
ResponseKind() ResponseKind
}
ResponsePayload is the typed value carried by a Response.
type RestartRequest ¶
type RestartRequest struct {
Reason string
}
RestartRequest is one Restart protocol message.
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 SideAskRequest ¶
type SideAskRequest struct {
ConversationID string
SessionEntryID int64
Agent, Question string
Thinking, Message func(context.Context, string) error
}
SideAskRequest is one isolated Slack Side Ask turn.
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 {
Source Source
Bridge BridgeID
SourceConversationID, CurrentAgent, Agent, Title, Prompt string
AllowedAgents []string
SlackReply *SlackReplyTarget
Response chan Response
}
StartNewThreadRequest asks RocketClaw to create a new managed conversation from the current turn.
type StartNewThreadResponse ¶
type StartNewThreadResponse struct {
Request *StartNewThreadRequest
Root chan StartNewThreadRootResult
Err chan error
}
StartNewThreadResponse asks a connector to create a native thread root.
func (StartNewThreadResponse) ResponseKind ¶
func (StartNewThreadResponse) ResponseKind() ResponseKind
ResponseKind identifies the child-thread interaction.
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 TextConversationTarget ¶
type TextConversationTarget struct{ ChannelID, MessageID, ThreadID string }
TextConversationTarget identifies a conversation/message in the configured primary text connector.
type TextResponse ¶
type TextResponse struct {
Kind ResponseKind
Message *OutboundMessage
}
TextResponse carries originator output for one inbound.
func (*TextResponse) ResponseKind ¶
func (r *TextResponse) ResponseKind() ResponseKind
ResponseKind identifies the TextResponse result.
type ThreadQueueItem ¶
type ThreadQueueItem struct {
ID string
ConversationID string
Message string
Principal string
StashAt time.Time
Position int
ParkAfter string
SlackChannel string
SlackTS string
}
ThreadQueueItem is one persisted Enqueued Slack Message.
type TryTurnRequest ¶
type TryTurnRequest struct {
Context OverlayContext
Agent, Prompt string
ConversationID string
}
TryTurnRequest is one Development MCP try-turn.
type TryTurnResult ¶
type TryTurnResult struct {
ConversationID, Thinking, Answer string
}
TryTurnResult is one Development MCP try-turn outcome.
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 {
RunID, Name, Args string
}
WorkflowInvocation is one inbound workflow start without a compiled program.