Documentation
¶
Overview ¶
Package harnessbridge owns the rocketcode library bridge.
Index ¶
- Constants
- Variables
- func AppendSessionEntryID(ctx context.Context, dbPath, conversationID string, ...) (int64, error)
- func DeleteSession(ctx context.Context, workspace, conversationID string) (int64, error)
- func DeleteSessionIn(ctx context.Context, workspace, workDir, conversationID string) (int64, error)
- func DiscordResponseCheckpointKey(channelID, messageID string) string
- func DiscordThreadConversationID(threadID string) string
- func ExternalMCPAgents(workspace string) ([]string, error)
- func ExternalMCPAgentsIn(workspace, workDir string) ([]string, error)
- func RecoverSessionDBIfCorrupt(ctx context.Context, workspace, workDir string) (bool, error)
- func SessionDBPath(workspace string) string
- func SessionDBPathIn(workspace, workDir string) string
- func SlackResponseCheckpointKey(channelID, messageTS string) string
- func SlackThreadConversationID(channelID, threadTS string) string
- type Bridge
- func (b *Bridge) ResetScheduledMessages() error
- func (b *Bridge) ScheduleMessage(delay time.Duration, message string, recurring bool) error
- func (b *Bridge) SeedResponseThread(ctx context.Context, checkpoint events.ResponseCheckpoint, _ string) error
- func (b *Bridge) SeedThreadFromCron(ctx context.Context, seedText string) error
- func (b *Bridge) SeedThreadFromMain(ctx context.Context) error
- func (b *Bridge) Start(ctx context.Context) error
- func (b *Bridge) Stop() error
- func (b *Bridge) Submit(ctx context.Context, msg *events.InboundMessage) error
- func (b *Bridge) Summarize(ctx context.Context, prompt string) (string, error)
- func (b *Bridge) WaitIdle(ctx context.Context) error
- type Config
- type ExternalMCPSessionState
- type ObservedSessionEntry
- type PruneStateStats
- type RawRunProgress
- type RawRunResult
- type ResponseCheckpointState
- type ScheduledMessageState
- type SessionService
- 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) CheckpointWAL(ctx context.Context) (WALCheckpointStats, error)
- func (s *SessionService) Load() (State, error)
- func (s *SessionService) MarkRestartRequester(ctx context.Context, conversationID string) error
- func (s *SessionService) MarkThreadSeeded(conversationID, seedKey string) error
- func (s *SessionService) ObserveEntries(ctx context.Context, conversationID string, lastID int64) ([]ObservedSessionEntry, error)
- func (s *SessionService) PruneStateBefore(ctx context.Context, cutoff time.Time) (PruneStateStats, error)
- func (s *SessionService) Stop(context.Context) error
- func (s *SessionService) UpsertExternalMCPSession(externalConversationID string, session ExternalMCPSessionState) error
- func (s *SessionService) UpsertResponseCheckpoint(key string, checkpoint ResponseCheckpointState) error
- func (s *SessionService) UpsertThread(conversationID, agent string) error
- func (s *SessionService) Vacuum(ctx context.Context) (VacuumStats, error)
- type SessionSummary
- type State
- type StateStoreLock
- type ThreadState
- type VacuumStats
- type WALCheckpointStats
Constants ¶
const RawRunExposedToolName = rawRunToolName
RawRunExposedToolName is the tool cron prompts use for human-visible output.
Variables ¶
var ErrStateStoreLocked = errors.New("rocketclaw state store is locked")
ErrStateStoreLocked reports that another RocketClaw process owns the state store.
Functions ¶
func AppendSessionEntryID ¶
func AppendSessionEntryID(ctx context.Context, dbPath, conversationID string, entry *harness.SessionEntry) (int64, error)
AppendSessionEntryID appends one replayable turn and returns its SQLite row ID.
func DeleteSession ¶
DeleteSession removes all entries for one conversation ID and returns deleted rows.
func DeleteSessionIn ¶
DeleteSessionIn removes all entries for one conversation ID in workDir and returns deleted rows.
func DiscordResponseCheckpointKey ¶
DiscordResponseCheckpointKey returns the stable key for one posted Discord AI response message.
func DiscordThreadConversationID ¶
DiscordThreadConversationID returns the stable conversation ID for a Discord thread.
func ExternalMCPAgents ¶
ExternalMCPAgents returns agents externally selectable through MCP.
func ExternalMCPAgentsIn ¶
ExternalMCPAgentsIn returns agents externally selectable through MCP in workDir.
func RecoverSessionDBIfCorrupt ¶
RecoverSessionDBIfCorrupt recovers a corrupt existing state DB before daemon startup proceeds.
func SessionDBPath ¶
SessionDBPath returns the SQLite database path for rocketcode session inspection.
func SessionDBPathIn ¶
SessionDBPathIn returns the SQLite database path for rocketcode session inspection in workDir.
func SlackResponseCheckpointKey ¶
SlackResponseCheckpointKey returns the stable key for one posted Slack AI response message.
func SlackThreadConversationID ¶
SlackThreadConversationID returns the stable conversation ID for a Slack thread.
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, bus *events.Bus, bridgeConfig *Config, logger *slog.Logger) *Bridge
NewConversation constructs a rocketcode bridge for one 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) SeedResponseThread ¶
func (b *Bridge) SeedResponseThread(ctx context.Context, checkpoint events.ResponseCheckpoint, _ string) error
SeedResponseThread initializes an empty thread session from a main-session response checkpoint.
func (*Bridge) SeedThreadFromCron ¶
SeedThreadFromCron initializes an empty Slack thread session from cron output.
func (*Bridge) SeedThreadFromMain ¶
SeedThreadFromMain initializes an empty thread session from current main-session context.
type Config ¶
type Config struct {
ConversationID, Agent string
OutputTargets []events.OutputTarget
RequestRestart func(context.Context, string) (string, error)
SessionService *SessionService
}
Config controls one rocketcode bridge conversation.
type ExternalMCPSessionState ¶
type ExternalMCPSessionState struct {
Agent string `json:"agent,omitempty"`
ConversationID string `json:"conversation_id,omitempty"`
}
ExternalMCPSessionState maps an external MCP conversation ID to its private session.
type ObservedSessionEntry ¶
type ObservedSessionEntry struct {
ID int64
Entry harness.SessionEntry
}
ObservedSessionEntry is one stored rocketcode entry with its SQLite row ID.
func ObserveSessionEntries ¶
func ObserveSessionEntries(ctx context.Context, dbPath, conversationID string, lastID int64) ([]ObservedSessionEntry, error)
ObserveSessionEntries returns replay entries and their row IDs after lastID.
type PruneStateStats ¶
type PruneStateStats struct {
Threads, ResponseCheckpoints, ExternalMCPSessions int
SessionRows int64
}
PruneStateStats reports how much stale persisted state was removed.
type RawRunProgress ¶
type RawRunProgress struct {
SessionService *SessionService
ConversationID string
Thinking, Message func(context.Context, string) error
ScheduleMessage func(time.Duration, string, bool) error
ResetScheduledMessages func() error
RequestRestart func(context.Context, string) (string, error)
}
RawRunProgress controls raw rocketcode run persistence and receives observable output.
type RawRunResult ¶
type RawRunResult struct {
Text, VerbatimMessage string
Attachments []events.OutboundAttachment
}
RawRunResult is the observable result of one non-publishing raw rocketcode turn.
func RunRawWithProgress ¶
func RunRawWithProgress(ctx context.Context, cfg *config.Config, agent, prompt string, logger *slog.Logger, progress *RawRunProgress) (RawRunResult, error)
RunRawWithProgress executes a raw rocketcode turn and reports optional progress.
type ResponseCheckpointState ¶
type ResponseCheckpointState struct {
ConversationID string `json:"conversation_id,omitempty"`
SessionEntryID int64 `json:"session_entry_id,omitempty"`
ResponseID string `json:"response_id,omitempty"`
Model string `json:"model,omitempty"`
AssistantText string `json:"assistant_text,omitempty"`
}
ResponseCheckpointState records enough metadata to seed a response-rooted thread.
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 SessionService ¶
type SessionService struct {
// contains filtered or unexported fields
}
SessionService owns runtime SQLite session and state access inside one rocketclaw process.
func NewSessionService ¶
func NewSessionService(workspace string) (*SessionService, error)
NewSessionService starts a runtime-owned SQLite session service.
func NewSessionServiceIn ¶
func NewSessionServiceIn(workspace, workDir string) (*SessionService, error)
NewSessionServiceIn starts a runtime-owned SQLite session service in workDir.
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) CheckpointWAL ¶
func (s *SessionService) CheckpointWAL(ctx context.Context) (WALCheckpointStats, error)
CheckpointWAL checkpoints and truncates the SQLite WAL through the runtime service handle.
func (*SessionService) Load ¶
func (s *SessionService) Load() (State, error)
Load returns the current persisted session state.
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) MarkThreadSeeded ¶
func (s *SessionService) MarkThreadSeeded(conversationID, seedKey string) error
MarkThreadSeeded records the response checkpoint used to seed a text thread.
func (*SessionService) ObserveEntries ¶
func (s *SessionService) ObserveEntries(ctx context.Context, conversationID string, lastID int64) ([]ObservedSessionEntry, error)
ObserveEntries loads observed session entries through the runtime service.
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) Stop ¶
func (s *SessionService) Stop(context.Context) error
Stop closes the runtime service and its SQLite handle.
func (*SessionService) UpsertExternalMCPSession ¶
func (s *SessionService) UpsertExternalMCPSession(externalConversationID string, session ExternalMCPSessionState) error
UpsertExternalMCPSession records an external MCP conversation ID mapping.
func (*SessionService) UpsertResponseCheckpoint ¶
func (s *SessionService) UpsertResponseCheckpoint(key string, checkpoint ResponseCheckpointState) error
UpsertResponseCheckpoint records a response checkpoint.
func (*SessionService) UpsertThread ¶
func (s *SessionService) UpsertThread(conversationID, agent string) error
UpsertThread records or updates a text-thread bridge entry.
func (*SessionService) Vacuum ¶
func (s *SessionService) Vacuum(ctx context.Context) (VacuumStats, error)
Vacuum runs explicit SQLite maintenance through the runtime service handle.
type SessionSummary ¶
type SessionSummary struct {
ConversationID, LastUserMessage, LastAssistantMessage string
Turns int
LastUpdated time.Time
}
SessionSummary is the compact observable state of one rocketcode session.
func ListSessions ¶
func ListSessions(ctx context.Context, workspace string) ([]SessionSummary, error)
ListSessions returns summaries for all stored rocketcode sessions.
func ListSessionsIn ¶
func ListSessionsIn(ctx context.Context, workspace, workDir string) ([]SessionSummary, error)
ListSessionsIn returns summaries for all stored rocketcode sessions in workDir.
type State ¶
type State struct {
Threads map[string]ThreadState `json:"threads,omitempty"`
ResponseCheckpoints map[string]ResponseCheckpointState `json:"response_checkpoints,omitempty"`
ExternalMCPSessions map[string]ExternalMCPSessionState `json:"external_mcp_sessions,omitempty"`
ScheduledMessages map[string]ScheduledMessageState `json:"scheduled_messages,omitempty"`
PendingRestartNotifications map[string]bool `json:"pending_restart_notifications,omitempty"`
}
State is the persisted rocketclaw session state.
type StateStoreLock ¶
type StateStoreLock struct {
// contains filtered or unexported fields
}
StateStoreLock holds advisory ownership of the RocketClaw state store.
func AcquireStateStoreLock ¶
func AcquireStateStoreLock(workspace, workDir string) (*StateStoreLock, error)
AcquireStateStoreLock acquires non-blocking advisory ownership of the state store.
func (*StateStoreLock) Close ¶
func (l *StateStoreLock) Close() error
Close releases the state-store lock.
type ThreadState ¶
type ThreadState struct {
Agent string `json:"agent,omitempty"`
SeededFromResponse string `json:"seeded_from_response,omitempty"`
}
ThreadState is the persisted state for one text-thread bridge.
type VacuumStats ¶
type VacuumStats struct {
DBExists bool
BeforePageCount, BeforeFreePages int64
AfterPageCount, AfterFreePages int64
}
VacuumStats reports SQLite page counts before and after vacuuming.
func VacuumSessions ¶
func VacuumSessions(ctx context.Context, workspace string) (VacuumStats, error)
VacuumSessions runs explicit SQLite maintenance for the rocketcode session DB.
func VacuumSessionsIn ¶
func VacuumSessionsIn(ctx context.Context, workspace, workDir string) (VacuumStats, error)
VacuumSessionsIn runs explicit SQLite maintenance for the rocketcode session DB in workDir.
type WALCheckpointStats ¶
type WALCheckpointStats struct {
Busy, LogFrames, CheckpointedFrames int64
}
WALCheckpointStats reports the outcome of a SQLite WAL checkpoint.