Documentation
¶
Overview ¶
Package backend owns conversation execution, later-work, and cron.
Index ¶
- Constants
- Variables
- func ExternalMCPAgentsIn(cfg *config.Config, runtimeDir string) ([]string, error)
- func GenerateHandoff(ctx context.Context, cfg *config.Config, agent, transcript string) (document string, err error)
- func IsBridgeStopped(err error) bool
- func LoadRuntimeDefinitions(cfg *config.Config, runtimeDir string) (rocketcode.Agents, rocketcode.Skills, error)
- func OriginPairsFromEntry(entry *rocketcode.SessionEntry) (map[string]string, bool)
- func ReplayDeliveryText(items []responses.ResponseInputItemUnionParam) (text string, index int, err error)
- func ReplayInputMessageRoleText(item *responses.ResponseInputItemUnionParam, raw json.RawMessage) (role, text string, ok bool, err error)
- func Run(ctx context.Context, cfg *config.Config, configPath string, ...) error
- func ValidateGoalCheckScriptStart(cfg *config.Config, agentName, script string) error
- type ActiveTurnState
- type Bridge
- func (b *Bridge) InterruptActiveTurn() *protocol.InboundMessage
- func (b *Bridge) PickLaterWork(ctx context.Context) error
- func (b *Bridge) RecoverActiveTurn(ctx context.Context, turn *ActiveTurnState) error
- func (b *Bridge) ResetScheduledMessages() error
- func (b *Bridge) ScheduleMessage(delay time.Duration, message string, recurring bool) error
- func (b *Bridge) Start(ctx context.Context) error
- func (b *Bridge) Stop() error
- func (b *Bridge) Submit(ctx context.Context, msg *protocol.InboundMessage) error
- func (b *Bridge) SwitchAgent(agent string)
- type Config
- type CronScheduleState
- type EnqueueActivation
- type ExternalMCPSessionState
- type FrontendAssembler
- type GoalState
- type KeyedConversationLocks
- type ObservedSessionEntry
- type PruneStateStats
- type RawRunProgress
- type Runtime
- func (r *Runtime) AttachSlack(slack SlackFrontend)
- func (r *Runtime) CreateConversation(ctx context.Context, conversation protocol.Conversation) error
- func (r *Runtime) DeleteQueueItem(ctx context.Context, conversationID, id string) (bool, error)
- func (r *Runtime) ListConversations(ctx context.Context) (conversations []protocol.Conversation, err error)
- func (r *Runtime) PopQueueItem(ctx context.Context, conversationID, id string) (bool, error)
- func (r *Runtime) PromoteQueueItem(ctx context.Context, conversationID, id string) (bool, error)
- func (r *Runtime) PublishOutbound(ctx context.Context, message *protocol.OutboundMessage) error
- func (r *Runtime) QueueItems(conversationID string) ([]protocol.ThreadQueueItem, error)
- func (r *Runtime) ReorderQueueItems(conversationID string, ids []string) error
- func (r *Runtime) RunTurn(ctx context.Context, inbound *protocol.InboundMessage) error
- func (r *Runtime) StartGoal(ctx context.Context, inbound *protocol.InboundMessage, ...) error
- func (r *Runtime) StashQueueItem(ctx context.Context, conversationID string, item *protocol.ThreadQueueItem) error
- func (r *Runtime) Subscribe(ctx context.Context) iter.Seq[protocol.Event]
- func (r *Runtime) SwitchConversationAgent(conversationID, agent string) (bool, error)
- func (r *Runtime) SyncConversation(ctx context.Context, source, destination string) error
- func (r *Runtime) WorkflowDescriptions() (descriptions []protocol.WorkflowDescription, err error)
- type SessionService
- func (s *SessionService) AccountGoalTurn(conversationID string) (GoalState, bool, error)
- func (s *SessionService) ActiveGoalThreads() (map[string]ThreadState, error)
- func (s *SessionService) ActiveGoals() (map[string]GoalState, error)
- func (s *SessionService) AppendEntryID(ctx context.Context, conversationID string, entry *harness.SessionEntry) (int64, error)
- func (s *SessionService) ApplyPendingRestartNotifications(ctx context.Context) error
- func (s *SessionService) AttachmentMetadata(ctx context.Context, conversationID, id string, uploadOnly bool) (protocol.OutboundAttachment, error)
- func (s *SessionService) BeginGoal(conversationID, objective, checkScript string, maxTurns int, ...) error
- func (s *SessionService) Changes(ctx context.Context, conversationID string) iter.Seq2[protocol.ConversationChange, error]
- func (s *SessionService) ChannelFact(ctx context.Context, workspaceID, channelID string) (name string, found bool, err error)
- func (s *SessionService) ClaimCronSchedule(due CronScheduleState, nextDue, now time.Time) (relativePath string, claimed bool, err error)
- func (s *SessionService) ClaimScheduledMessage(id, conversationID string, dueAt, now time.Time) (message protocol.ScheduledMessageState, claimed bool, err error)
- func (s *SessionService) ClearActiveTurn(ctx context.Context, turnID string) error
- func (s *SessionService) CompleteCronRun(relativePath string, now time.Time) error
- func (s *SessionService) Delegations(ctx context.Context, conversationID, sourceConversationID string, ...) ([]string, error)
- func (s *SessionService) DeleteScheduledMessage(id string) error
- func (s *SessionService) DeleteSession(ctx context.Context, conversationID string) (int64, error)
- func (s *SessionService) DeleteThreadQueueItem(id string) error
- func (s *SessionService) DueCronSchedules(now time.Time) ([]CronScheduleState, error)
- func (s *SessionService) ExternalMCPSession(externalConversationID string) (ExternalMCPSessionState, bool, error)
- func (s *SessionService) ExternalMCPSessionByConversationID(conversationID string) (externalConversationID string, session ExternalMCPSessionState, ok bool, ...)
- func (s *SessionService) ForkConversation(ctx context.Context, source string, destination protocol.Conversation, ...) (string, error)
- func (s *SessionService) Goal(conversationID string) (GoalState, bool, error)
- func (s *SessionService) ListSessions(ctx context.Context, conversationIDs []string) ([]protocol.SessionSummary, error)
- func (s *SessionService) LoadAttachment(ctx context.Context, conversationID, id string, uploadOnly bool) (protocol.OutboundAttachment, error)
- func (s *SessionService) MarkRestartRequester(ctx context.Context, conversationID string) error
- func (s *SessionService) ObserveEntries(ctx context.Context, conversationID string) ([]ObservedSessionEntry, error)
- func (s *SessionService) ObserveTranscript(ctx context.Context, conversationID string, from, before int64, ...) ([]ObservedSessionEntry, error)
- func (s *SessionService) OriginPairs(ctx context.Context, conversationID string) (map[string]string, error)
- func (s *SessionService) PairBusyFor(pairID string) bool
- func (s *SessionService) PruneStateBefore(ctx context.Context, cutoff time.Time) (PruneStateStats, error)
- func (s *SessionService) PutMCPWaiter(id string, inbound *protocol.InboundMessage)
- func (s *SessionService) PutScheduledMessage(id string, message *protocol.ScheduledMessageState) error
- func (s *SessionService) PutThreadQueueItem(id string, item *protocol.ThreadQueueItem) error
- func (s *SessionService) RecordChannelFact(ctx context.Context, workspaceID, channelID, name string, observedAt time.Time) error
- func (s *SessionService) RecoverableActiveTurns(ctx context.Context) ([]ActiveTurnState, error)
- func (s *SessionService) RegisterExternalMCPConversation(externalConversationID, managedAgent string, session *ExternalMCPSessionState) error
- func (s *SessionService) ReleaseExternalMCPRecovery(conversationID string) error
- func (s *SessionService) RemoveExternalMCPConversation(externalConversationID string) error
- func (s *SessionService) ReplayAttachments(ctx context.Context, conversationID string, root *os.Root, raw json.RawMessage, ...) ([]protocol.OutboundAttachment, error)
- func (s *SessionService) ReserveExternalMCPRecovery(conversationID string) error
- func (s *SessionService) ResetCronSchedules() error
- func (s *SessionService) ResetScheduledMessages(conversationID string) error
- func (s *SessionService) SaveAttachment(ctx context.Context, conversationID string, ...) error
- func (s *SessionService) ScheduledMessages() (map[string]protocol.ScheduledMessageState, error)
- func (s *SessionService) ScheduledMessagesForConversation(conversationID string) (map[string]protocol.ScheduledMessageState, error)
- func (s *SessionService) SetActiveTurnTerminal(ctx context.Context, turnID string, terminal protocol.Terminal) error
- func (s *SessionService) SetConversationSettled(ctx context.Context, conversationID string, settled bool) (bool, error)
- func (s *SessionService) SetPendingSteers(conversationID string, steers []protocol.PendingSteer) error
- func (s *SessionService) SetThreadAgentIfExists(conversationID, agent string) (bool, error)
- func (s *SessionService) SidebarSessions(ctx context.Context, autoSettleBefore time.Time) iter.Seq2[SidebarSession, error]
- func (s *SessionService) SlackChannelIDs(ctx context.Context) ([]string, error)
- func (s *SessionService) Stop() error
- func (s *SessionService) StopGoal(conversationID string) error
- func (s *SessionService) SyncCronSchedules(schedules []CronScheduleState, now time.Time) error
- func (s *SessionService) TakeMCPWaiter(id string) *protocol.InboundMessage
- func (s *SessionService) Thread(conversationID string) (ThreadState, bool, error)
- func (s *SessionService) ThreadQueueForConversation(conversationID string) ([]protocol.ThreadQueueItem, error)
- func (s *SessionService) TranscriptPage(ctx context.Context, conversationID string, before int64, limit int) (start, oldest int64, err error)
- func (s *SessionService) UpdateConversationDetails(ctx context.Context, conversationID string, pinned *bool, name *string, ...) (bool, error)
- func (s *SessionService) UpdateGoalStatus(conversationID, status, note string) (GoalState, error)
- func (s *SessionService) UpsertActiveTurn(ctx context.Context, checkpoint *harness.ActiveTurnCheckpoint, ...) error
- func (s *SessionService) UpsertExternalMCPSession(externalConversationID string, session *ExternalMCPSessionState) error
- func (s *SessionService) UpsertThread(conversationID string, thread ThreadState) error
- type SidebarSession
- type SlackFrontend
- type ThreadCreator
- type ThreadState
Constants ¶
const ( GoalStatusActive = "active" GoalStatusProgress = "progress" GoalStatusComplete = "complete" GoalStatusBlocked = "blocked" GoalStatusStopped = "stopped" GoalStatusBudgetExhausted = "budget_exhausted" )
GoalStatusActive and related constants are persisted goal-loop statuses.
const RawRunExposedToolName = rawRunToolName
RawRunExposedToolName is the tool cron prompts use for human-visible output.
Variables ¶
var ErrRestartRequested = errors.New("restart requested")
ErrRestartRequested indicates rocketclaw should exit so a supervisor can restart it.
Functions ¶
func ExternalMCPAgentsIn ¶
ExternalMCPAgentsIn returns agents externally selectable through MCP in runtimeDir.
func GenerateHandoff ¶ added in v0.1.3
func GenerateHandoff(ctx context.Context, cfg *config.Config, agent, transcript string) (document string, err error)
GenerateHandoff summarizes a snapshot without running tools or changing its session.
func IsBridgeStopped ¶
IsBridgeStopped reports whether err was caused by a stopped bridge.
func LoadRuntimeDefinitions ¶
func LoadRuntimeDefinitions(cfg *config.Config, runtimeDir string) (rocketcode.Agents, rocketcode.Skills, error)
LoadRuntimeDefinitions loads RocketCode definitions from runtimeDir without starting a run.
func OriginPairsFromEntry ¶ added in v0.1.0
func OriginPairsFromEntry(entry *rocketcode.SessionEntry) (map[string]string, bool)
OriginPairsFromEntry reads caller metadata pairs from a stored origin entry.
func ReplayDeliveryText ¶ added in v0.1.0
func ReplayDeliveryText(items []responses.ResponseInputItemUnionParam) (text string, index int, err error)
ReplayDeliveryText returns the last successful human-facing delivery and its call index.
func ReplayInputMessageRoleText ¶ added in v0.1.0
func ReplayInputMessageRoleText(item *responses.ResponseInputItemUnionParam, raw json.RawMessage) (role, text string, ok bool, err error)
ReplayInputMessageRoleText projects a stored message into its display role and text.
Types ¶
type ActiveTurnState ¶
type ActiveTurnState struct {
Checkpoint harness.ActiveTurnCheckpoint `json:"checkpoint"`
SourceMetadata map[string]string `json:"source_metadata,omitempty"`
PendingSteers []protocol.PendingSteer `json:"pending_steers,omitempty"`
CreatedAt time.Time `json:"created_at,omitzero"`
UpdatedAt time.Time `json:"updated_at,omitzero"`
Terminal protocol.Terminal `json:"terminal,omitempty"`
}
ActiveTurnState records one durable RocketCode active-turn checkpoint.
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge forwards rocketclaw messages into one turn-lived rocketcode run per turn.
func NewConversation ¶
func NewConversation(cfg *config.Config, publisher protocol.OutboundPublisher, bridgeCfg *Config, logger *slog.Logger) *Bridge
NewConversation constructs a rocketcode bridge for one conversation.
func (*Bridge) InterruptActiveTurn ¶
func (b *Bridge) InterruptActiveTurn() *protocol.InboundMessage
InterruptActiveTurn interrupts current work without discarding waiting work.
func (*Bridge) PickLaterWork ¶
PickLaterWork submits the next saved queue or due schedule for this conversation.
func (*Bridge) RecoverActiveTurn ¶
func (b *Bridge) RecoverActiveTurn(ctx context.Context, turn *ActiveTurnState) error
RecoverActiveTurn enqueues a startup recovery continuation for this conversation.
func (*Bridge) ResetScheduledMessages ¶
ResetScheduledMessages deletes pending scheduled prompts for this conversation.
func (*Bridge) ScheduleMessage ¶
ScheduleMessage schedules one delayed prompt for this conversation.
func (*Bridge) SwitchAgent ¶
SwitchAgent changes the agent used for future turns in this conversation.
type Config ¶
type Config struct {
ConversationID, Agent, AgentAfterRecovery, ManagedConversationID, ExternalConversationID string
RecoveringActiveTurn bool
RequestRestart func(string) (string, error)
RequestReload func(string) (string, error)
UserQuestionAsker protocol.UserQuestionAsker
StartNewThread func(context.Context, *protocol.StartNewThreadRequest) (protocol.StartNewThreadResult, error)
SessionService *SessionService
SteerDrain rocketcode.SteerDrain
EnqueueActivation EnqueueActivation
}
Config controls one rocketcode bridge conversation.
type CronScheduleState ¶
CronScheduleState records one observed scheduled cron trigger.
type EnqueueActivation ¶
type EnqueueActivation struct {
Fn func(context.Context, *protocol.ThreadQueueItem, *protocol.InboundMessage) error
}
EnqueueActivation posts the consume card for a popped Enqueued Slack Message. The zero value is inert.
func (EnqueueActivation) Activate ¶
func (a EnqueueActivation) Activate(ctx context.Context, item *protocol.ThreadQueueItem, inbound *protocol.InboundMessage) error
Activate runs the consume-card hook, or does nothing when the hook is unset.
type ExternalMCPSessionState ¶
type ExternalMCPSessionState struct {
Agent string `json:"agent,omitempty"`
PrivateConversationID string `json:"private_conversation_id,omitempty"`
ManagedConversationID string `json:"managed_conversation_id,omitempty"`
SlackChannel string `json:"slack_channel,omitempty"`
}
ExternalMCPSessionState binds an external MCP conversation ID to private and managed sessions.
type FrontendAssembler ¶ added in v0.1.0
type FrontendAssembler interface {
Assemble(*Runtime) (SlackFrontend, <-chan struct{}, []func(context.Context) error, error)
ValidateAssets(*config.Config, string, []string) error
}
FrontendAssembler constructs Slack and MCP frontends for a running backend.
type GoalState ¶
type GoalState struct {
Objective string `json:"objective,omitempty"`
CheckScript string `json:"check_script,omitempty"`
MaxTurns int `json:"max_turns,omitempty"`
TurnsUsed int `json:"turns_used,omitempty"`
Status string `json:"status,omitempty"`
Note string `json:"note,omitempty"`
SlackRecipientTeamID string `json:"slack_recipient_team_id,omitempty"`
SlackRecipientUserID string `json:"slack_recipient_user_id,omitempty"`
CreatedAt time.Time `json:"created_at,omitzero"`
UpdatedAt time.Time `json:"updated_at,omitzero"`
}
GoalState records one active or terminal managed-thread goal loop.
type KeyedConversationLocks ¶
type KeyedConversationLocks struct {
// contains filtered or unexported fields
}
KeyedConversationLocks serializes work per conversation id.
func NewKeyedConversationLocks ¶
func NewKeyedConversationLocks() *KeyedConversationLocks
NewKeyedConversationLocks constructs an empty lock set.
func (*KeyedConversationLocks) Lock ¶
func (l *KeyedConversationLocks) Lock(key string) func()
Lock serializes one conversation id and returns the unlock function.
type ObservedSessionEntry ¶
type ObservedSessionEntry struct {
ID int64
Entry harness.SessionEntry
Key string
Revision string
// SourceConversationID identifies the surviving source row of a synced entry.
SourceConversationID string
Synced bool
Active bool
Terminal protocol.Terminal
}
ObservedSessionEntry carries saved or checkpoint metadata and an optional payload.
type PruneStateStats ¶
PruneStateStats reports how much stale persisted state was removed.
type RawRunProgress ¶
type RawRunProgress struct {
ConversationID string
SyncDestination string
Cronjob *protocol.CronjobMessage
TextChannel string
}
RawRunProgress carries the conversation and Slack destination for one cron run.
type Runtime ¶
type Runtime struct {
Cfg *config.Config
Log *slog.Logger
RunCtx context.Context
Sessions *SessionService
ExternalMCPUsers map[string]string
RefreshExternalMCPAgents *func() error
TextRouter protocol.PrimaryTextRouter
// contains filtered or unexported fields
}
Runtime is the backend after construction, before frontends.
func (*Runtime) AttachSlack ¶
func (r *Runtime) AttachSlack(slack SlackFrontend)
AttachSlack hooks originator Slack methods into backend thread state.
func (*Runtime) CreateConversation ¶ added in v0.1.0
CreateConversation records an explicit ID without changing existing selection.
func (*Runtime) DeleteQueueItem ¶ added in v0.1.0
DeleteQueueItem drops one waiting steer or enqueue so it never runs.
func (*Runtime) ListConversations ¶ added in v0.1.0
func (r *Runtime) ListConversations(ctx context.Context) (conversations []protocol.Conversation, err error)
ListConversations returns recorded conversations, never discovered pair IDs.
func (*Runtime) PopQueueItem ¶ added in v0.1.0
PopQueueItem releases held work at the end of the ordinary queue.
func (*Runtime) PromoteQueueItem ¶ added in v0.1.0
PromoteQueueItem claims one persisted enqueue and submits it as a steer, keeping its principal.
func (*Runtime) PublishOutbound ¶ added in v0.1.0
PublishOutbound completes delivery through live consumers, never a private request response stream. Each consumer receives an independent rendering copy.
func (*Runtime) QueueItems ¶ added in v0.1.0
func (r *Runtime) QueueItems(conversationID string) ([]protocol.ThreadQueueItem, error)
QueueItems returns persisted waiting work plus uninjected active steers.
func (*Runtime) ReorderQueueItems ¶ added in v0.1.0
ReorderQueueItems writes persisted enqueue positions in the given ID order.
func (*Runtime) RunTurn ¶ added in v0.1.0
RunTurn waits for the submitted work's processing and terminal handling.
func (*Runtime) StartGoal ¶ added in v0.1.12
func (r *Runtime) StartGoal(ctx context.Context, inbound *protocol.InboundMessage, goal protocol.GoalRequest) error
StartGoal records an active goal on a recorded conversation and submits its first turn without waiting for the goal loop.
func (*Runtime) StashQueueItem ¶ added in v0.1.0
func (r *Runtime) StashQueueItem(ctx context.Context, conversationID string, item *protocol.ThreadQueueItem) error
StashQueueItem persists waiting work and offers it to the conversation bridge.
func (*Runtime) Subscribe ¶ added in v0.1.0
Subscribe registers a live-only event consumer. History is read separately.
func (*Runtime) SwitchConversationAgent ¶ added in v0.1.0
SwitchConversationAgent persists selection and updates the existing live bridge. Frontends validate their current human/producer policy before calling it.
func (*Runtime) SyncConversation ¶ added in v0.1.0
SyncConversation exposes surviving source work in an existing destination. The producer's own occupancy is not a competing destination turn.
func (*Runtime) WorkflowDescriptions ¶ added in v0.1.12
func (r *Runtime) WorkflowDescriptions() (descriptions []protocol.WorkflowDescription, err error)
WorkflowDescriptions lists the saved workflows a human can start with $workflow.
type SessionService ¶
type SessionService struct {
// contains filtered or unexported fields
}
SessionService owns runtime PostgreSQL session and state access inside one rocketclaw process.
func NewSessionServiceIn ¶
func NewSessionServiceIn(ctx context.Context, cfg *config.Config, logger *slog.Logger) (*SessionService, error)
NewSessionServiceIn starts a runtime-owned PostgreSQL session service.
func (*SessionService) AccountGoalTurn ¶
func (s *SessionService) AccountGoalTurn(conversationID string) (GoalState, bool, error)
AccountGoalTurn increments one active goal turn and applies budget exhaustion.
func (*SessionService) ActiveGoalThreads ¶
func (s *SessionService) ActiveGoalThreads() (map[string]ThreadState, error)
ActiveGoalThreads returns managed thread state for conversations with active goals.
func (*SessionService) ActiveGoals ¶
func (s *SessionService) ActiveGoals() (map[string]GoalState, error)
ActiveGoals returns persisted active goals keyed by conversation ID.
func (*SessionService) AppendEntryID ¶
func (s *SessionService) AppendEntryID(ctx context.Context, conversationID string, entry *harness.SessionEntry) (int64, error)
AppendEntryID appends one entry through the runtime service and returns its row ID.
func (*SessionService) ApplyPendingRestartNotifications ¶
func (s *SessionService) ApplyPendingRestartNotifications(ctx context.Context) error
ApplyPendingRestartNotifications appends one developer notice to pending requester sessions.
func (*SessionService) AttachmentMetadata ¶ added in v0.1.0
func (s *SessionService) AttachmentMetadata(ctx context.Context, conversationID, id string, uploadOnly bool) (protocol.OutboundAttachment, error)
AttachmentMetadata loads stored metadata without transferring the file bytes. Callers must authorize the reference within its producer scope.
func (*SessionService) BeginGoal ¶
func (s *SessionService) BeginGoal(conversationID, objective, checkScript string, maxTurns int, recipientTeamID, recipientUserID string) error
BeginGoal records a new active goal for a managed conversation.
func (*SessionService) Changes ¶ added in v0.1.12
func (s *SessionService) Changes(ctx context.Context, conversationID string) iter.Seq2[protocol.ConversationChange, error]
Changes registers before yielding an initial refresh, then waits for committed changes to this conversation. Breaking iteration or cancelling ctx discards the listening connection rather than returning LISTEN state to the pool.
func (*SessionService) ChannelFact ¶ added in v0.1.0
func (s *SessionService) ChannelFact(ctx context.Context, workspaceID, channelID string) (name string, found bool, err error)
ChannelFact returns a stored Slack name, never derived channel policy.
func (*SessionService) ClaimCronSchedule ¶
func (s *SessionService) ClaimCronSchedule(due CronScheduleState, nextDue, now time.Time) (relativePath string, claimed bool, err error)
ClaimCronSchedule verifies one due scheduled cron trigger and records per-file running state.
func (*SessionService) ClaimScheduledMessage ¶
func (s *SessionService) ClaimScheduledMessage(id, conversationID string, dueAt, now time.Time) (message protocol.ScheduledMessageState, claimed bool, err error)
ClaimScheduledMessage verifies one due scheduled message and advances recurring messages atomically.
func (*SessionService) ClearActiveTurn ¶
func (s *SessionService) ClearActiveTurn(ctx context.Context, turnID string) error
ClearActiveTurn removes an active root-turn checkpoint.
func (*SessionService) CompleteCronRun ¶
func (s *SessionService) CompleteCronRun(relativePath string, now time.Time) error
CompleteCronRun clears per-file scheduled cron running state.
func (*SessionService) Delegations ¶ added in v0.1.11
func (s *SessionService) Delegations(ctx context.Context, conversationID, sourceConversationID string, from, before int64) ([]string, error)
Delegations returns saved direct child histories referenced by this transcript, including unchanged entries omitted from a delta's readable payloads. Only saved entries in [from, before) count; zero before means no upper bound and includes checkpoints, matching ObserveTranscript.
func (*SessionService) DeleteScheduledMessage ¶
func (s *SessionService) DeleteScheduledMessage(id string) error
DeleteScheduledMessage deletes one scheduled message.
func (*SessionService) DeleteSession ¶ added in v0.1.0
DeleteSession removes all entries for one conversation ID and returns deleted rows.
func (*SessionService) DeleteThreadQueueItem ¶
func (s *SessionService) DeleteThreadQueueItem(id string) error
DeleteThreadQueueItem deletes one Enqueued Slack Message.
func (*SessionService) DueCronSchedules ¶
func (s *SessionService) DueCronSchedules(now time.Time) ([]CronScheduleState, error)
DueCronSchedules returns observed scheduled cron definitions due at now.
func (*SessionService) ExternalMCPSession ¶
func (s *SessionService) ExternalMCPSession(externalConversationID string) (ExternalMCPSessionState, bool, error)
ExternalMCPSession returns a persisted external MCP session mapping.
func (*SessionService) ExternalMCPSessionByConversationID ¶
func (s *SessionService) ExternalMCPSessionByConversationID(conversationID string) (externalConversationID string, session ExternalMCPSessionState, ok bool, err error)
ExternalMCPSessionByConversationID returns the public ID and binding for either session ID.
func (*SessionService) ForkConversation ¶ added in v0.1.3
func (s *SessionService) ForkConversation(ctx context.Context, source string, destination protocol.Conversation, before string) (string, error)
ForkConversation copies a recorded prefix and returns the excluded user prompt. OpenCode V2: packages/app/src/session/commands/fork-dialog.tsx uses an exclusive message boundary; packages/tui/src/routes/session/dialog-fork.tsx also allows all.
func (*SessionService) Goal ¶
func (s *SessionService) Goal(conversationID string) (GoalState, bool, error)
Goal returns the persisted goal state for a conversation.
func (*SessionService) ListSessions ¶ added in v0.1.0
func (s *SessionService) ListSessions(ctx context.Context, conversationIDs []string) ([]protocol.SessionSummary, error)
ListSessions returns summaries for the requested stored rocketcode sessions.
func (*SessionService) LoadAttachment ¶ added in v0.1.0
func (s *SessionService) LoadAttachment(ctx context.Context, conversationID, id string, uploadOnly bool) (protocol.OutboundAttachment, error)
LoadAttachment requires the producer scope; callers must authorize its reference. uploadOnly restricts prompt consumption to files acquired through upload.
func (*SessionService) MarkRestartRequester ¶
func (s *SessionService) MarkRestartRequester(ctx context.Context, conversationID string) error
MarkRestartRequester records that conversationID should see the post-restart notice.
func (*SessionService) ObserveEntries ¶
func (s *SessionService) ObserveEntries(ctx context.Context, conversationID string) ([]ObservedSessionEntry, error)
ObserveEntries loads observed session entries through the runtime service.
func (*SessionService) ObserveTranscript ¶ added in v0.1.12
func (s *SessionService) ObserveTranscript(ctx context.Context, conversationID string, from, before int64, revisions map[string]string) ([]ObservedSessionEntry, error)
ObserveTranscript returns the ordered inventory from one database snapshot, with payloads only for keys whose fingerprints differ from revisions. Nil revisions requests all payloads. A saved logical turn supersedes its checkpoint. Turn keys are producer-scoped and stable across checkpoint completion. Checkpoints stay after the saved row visible when first persisted, preserving ID order. Rows are limited to positions in [from, before); zero before means no upper bound and also includes every running checkpoint. Positive before reads a settled page, so running checkpoints are excluded. Source attribution matches ObserveEntries; authorization belongs to the caller. Fingerprints describe readable content, not the transaction IDs yielded by Changes.
func (*SessionService) OriginPairs ¶ added in v0.1.12
func (s *SessionService) OriginPairs(ctx context.Context, conversationID string) (map[string]string, error)
OriginPairs reads only the initial caller metadata, never the producer transcript.
func (*SessionService) PairBusyFor ¶
func (s *SessionService) PairBusyFor(pairID string) bool
PairBusyFor reports whether pairID is reserved or holding a turn.
func (*SessionService) PruneStateBefore ¶
func (s *SessionService) PruneStateBefore(ctx context.Context, cutoff time.Time) (PruneStateStats, error)
PruneStateBefore removes expired thread and external-session state.
func (*SessionService) PutMCPWaiter ¶
func (s *SessionService) PutMCPWaiter(id string, inbound *protocol.InboundMessage)
PutMCPWaiter records an MCP turn waiting on a later-work queue row.
func (*SessionService) PutScheduledMessage ¶
func (s *SessionService) PutScheduledMessage(id string, message *protocol.ScheduledMessageState) error
PutScheduledMessage persists one scheduled message.
func (*SessionService) PutThreadQueueItem ¶
func (s *SessionService) PutThreadQueueItem(id string, item *protocol.ThreadQueueItem) error
PutThreadQueueItem persists one Enqueued Slack Message.
func (*SessionService) RecordChannelFact ¶ added in v0.1.0
func (s *SessionService) RecordChannelFact(ctx context.Context, workspaceID, channelID, name string, observedAt time.Time) error
RecordChannelFact keeps the newest observation. Nanoseconds preserve ordering even when a lookup and rename occur within one PostgreSQL timestamp microsecond.
func (*SessionService) RecoverableActiveTurns ¶
func (s *SessionService) RecoverableActiveTurns(ctx context.Context) ([]ActiveTurnState, error)
RecoverableActiveTurns returns remaining active-turn handoff rows for startup recovery.
func (*SessionService) RegisterExternalMCPConversation ¶
func (s *SessionService) RegisterExternalMCPConversation(externalConversationID, managedAgent string, session *ExternalMCPSessionState) error
RegisterExternalMCPConversation atomically persists a managed conversation and its public binding.
func (*SessionService) ReleaseExternalMCPRecovery ¶
func (s *SessionService) ReleaseExternalMCPRecovery(conversationID string) error
ReleaseExternalMCPRecovery releases paired work after recovery is abandoned.
func (*SessionService) RemoveExternalMCPConversation ¶
func (s *SessionService) RemoveExternalMCPConversation(externalConversationID string) error
RemoveExternalMCPConversation removes a failed newly-created conversation and all of its durable state.
func (*SessionService) ReplayAttachments ¶ added in v0.1.0
func (s *SessionService) ReplayAttachments(ctx context.Context, conversationID string, root *os.Root, raw json.RawMessage, calls map[string]string) ([]protocol.OutboundAttachment, error)
ReplayAttachments resolves metadata for successful attach-tool output, never arbitrary paths. calls belongs to one producer and survives entry boundaries during history projection.
func (*SessionService) ReserveExternalMCPRecovery ¶
func (s *SessionService) ReserveExternalMCPRecovery(conversationID string) error
ReserveExternalMCPRecovery makes paired work wait for the recovering owner.
func (*SessionService) ResetCronSchedules ¶
func (s *SessionService) ResetCronSchedules() error
ResetCronSchedules clears scheduled cron state at daemon observation start.
func (*SessionService) ResetScheduledMessages ¶
func (s *SessionService) ResetScheduledMessages(conversationID string) error
ResetScheduledMessages deletes pending scheduled messages for one conversation.
func (*SessionService) SaveAttachment ¶ added in v0.1.0
func (s *SessionService) SaveAttachment(ctx context.Context, conversationID string, attachment *protocol.OutboundAttachment, upload bool) error
SaveAttachment stores immutable original bytes before publishing a reference.
func (*SessionService) ScheduledMessages ¶
func (s *SessionService) ScheduledMessages() (map[string]protocol.ScheduledMessageState, error)
ScheduledMessages returns all persisted scheduled messages.
func (*SessionService) ScheduledMessagesForConversation ¶
func (s *SessionService) ScheduledMessagesForConversation(conversationID string) (map[string]protocol.ScheduledMessageState, error)
ScheduledMessagesForConversation returns persisted scheduled messages for one conversation.
func (*SessionService) SetActiveTurnTerminal ¶ added in v0.1.12
func (s *SessionService) SetActiveTurnTerminal(ctx context.Context, turnID string, terminal protocol.Terminal) error
SetActiveTurnTerminal retains a failed or stopped checkpoint for observation while preventing startup recovery from resuming it.
func (*SessionService) SetConversationSettled ¶ added in v0.1.0
func (s *SessionService) SetConversationSettled(ctx context.Context, conversationID string, settled bool) (bool, error)
SetConversationSettled changes only the recorded conversation's sidebar state.
func (*SessionService) SetPendingSteers ¶
func (s *SessionService) SetPendingSteers(conversationID string, steers []protocol.PendingSteer) error
SetPendingSteers copies uninjected Slack Steers onto the conversation's active-turn row.
func (*SessionService) SetThreadAgentIfExists ¶
func (s *SessionService) SetThreadAgentIfExists(conversationID, agent string) (bool, error)
SetThreadAgentIfExists updates a managed conversation agent without creating a thread.
func (*SessionService) SidebarSessions ¶ added in v0.1.0
func (s *SessionService) SidebarSessions(ctx context.Context, autoSettleBefore time.Time) iter.Seq2[SidebarSession, error]
SidebarSessions yields pinned records first, then recent-first, bytewise-ID order. Conversations without stored history are omitted until their first entry arrives. Inactive, non-running, unpinned conversations settle at the supplied cutoff; manual reopening grants a fresh inactivity window without changing message timestamps. Breaking iteration or cancelling ctx closes the database rows.
func (*SessionService) SlackChannelIDs ¶ added in v0.1.0
func (s *SessionService) SlackChannelIDs(ctx context.Context) ([]string, error)
SlackChannelIDs lists the distinct channels of recorded managed Slack threads.
func (*SessionService) Stop ¶
func (s *SessionService) Stop() error
Stop closes the runtime service and its database handle.
func (*SessionService) StopGoal ¶
func (s *SessionService) StopGoal(conversationID string) error
StopGoal marks an active goal stopped.
func (*SessionService) SyncCronSchedules ¶
func (s *SessionService) SyncCronSchedules(schedules []CronScheduleState, now time.Time) error
SyncCronSchedules replaces observed scheduled cron definitions.
func (*SessionService) TakeMCPWaiter ¶
func (s *SessionService) TakeMCPWaiter(id string) *protocol.InboundMessage
TakeMCPWaiter removes and returns the MCP waiter for a queue row.
func (*SessionService) Thread ¶
func (s *SessionService) Thread(conversationID string) (ThreadState, bool, error)
Thread returns the persisted managed conversation state.
func (*SessionService) ThreadQueueForConversation ¶
func (s *SessionService) ThreadQueueForConversation(conversationID string) ([]protocol.ThreadQueueItem, error)
ThreadQueueForConversation returns Enqueued Slack Messages in stack order.
func (*SessionService) TranscriptPage ¶ added in v0.1.12
func (s *SessionService) TranscriptPage(ctx context.Context, conversationID string, before int64, limit int) (start, oldest int64, err error)
TranscriptPage returns the saved-entry ID that starts the newest limit entries before (zero for no bound), or zero when fewer exist, and the conversation's oldest saved-entry ID, which changes only when history is cleared.
func (*SessionService) UpdateConversationDetails ¶ added in v0.1.0
func (s *SessionService) UpdateConversationDetails(ctx context.Context, conversationID string, pinned *bool, name *string, snoozedUntil *time.Time) (bool, error)
UpdateConversationDetails changes shared display metadata without touching history. Nil fields are left unchanged; snoozing replaces explicit settlement.
func (*SessionService) UpdateGoalStatus ¶
func (s *SessionService) UpdateGoalStatus(conversationID, status, note string) (GoalState, error)
UpdateGoalStatus records a model-controlled goal status update.
func (*SessionService) UpsertActiveTurn ¶
func (s *SessionService) UpsertActiveTurn(ctx context.Context, checkpoint *harness.ActiveTurnCheckpoint, sourceMetadata map[string]string) error
UpsertActiveTurn records a RocketCode active-turn restart handoff checkpoint with source metadata.
func (*SessionService) UpsertExternalMCPSession ¶
func (s *SessionService) UpsertExternalMCPSession(externalConversationID string, session *ExternalMCPSessionState) error
UpsertExternalMCPSession records an external MCP conversation ID mapping.
func (*SessionService) UpsertThread ¶
func (s *SessionService) UpsertThread(conversationID string, thread ThreadState) error
UpsertThread records or updates a text-thread bridge entry.
type SidebarSession ¶ added in v0.1.0
type SidebarSession struct {
Conversation protocol.Conversation
Summary *protocol.SessionSummary
Running bool
Pinned bool
Name string
SnoozedUntil *time.Time
ForkedFrom string
Tags []string
}
SidebarSession combines a recorded conversation with its optional durable summary.
type SlackFrontend ¶
type SlackFrontend interface {
Start(context.Context) error
Stop(context.Context) error
StartNewThreadRoot(context.Context, *protocol.StartNewThreadRequest) (protocol.StartNewThreadRootResult, error)
AskUserQuestion(context.Context, *protocol.AskUserQuestionRequest) (protocol.AskUserQuestionAnswer, error)
DrainSteers(context.Context, string) []string
ActivateEnqueue(context.Context, *protocol.ThreadQueueItem, *protocol.InboundMessage) error
SetPendingSteersSink(protocol.PendingSteersSink)
RestorePendingSteers(string, []protocol.PendingSteer)
DiscardPendingSteers(context.Context, []protocol.PendingSteer)
}
SlackFrontend is the Slack surface cmd constructs.
type ThreadCreator ¶
type ThreadCreator string
ThreadCreator records which subsystem created a managed text conversation.
const ThreadCreatedByCron ThreadCreator = "cron"
ThreadCreatedByCron marks managed conversations created for cron output.
type ThreadState ¶
type ThreadState struct {
Agent string `json:"agent,omitempty"`
CreatedBy ThreadCreator `json:"created_by,omitempty"`
Settled bool `json:"settled,omitempty"`
}
ThreadState is the persisted state for one text-thread bridge.
Source Files
¶
- app.go
- attachment_storage.go
- attachments.go
- bridge.go
- conversation_locks.go
- conversations.go
- dynamic_workflow_tool.go
- fork.go
- goal_check.go
- handoff.go
- instrumentation.go
- model_resolver.go
- observability.go
- provider_replay.go
- raw_run.go
- runtime.go
- session_tools.go
- startup_recovery.go
- store.go
- store_dao.go
- store_schema.go
- store_summaries.go
- thread_bridges.go
- transcript.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package harnessbridgetest holds test helpers for backend.
|
Package harnessbridgetest holds test helpers for backend. |