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 LoadRuntimeDefinitions(cfg *config.Config, runtimeDir string) (rocketcode.Agents, rocketcode.Skills, error)
- 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 Bridge
- func (b *Bridge) InterruptActiveTurn() *protocol.InboundMessage
- func (b *Bridge) PickLaterWork(ctx context.Context) error
- func (b *Bridge) ResetScheduledMessages() error
- func (b *Bridge) Run(ctx context.Context) error
- func (b *Bridge) ScheduleMessage(delay time.Duration, message string, recurring bool) error
- func (b *Bridge) Stop() error
- func (b *Bridge) Submit(ctx context.Context, msg *protocol.InboundMessage) error
- func (b *Bridge) SwitchAgent(agent string)
- type ChatOriginFacts
- type Config
- type CronScheduleState
- type EnqueueActivation
- type ExternalMCPSessionState
- type FrontendAssembler
- type GoalState
- type HistoryInventory
- type HistorySnapshot
- type KeyedConversationLocks
- type ObservedSessionEntry
- type PruneStateStats
- type RawRunProgress
- type Runtime
- func (r *Runtime) AttachSlack(slack SlackFrontend)
- func (r *Runtime) ClearRevert(ctx context.Context, conversationID string) error
- 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) StageRevert(ctx context.Context, conversationID, before string) (marker, prompt string, err 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) 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) ChatOriginFacts(ctx context.Context, id string) iter.Seq2[ChatOriginFacts, 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) CompleteCronRun(relativePath string, now time.Time) error
- func (s *SessionService) Delegations(ctx context.Context, conversationID, sourceConversationID string, ...) ([]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) HasActiveTurn(ctx context.Context, conversationID string) (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) LoadTurnStep(ctx context.Context, conversationID, key string) (value json.RawMessage, found bool, err error)
- func (s *SessionService) ObserveEntries(ctx context.Context, conversationID string) ([]ObservedSessionEntry, error)
- func (s *SessionService) ObserveHistory(ctx context.Context, id, source string, from, before int64, limit int, ...) (view HistorySnapshot, err error)
- func (s *SessionService) ObserveTranscript(ctx context.Context, conversationID string, from, before int64, ...) ([]ObservedSessionEntry, error)
- func (s *SessionService) PairBusyFor(pairID string) bool
- func (s *SessionService) PruneStateBefore(ctx context.Context, cutoff time.Time) (PruneStateStats, error)
- 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) RegisterExternalMCPConversation(externalConversationID, managedAgent string, session *ExternalMCPSessionState) 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) ResetCronSchedules() error
- func (s *SessionService) ResetScheduledMessages(conversationID string) error
- func (s *SessionService) RevertAttachmentMetadata(ctx context.Context, conversationID, id string) (protocol.OutboundAttachment, error)
- func (s *SessionService) RevertState(ctx context.Context, conversationID string) (marker string, eligible bool, predecessor string, err error)
- func (s *SessionService) SaveAttachment(ctx context.Context, conversationID string, ...) error
- func (s *SessionService) SaveTurnStep(ctx context.Context, conversationID, key string, value json.RawMessage) error
- func (s *SessionService) ScheduledMessages() (map[string]protocol.ScheduledMessageState, error)
- func (s *SessionService) ScheduledMessagesForConversation(conversationID string) (map[string]protocol.ScheduledMessageState, error)
- func (s *SessionService) SetConversationSettled(ctx context.Context, conversationID string, settled bool) (bool, 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) 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) 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 LoadRuntimeDefinitions ¶
func LoadRuntimeDefinitions(cfg *config.Config, runtimeDir string) (rocketcode.Agents, rocketcode.Skills, error)
LoadRuntimeDefinitions loads RocketCode definitions from runtimeDir without starting a run.
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 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) ResetScheduledMessages ¶
ResetScheduledMessages deletes pending scheduled prompts for this conversation.
func (*Bridge) Run ¶ added in v0.1.14
Run handles the conversation's unfinished active turn, then its requests, until ctx is canceled or the bridge stops.
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 ChatOriginFacts ¶ added in v0.1.14
type ChatOriginFacts struct {
ConversationID string
CreatedBy ThreadCreator
ExternalConversationID string
Binding ExternalMCPSessionState
// CreatingSource is the creating entry's source conversation, attributed as ObserveTranscript does.
CreatingSource string
// ProducerAgent is the agent of the cron run that may have created the conversation.
ProducerAgent string
}
ChatOriginFacts are the stored facts that decide a conversation's chat origin.
type Config ¶
type Config struct {
ConversationID, Agent, ManagedConversationID, ExternalConversationID string
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"`
OriginPairs map[string]string `json:"origin_pairs,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 HistoryInventory ¶ added in v0.1.17
type HistoryInventory struct {
ConversationID string `json:"conversation_id"`
Source string `json:"source"`
Entries map[string]string `json:"entries"`
From int64 `json:"from,omitempty"`
Oldest int64 `json:"oldest,omitempty"`
Marker string `json:"revert_message_id,omitempty"`
}
HistoryInventory follows a stateless saved-entry view, not an event cursor.
type HistorySnapshot ¶ added in v0.1.17
type HistorySnapshot struct {
Inventory HistoryInventory
Entries []ObservedSessionEntry
Delegations []string
Eligible bool
Predecessor string
Reset bool
}
HistorySnapshot keeps cutoff, page bounds, payloads and delegation links coherent.
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) ClearRevert ¶ added in v0.1.17
ClearRevert restores the whole suffix without changing any viewer's draft.
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) StageRevert ¶ added in v0.1.17
func (r *Runtime) StageRevert(ctx context.Context, conversationID, before string) (marker, prompt string, err error)
StageRevert settles the recorded bridge before changing its cutoff. Like packages/app/src/session/revert.ts, interruption is not effect rollback.
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) 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) ChatOriginFacts ¶ added in v0.1.14
func (s *SessionService) ChatOriginFacts(ctx context.Context, id string) iter.Seq2[ChatOriginFacts, error]
ChatOriginFacts yields, in one query, origin facts for every conversation people may see: cron runs and private External MCP conversations are omitted. The creating entry is read only where it can decide the origin: not for Slack threads cron did not create, nor for web:cron: and web:one-off-cron: chats, whose ID names the run. A nonempty id restricts the inventory to that conversation.
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) 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) 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) HasActiveTurn ¶ added in v0.1.14
HasActiveTurn reports whether the conversation has a running or undelivered turn.
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) LoadTurnStep ¶ added in v0.1.14
func (s *SessionService) LoadTurnStep(ctx context.Context, conversationID, key string) (value json.RawMessage, found bool, err error)
LoadTurnStep returns one recorded step of a conversation's turns.
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) ObserveHistory ¶ added in v0.1.17
func (s *SessionService) ObserveHistory(ctx context.Context, id, source string, from, before int64, limit int, previous HistoryInventory) (view HistorySnapshot, err error)
ObserveHistory reads every part of a followed view from one database snapshot.
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) 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) 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) RegisterExternalMCPConversation ¶
func (s *SessionService) RegisterExternalMCPConversation(externalConversationID, managedAgent string, session *ExternalMCPSessionState) error
RegisterExternalMCPConversation atomically persists a managed conversation and its public binding.
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) 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) RevertAttachmentMetadata ¶ added in v0.1.17
func (s *SessionService) RevertAttachmentMetadata(ctx context.Context, conversationID, id string) (protocol.OutboundAttachment, error)
RevertAttachmentMetadata authorizes only an upload referenced by the current staged user boundary. It never exposes the rest of the hidden replay.
func (*SessionService) RevertState ¶ added in v0.1.17
func (s *SessionService) RevertState(ctx context.Context, conversationID string) (marker string, eligible bool, predecessor string, err error)
RevertState reports the durable cutoff and capability from physical origin facts. Empty effective history must not erase a conversation's origin.
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) SaveTurnStep ¶ added in v0.1.14
func (s *SessionService) SaveTurnStep(ctx context.Context, conversationID, key string, value json.RawMessage) error
SaveTurnStep records one step of a conversation's turns; the turn's finish removes it.
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) 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) 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) 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) 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
SendCronjobRoot(context.Context, *protocol.OutboundMessage) (protocol.TextConversationTarget, error)
AskUserQuestion(context.Context, *protocol.AskUserQuestionRequest) (protocol.AskUserQuestionAnswer, error)
DrainSteers(context.Context, string) []string
ActivateEnqueue(context.Context, *protocol.ThreadQueueItem, *protocol.InboundMessage) error
}
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
- health.go
- history.go
- instrumentation.go
- model_resolver.go
- observability.go
- provider_replay.go
- raw_run.go
- revert.go
- runtime.go
- session_tools.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. |