Documentation
¶
Index ¶
- Constants
- Variables
- func CurrentSchemaVersion() int
- func EncodeCursor(c ThreadsCursor) string
- type AutoThreadTitleCandidate
- type ContextSnapshotRecord
- type ConversationTurn
- type ExecutionSpanRecord
- type FollowupDeleteResourcesResult
- type MemoryItemRecord
- type Message
- type ProviderCapabilityRecord
- type QueuedTurn
- type RequestUserInputSecretAnswerRecord
- type RunEventRecord
- type RunEventsQuery
- type RunRecord
- type SQLiteCompactionPlan
- type SQLitePageStats
- type Store
- func (s *Store) AppendConversationTurn(ctx context.Context, rec ConversationTurn) error
- func (s *Store) AppendMessage(ctx context.Context, endpointID string, threadID string, m Message, ...) (int64, error)
- func (s *Store) AppendMessageWithUploadRefs(ctx context.Context, endpointID string, threadID string, m Message, ...) (int64, error)
- func (s *Store) AppendRunEvent(ctx context.Context, rec RunEventRecord) error
- func (s *Store) BindUploadsToRef(ctx context.Context, endpointID string, threadID string, refKind string, ...) error
- func (s *Store) ClearThreadProviderContinuation(ctx context.Context, endpointID string, threadID string) error
- func (s *Store) ClearThreadState(ctx context.Context, endpointID string, threadID string) error
- func (s *Store) Close() error
- func (s *Store) CountFollowupsByLane(ctx context.Context, endpointID string, threadID string, lane string) (int, error)
- func (s *Store) CountFollowupsByThreadAndLane(ctx context.Context, endpointID string, threadIDs []string, lane string) (map[string]int, error)
- func (s *Store) CountQueuedTurns(ctx context.Context, endpointID string, threadID string) (int, error)
- func (s *Store) CountQueuedTurnsByThread(ctx context.Context, endpointID string, threadIDs []string) (map[string]int, error)
- func (s *Store) CreateFollowup(ctx context.Context, rec QueuedTurn) (QueuedTurn, int, int64, error)
- func (s *Store) CreateFollowupWithUploadRefs(ctx context.Context, rec QueuedTurn, uploadIDs []string, claimedAtUnixMs int64) (QueuedTurn, int, int64, error)
- func (s *Store) CreateThread(ctx context.Context, t Thread) error
- func (s *Store) CreateThreadCheckpoint(ctx context.Context, endpointID string, threadID string, checkpointID string, ...) (ThreadCheckpointRecord, error)
- func (s *Store) DeleteFollowup(ctx context.Context, endpointID string, threadID string, followupID string) (int64, error)
- func (s *Store) DeleteFollowupResources(ctx context.Context, endpointID string, threadID string, followupID string) (FollowupDeleteResourcesResult, error)
- func (s *Store) DeleteQueuedTurn(ctx context.Context, endpointID string, threadID string, queueID string) error
- func (s *Store) DeleteQueuedTurns(ctx context.Context, endpointID string, threadID string) error
- func (s *Store) DeleteThread(ctx context.Context, endpointID string, threadID string) error
- func (s *Store) DeleteThreadContextData(ctx context.Context, endpointID string, threadID string) error
- func (s *Store) DeleteThreadMemoryItem(ctx context.Context, endpointID string, threadID string, memoryID string) error
- func (s *Store) DeleteThreadResources(ctx context.Context, endpointID string, threadID string) (ThreadDeleteResourcesResult, error)
- func (s *Store) EnqueueQueuedTurn(ctx context.Context, rec QueuedTurn) (QueuedTurn, int, error)
- func (s *Store) EnsureUpload(ctx context.Context, rec UploadRecord) error
- func (s *Store) FinalizeDeletedUploads(ctx context.Context, uploadIDs []string) (int64, error)
- func (s *Store) GetFirstUserThreadMessage(ctx context.Context, endpointID string, threadID string) (*Message, error)
- func (s *Store) GetLatestThreadCheckpoint(ctx context.Context, endpointID string, threadID string) (*ThreadCheckpointRecord, error)
- func (s *Store) GetProviderCapability(ctx context.Context, providerID string, modelName string) (*ProviderCapabilityRecord, error)
- func (s *Store) GetQueuedTurn(ctx context.Context, endpointID string, threadID string, queueID string) (*QueuedTurn, error)
- func (s *Store) GetThread(ctx context.Context, endpointID string, threadID string) (*Thread, error)
- func (s *Store) GetThreadCheckpoint(ctx context.Context, endpointID string, threadID string, checkpointID string) (*ThreadCheckpointRecord, error)
- func (s *Store) GetThreadFollowupsRevision(ctx context.Context, endpointID string, threadID string) (int64, error)
- func (s *Store) GetThreadOpenGoal(ctx context.Context, endpointID string, threadID string) (string, error)
- func (s *Store) GetThreadProviderContinuation(ctx context.Context, endpointID string, threadID string) (*ThreadProviderContinuation, error)
- func (s *Store) GetThreadState(ctx context.Context, endpointID string, threadID string) (*ThreadState, error)
- func (s *Store) GetThreadTodosSnapshot(ctx context.Context, endpointID string, threadID string) (ThreadTodosSnapshot, error)
- func (s *Store) GetToolCall(ctx context.Context, endpointID string, runID string, toolID string) (*ToolCallRecord, error)
- func (s *Store) GetTranscriptMessage(ctx context.Context, endpointID string, threadID string, messageID string) (*Message, error)
- func (s *Store) GetTranscriptMessageRowIDAndJSONByMessageID(ctx context.Context, endpointID string, threadID string, messageID string) (int64, string, error)
- func (s *Store) GetUpload(ctx context.Context, endpointID string, uploadID string) (*UploadRecord, error)
- func (s *Store) InsertContextSnapshot(ctx context.Context, rec ContextSnapshotRecord) error
- func (s *Store) InsertUpload(ctx context.Context, rec UploadRecord) error
- func (s *Store) ListAutoThreadTitleCandidates(ctx context.Context, limit int) ([]AutoThreadTitleCandidate, error)
- func (s *Store) ListCheckpointIDs(ctx context.Context) ([]string, error)
- func (s *Store) ListContextSnapshots(ctx context.Context, endpointID string, threadID string, level string, ...) ([]ContextSnapshotRecord, error)
- func (s *Store) ListConversationTurns(ctx context.Context, endpointID string, threadID string, limit int) ([]ConversationTurn, error)
- func (s *Store) ListExecutionSpansByRun(ctx context.Context, endpointID string, runID string, limit int) ([]ExecutionSpanRecord, error)
- func (s *Store) ListFollowupsByLane(ctx context.Context, endpointID string, threadID string, lane string, ...) ([]QueuedTurn, error)
- func (s *Store) ListHistoryLite(ctx context.Context, endpointID string, threadID string, limit int) ([]Message, error)
- func (s *Store) ListMemoryItemsByScopeKind(ctx context.Context, endpointID string, threadID string, scope string, ...) ([]MemoryItemRecord, error)
- func (s *Store) ListMessages(ctx context.Context, endpointID string, threadID string, limit int, ...) ([]Message, int64, bool, error)
- func (s *Store) ListMessagesAfter(ctx context.Context, endpointID string, threadID string, limit int, ...) ([]Message, int64, bool, error)
- func (s *Store) ListQueuedTurns(ctx context.Context, endpointID string, threadID string, limit int) ([]QueuedTurn, error)
- func (s *Store) ListRecentExecutionSpansByThread(ctx context.Context, endpointID string, threadID string, limit int) ([]ExecutionSpanRecord, error)
- func (s *Store) ListRecentMemoryItems(ctx context.Context, endpointID string, threadID string, limit int) ([]MemoryItemRecord, error)
- func (s *Store) ListRecentStructuredUserInputs(ctx context.Context, endpointID string, threadID string, limit int) ([]StructuredUserInputRecord, error)
- func (s *Store) ListRecentThreadToolCalls(ctx context.Context, endpointID string, threadID string, limit int) ([]ToolCallRecord, error)
- func (s *Store) ListRecentTranscriptMessages(ctx context.Context, endpointID string, threadID string, limit int) ([]Message, error)
- func (s *Store) ListRequestUserInputSecretAnswers(ctx context.Context, endpointID string, threadID string, ...) ([]RequestUserInputSecretAnswerRecord, error)
- func (s *Store) ListRunEvents(ctx context.Context, endpointID string, runID string, limit int) ([]RunEventRecord, error)
- func (s *Store) ListRunEventsPage(ctx context.Context, endpointID string, runID string, query RunEventsQuery) ([]RunEventRecord, int64, bool, error)
- func (s *Store) ListThreadCheckpointIDs(ctx context.Context, endpointID string, threadID string) ([]string, error)
- func (s *Store) ListThreads(ctx context.Context, endpointID string, limit int, cursor ThreadsCursor) ([]Thread, string, error)
- func (s *Store) MaybeCompact(ctx context.Context) (SQLiteCompactionPlan, error)
- func (s *Store) PopNextQueuedTurn(ctx context.Context, endpointID string, threadID string) (*QueuedTurn, error)
- func (s *Store) PrepareExpiredUploadsForDeletion(ctx context.Context, nowUnixMs int64, limit int) ([]UploadRecord, error)
- func (s *Store) PruneThreadCheckpoints(ctx context.Context, endpointID string, threadID string, keep int) ([]string, error)
- func (s *Store) RecoverQueuedTurnsToDrafts(ctx context.Context, endpointID string, threadID string) ([]QueuedTurn, int64, error)
- func (s *Store) RenameThread(ctx context.Context, endpointID string, threadID string, title string, ...) error
- func (s *Store) ReorderFollowups(ctx context.Context, endpointID string, threadID string, lane string, ...) (int64, error)
- func (s *Store) ReplaceRequestUserInputSecretAnswers(ctx context.Context, endpointID string, threadID string, ...) error
- func (s *Store) ReplaceStructuredUserInputs(ctx context.Context, endpointID string, threadID string, ...) error
- func (s *Store) ReplaceThreadTodosSnapshot(ctx context.Context, rec ThreadTodosSnapshot, expectedVersion *int64) (ThreadTodosSnapshot, error)
- func (s *Store) RescheduleUploadDeletion(ctx context.Context, uploadIDs []string, retryAtUnixMs int64) error
- func (s *Store) ResetStaleActiveThreadRunStates(ctx context.Context) (int64, error)
- func (s *Store) RestoreThreadCheckpoint(ctx context.Context, endpointID string, threadID string, checkpointID string) (*ThreadCheckpointRecord, error)
- func (s *Store) SQLitePageStats(ctx context.Context) (SQLitePageStats, error)
- func (s *Store) SetAutoThreadTitle(ctx context.Context, endpointID string, threadID string, title string, ...) (bool, error)
- func (s *Store) SetFallbackThreadTitle(ctx context.Context, endpointID string, threadID string, title string, ...) (bool, error)
- func (s *Store) SetThreadCheckpointWorkspaceJSON(ctx context.Context, endpointID string, threadID string, checkpointID string, ...) error
- func (s *Store) SetThreadOpenGoal(ctx context.Context, endpointID string, threadID string, goal string) error
- func (s *Store) SetThreadProviderContinuation(ctx context.Context, endpointID string, threadID string, ...) error
- func (s *Store) UpdateFollowupText(ctx context.Context, endpointID string, threadID string, followupID string, ...) (int64, error)
- func (s *Store) UpdateQueuedTurn(ctx context.Context, endpointID string, threadID string, queueID string, ...) error
- func (s *Store) UpdateThreadExecutionMode(ctx context.Context, endpointID string, threadID string, executionMode string) error
- func (s *Store) UpdateThreadModelID(ctx context.Context, endpointID string, threadID string, modelID string) error
- func (s *Store) UpdateThreadModelLock(ctx context.Context, endpointID string, threadID string, locked bool) error
- func (s *Store) UpdateThreadRunState(ctx context.Context, endpointID string, threadID string, runStatus string, ...) error
- func (s *Store) UpdateTranscriptMessageJSONByRowID(ctx context.Context, endpointID string, rowID int64, messageJSON string, ...) error
- func (s *Store) UpsertExecutionSpan(ctx context.Context, rec ExecutionSpanRecord) error
- func (s *Store) UpsertMemoryItem(ctx context.Context, rec MemoryItemRecord) error
- func (s *Store) UpsertProviderCapability(ctx context.Context, rec ProviderCapabilityRecord) error
- func (s *Store) UpsertRun(ctx context.Context, rec RunRecord) error
- func (s *Store) UpsertThreadState(ctx context.Context, st ThreadState) error
- func (s *Store) UpsertToolCall(ctx context.Context, rec ToolCallRecord) error
- type StructuredUserInputRecord
- type Thread
- type ThreadCheckpointRecord
- type ThreadDeleteResourcesResult
- type ThreadProviderContinuation
- type ThreadState
- type ThreadTodosSnapshot
- type ThreadsCursor
- type ToolCallRecord
- type UploadRecord
- type UploadRefRecord
Constants ¶
const ( FollowupLaneQueued = "queued" FollowupLaneDraft = "draft" )
const ( ThreadTitleSourceAuto = "auto" ThreadTitleSourceAutoFallback = "auto_fallback" ThreadTitleSourceUser = "user" )
const ( UploadStateStaged = "staged" UploadStateLive = "live" UploadStateDeleting = "deleting" UploadRefKindMessage = "message" UploadRefKindQueuedTurn = "queued_turn" )
const (
// CheckpointKindPreRun identifies the legacy snapshot rows retained for compatibility.
CheckpointKindPreRun = "pre_run"
)
Variables ¶
var ErrFollowupsRevisionChanged = errors.New("followups revision changed")
var ErrInvalidFollowupOrder = errors.New("invalid followup order")
var ErrThreadTodosVersionConflict = errors.New("thread todos version conflict")
Functions ¶
func CurrentSchemaVersion ¶
func CurrentSchemaVersion() int
CurrentSchemaVersion returns the latest threadstore schema version expected by migrations.
func EncodeCursor ¶
func EncodeCursor(c ThreadsCursor) string
EncodeCursor encodes a cursor as a URL-safe base64 string.
Types ¶
type ContextSnapshotRecord ¶
type ContextSnapshotRecord struct {
SnapshotID string `json:"snapshot_id"`
EndpointID string `json:"endpoint_id"`
ThreadID string `json:"thread_id"`
Level string `json:"level"`
SummaryText string `json:"summary_text"`
CoversTurnFromID int64 `json:"covers_turn_from_id"`
CoversTurnToID int64 `json:"covers_turn_to_id"`
QualityScore float64 `json:"quality_score"`
CreatedAtUnixMs int64 `json:"created_at_unix_ms"`
}
ContextSnapshotRecord stores compression artifacts with quality scores.
type ConversationTurn ¶
type ConversationTurn struct {
ID int64 `json:"id"`
TurnID string `json:"turn_id"`
EndpointID string `json:"endpoint_id"`
ThreadID string `json:"thread_id"`
RunID string `json:"run_id"`
UserMessageID string `json:"user_message_id"`
AssistantMessageID string `json:"assistant_message_id"`
CreatedAtUnixMs int64 `json:"created_at_unix_ms"`
}
ConversationTurn links transcript messages to one semantic turn.
type ExecutionSpanRecord ¶
type ExecutionSpanRecord struct {
SpanID string `json:"span_id"`
EndpointID string `json:"endpoint_id"`
ThreadID string `json:"thread_id"`
RunID string `json:"run_id"`
Kind string `json:"kind"`
Name string `json:"name"`
Status string `json:"status"`
PayloadJSON string `json:"payload_json"`
StartedAtUnixMs int64 `json:"started_at_unix_ms"`
EndedAtUnixMs int64 `json:"ended_at_unix_ms"`
UpdatedAtUnixMs int64 `json:"updated_at_unix_ms"`
}
ExecutionSpanRecord captures structured execution evidence.
type FollowupDeleteResourcesResult ¶
type FollowupDeleteResourcesResult struct {
Revision int64
UploadsToDelete []UploadRecord
}
type MemoryItemRecord ¶
type MemoryItemRecord struct {
MemoryID string `json:"memory_id"`
EndpointID string `json:"endpoint_id"`
ThreadID string `json:"thread_id"`
Scope string `json:"scope"`
Kind string `json:"kind"`
Content string `json:"content"`
SourceRefsJSON string `json:"source_refs_json"`
Importance float64 `json:"importance"`
Freshness float64 `json:"freshness"`
Confidence float64 `json:"confidence"`
CreatedAtUnixMs int64 `json:"created_at_unix_ms"`
UpdatedAtUnixMs int64 `json:"updated_at_unix_ms"`
}
MemoryItemRecord is the normalized semantic memory entry.
type Message ¶
type Message struct {
ID int64 `json:"id"`
ThreadID string `json:"thread_id"`
EndpointID string `json:"endpoint_id"`
MessageID string `json:"message_id"`
Role string `json:"role"`
AuthorUserPublicID string `json:"author_user_public_id"`
AuthorUserEmail string `json:"author_user_email"`
Status string `json:"status"`
CreatedAtUnixMs int64 `json:"created_at_unix_ms"`
UpdatedAtUnixMs int64 `json:"updated_at_unix_ms"`
TextContent string `json:"text_content"`
MessageJSON string `json:"message_json"`
}
type ProviderCapabilityRecord ¶
type ProviderCapabilityRecord struct {
ProviderID string `json:"provider_id"`
ModelName string `json:"model_name"`
CapabilityJSON string `json:"capability_json"`
UpdatedAtUnixMs int64 `json:"updated_at_unix_ms"`
}
ProviderCapabilityRecord caches capability json by provider/model.
type QueuedTurn ¶
type QueuedTurn struct {
QueueID string `json:"queue_id"`
ThreadID string `json:"thread_id"`
EndpointID string `json:"endpoint_id"`
ChannelID string `json:"channel_id"`
Lane string `json:"lane"`
MessageID string `json:"message_id"`
ModelID string `json:"model_id"`
TextContent string `json:"text_content"`
AttachmentsJSON string `json:"attachments_json"`
OptionsJSON string `json:"options_json"`
SessionMetaJSON string `json:"session_meta_json"`
CreatedByUserPublicID string `json:"created_by_user_public_id"`
CreatedByUserEmail string `json:"created_by_user_email"`
SortIndex int64 `json:"sort_index"`
CreatedAtUnixMs int64 `json:"created_at_unix_ms"`
UpdatedAtUnixMs int64 `json:"updated_at_unix_ms"`
}
type RequestUserInputSecretAnswerRecord ¶
type RequestUserInputSecretAnswerRecord struct {
ID int64 `json:"id"`
EndpointID string `json:"endpoint_id"`
ThreadID string `json:"thread_id"`
ResponseMessageID string `json:"response_message_id"`
QuestionID string `json:"question_id"`
Text string `json:"text,omitempty"`
CreatedAtUnixMs int64 `json:"created_at_unix_ms"`
}
type RunEventRecord ¶
type RunEventRecord struct {
ID int64 `json:"id"`
EndpointID string `json:"endpoint_id"`
ThreadID string `json:"thread_id"`
RunID string `json:"run_id"`
StreamKind string `json:"stream_kind"`
EventType string `json:"event_type"`
PayloadJSON string `json:"payload_json"`
AtUnixMs int64 `json:"at_unix_ms"`
}
type RunEventsQuery ¶
type RunRecord ¶
type RunRecord struct {
RunID string `json:"run_id"`
EndpointID string `json:"endpoint_id"`
ThreadID string `json:"thread_id"`
MessageID string `json:"message_id"`
State string `json:"state"`
ErrorCode string `json:"error_code"`
ErrorMessage string `json:"error_message"`
AttemptCount int `json:"attempt_count"`
StartedAtUnixMs int64 `json:"started_at_unix_ms"`
EndedAtUnixMs int64 `json:"ended_at_unix_ms"`
UpdatedAtUnixMs int64 `json:"updated_at_unix_ms"`
}
type SQLiteCompactionPlan ¶
type SQLiteCompactionPlan struct {
ShouldCompact bool
UseIncremental bool
PageSize int64
PageCount int64
FreelistCount int64
FreeBytes int64
PagesToRelease int64
}
func BuildSQLiteCompactionPlan ¶
func BuildSQLiteCompactionPlan(stats SQLitePageStats) SQLiteCompactionPlan
type SQLitePageStats ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a local SQLite-backed persistence layer for AI threads and messages.
Notes: - Data is scoped by endpoint_id (env public id). It is intentionally shared within the same env for collaboration. - WAL is enabled to support concurrent reads while writing (multiple browser sessions).
func (*Store) AppendConversationTurn ¶
func (s *Store) AppendConversationTurn(ctx context.Context, rec ConversationTurn) error
func (*Store) AppendMessage ¶
func (s *Store) AppendMessage(ctx context.Context, endpointID string, threadID string, m Message, updatedByID string, updatedByEmail string) (int64, error)
AppendMessage inserts a message into the thread and updates thread metadata in the same transaction.
func (*Store) AppendMessageWithUploadRefs ¶
func (*Store) AppendRunEvent ¶
func (s *Store) AppendRunEvent(ctx context.Context, rec RunEventRecord) error
func (*Store) BindUploadsToRef ¶
func (*Store) ClearThreadProviderContinuation ¶
func (*Store) ClearThreadState ¶
func (*Store) CountFollowupsByLane ¶
func (*Store) CountFollowupsByThreadAndLane ¶
func (*Store) CountQueuedTurns ¶
func (*Store) CountQueuedTurnsByThread ¶
func (*Store) CreateFollowup ¶
func (s *Store) CreateFollowup(ctx context.Context, rec QueuedTurn) (QueuedTurn, int, int64, error)
func (*Store) CreateFollowupWithUploadRefs ¶
func (s *Store) CreateFollowupWithUploadRefs(ctx context.Context, rec QueuedTurn, uploadIDs []string, claimedAtUnixMs int64) (QueuedTurn, int, int64, error)
func (*Store) CreateThreadCheckpoint ¶
func (*Store) DeleteFollowup ¶
func (*Store) DeleteFollowupResources ¶
func (*Store) DeleteQueuedTurn ¶
func (*Store) DeleteQueuedTurns ¶
func (*Store) DeleteThread ¶
func (*Store) DeleteThreadContextData ¶
func (*Store) DeleteThreadMemoryItem ¶
func (*Store) DeleteThreadResources ¶
func (*Store) EnqueueQueuedTurn ¶
func (s *Store) EnqueueQueuedTurn(ctx context.Context, rec QueuedTurn) (QueuedTurn, int, error)
func (*Store) EnsureUpload ¶
func (s *Store) EnsureUpload(ctx context.Context, rec UploadRecord) error
func (*Store) FinalizeDeletedUploads ¶
func (*Store) GetFirstUserThreadMessage ¶
func (*Store) GetLatestThreadCheckpoint ¶
func (*Store) GetProviderCapability ¶
func (*Store) GetQueuedTurn ¶
func (*Store) GetThreadCheckpoint ¶
func (*Store) GetThreadFollowupsRevision ¶
func (*Store) GetThreadOpenGoal ¶
func (*Store) GetThreadProviderContinuation ¶
func (*Store) GetThreadState ¶
func (*Store) GetThreadTodosSnapshot ¶
func (*Store) GetToolCall ¶
func (*Store) GetTranscriptMessage ¶
func (*Store) GetTranscriptMessageRowIDAndJSONByMessageID ¶
func (s *Store) GetTranscriptMessageRowIDAndJSONByMessageID(ctx context.Context, endpointID string, threadID string, messageID string) (int64, string, error)
GetTranscriptMessageRowIDAndJSONByMessageID returns (row_id, message_json) for a transcript message.
func (*Store) InsertContextSnapshot ¶
func (s *Store) InsertContextSnapshot(ctx context.Context, rec ContextSnapshotRecord) error
func (*Store) InsertUpload ¶
func (s *Store) InsertUpload(ctx context.Context, rec UploadRecord) error
func (*Store) ListAutoThreadTitleCandidates ¶
func (*Store) ListCheckpointIDs ¶
func (*Store) ListContextSnapshots ¶
func (*Store) ListConversationTurns ¶
func (*Store) ListExecutionSpansByRun ¶
func (*Store) ListFollowupsByLane ¶
func (*Store) ListHistoryLite ¶
func (s *Store) ListHistoryLite(ctx context.Context, endpointID string, threadID string, limit int) ([]Message, error)
ListHistoryLite returns the latest messages as (role, status, text_content), in ascending order.
func (*Store) ListMemoryItemsByScopeKind ¶
func (*Store) ListMessages ¶
func (s *Store) ListMessages(ctx context.Context, endpointID string, threadID string, limit int, beforeID int64) ([]Message, int64, bool, error)
ListMessages returns messages in ascending order by internal id.
If beforeID <= 0, it returns the latest messages. Otherwise, it returns messages with id < beforeID. The returned nextBeforeID is the smallest id in the result (for loading older history).
func (*Store) ListMessagesAfter ¶
func (s *Store) ListMessagesAfter(ctx context.Context, endpointID string, threadID string, limit int, afterID int64) ([]Message, int64, bool, error)
ListMessagesAfter returns messages in ascending order by internal id.
It returns messages with id > afterID. The returned nextAfterID is the largest id in the result (for incremental backfill). If no messages are returned, nextAfterID equals afterID.
func (*Store) ListQueuedTurns ¶
func (*Store) ListRecentExecutionSpansByThread ¶
func (*Store) ListRecentMemoryItems ¶
func (*Store) ListRecentStructuredUserInputs ¶
func (*Store) ListRecentThreadToolCalls ¶
func (*Store) ListRecentTranscriptMessages ¶
func (*Store) ListRequestUserInputSecretAnswers ¶
func (*Store) ListRunEvents ¶
func (*Store) ListRunEventsPage ¶
func (s *Store) ListRunEventsPage(ctx context.Context, endpointID string, runID string, query RunEventsQuery) ([]RunEventRecord, int64, bool, error)
func (*Store) ListThreadCheckpointIDs ¶
func (*Store) ListThreads ¶
func (*Store) MaybeCompact ¶
func (s *Store) MaybeCompact(ctx context.Context) (SQLiteCompactionPlan, error)
func (*Store) PopNextQueuedTurn ¶
func (*Store) PrepareExpiredUploadsForDeletion ¶
func (*Store) PruneThreadCheckpoints ¶
func (*Store) RecoverQueuedTurnsToDrafts ¶
func (*Store) RenameThread ¶
func (*Store) ReorderFollowups ¶
func (*Store) ReplaceRequestUserInputSecretAnswers ¶
func (*Store) ReplaceStructuredUserInputs ¶
func (*Store) ReplaceThreadTodosSnapshot ¶
func (s *Store) ReplaceThreadTodosSnapshot(ctx context.Context, rec ThreadTodosSnapshot, expectedVersion *int64) (ThreadTodosSnapshot, error)
func (*Store) RescheduleUploadDeletion ¶
func (*Store) ResetStaleActiveThreadRunStates ¶
ResetStaleActiveThreadRunStates marks startup-orphaned active thread states as canceled.
Why this exists: - Active runs are held in memory during normal execution. - If the runtime process restarts, those in-memory runs are gone. - Any persisted thread state that still looks "active" must be reset so UI does not show phantom running threads.
func (*Store) RestoreThreadCheckpoint ¶
func (*Store) SQLitePageStats ¶
func (s *Store) SQLitePageStats(ctx context.Context) (SQLitePageStats, error)
func (*Store) SetAutoThreadTitle ¶
func (*Store) SetFallbackThreadTitle ¶
func (*Store) SetThreadCheckpointWorkspaceJSON ¶
func (*Store) SetThreadOpenGoal ¶
func (*Store) SetThreadProviderContinuation ¶
func (*Store) UpdateFollowupText ¶
func (*Store) UpdateQueuedTurn ¶
func (*Store) UpdateThreadExecutionMode ¶
func (*Store) UpdateThreadModelID ¶
func (*Store) UpdateThreadModelLock ¶
func (*Store) UpdateThreadRunState ¶
func (*Store) UpdateTranscriptMessageJSONByRowID ¶
func (s *Store) UpdateTranscriptMessageJSONByRowID(ctx context.Context, endpointID string, rowID int64, messageJSON string, updatedAtUnixMs int64) error
UpdateTranscriptMessageJSONByRowID updates transcript_messages.message_json without mutating thread metadata.
func (*Store) UpsertExecutionSpan ¶
func (s *Store) UpsertExecutionSpan(ctx context.Context, rec ExecutionSpanRecord) error
func (*Store) UpsertMemoryItem ¶
func (s *Store) UpsertMemoryItem(ctx context.Context, rec MemoryItemRecord) error
func (*Store) UpsertProviderCapability ¶
func (s *Store) UpsertProviderCapability(ctx context.Context, rec ProviderCapabilityRecord) error
func (*Store) UpsertThreadState ¶
func (s *Store) UpsertThreadState(ctx context.Context, st ThreadState) error
func (*Store) UpsertToolCall ¶
func (s *Store) UpsertToolCall(ctx context.Context, rec ToolCallRecord) error
type StructuredUserInputRecord ¶
type StructuredUserInputRecord struct {
ID int64 `json:"id"`
EndpointID string `json:"endpoint_id"`
ThreadID string `json:"thread_id"`
ResponseMessageID string `json:"response_message_id"`
PromptID string `json:"prompt_id"`
ToolID string `json:"tool_id"`
ReasonCode string `json:"reason_code"`
QuestionID string `json:"question_id"`
Header string `json:"header"`
QuestionText string `json:"question_text"`
SelectedChoiceID string `json:"selected_choice_id"`
SelectedChoiceLabel string `json:"selected_choice_label"`
Text string `json:"text,omitempty"`
PublicSummary string `json:"public_summary"`
ContainsSecret bool `json:"contains_secret"`
CreatedAtUnixMs int64 `json:"created_at_unix_ms"`
}
type Thread ¶
type Thread struct {
ThreadID string `json:"thread_id"`
EndpointID string `json:"endpoint_id"`
NamespacePublicID string `json:"namespace_public_id"`
ModelID string `json:"model_id"`
ModelLocked bool `json:"model_locked"`
ExecutionMode string `json:"execution_mode"`
WorkingDir string `json:"working_dir"`
Title string `json:"title"`
TitleSource string `json:"title_source"`
TitleGeneratedAtUnixMs int64 `json:"title_generated_at_unix_ms"`
TitleInputMessageID string `json:"title_input_message_id"`
TitleModelID string `json:"title_model_id"`
TitlePromptVersion string `json:"title_prompt_version"`
RunStatus string `json:"run_status"`
RunUpdatedAtUnixMs int64 `json:"run_updated_at_unix_ms"`
RunError string `json:"run_error"`
WaitingUserInputJSON string `json:"waiting_user_input_json"`
LastContextRunID string `json:"last_context_run_id"`
CreatedByUserPublicID string `json:"created_by_user_public_id"`
CreatedByUserEmail string `json:"created_by_user_email"`
UpdatedByUserPublicID string `json:"updated_by_user_public_id"`
UpdatedByUserEmail string `json:"updated_by_user_email"`
CreatedAtUnixMs int64 `json:"created_at_unix_ms"`
UpdatedAtUnixMs int64 `json:"updated_at_unix_ms"`
LastMessageAtUnixMs int64 `json:"last_message_at_unix_ms"`
LastMessagePreview string `json:"last_message_preview"`
}
type ThreadCheckpointRecord ¶
type ThreadCheckpointRecord struct {
CheckpointID string `json:"checkpoint_id"`
EndpointID string `json:"endpoint_id"`
ThreadID string `json:"thread_id"`
RunID string `json:"run_id"`
Kind string `json:"kind"`
CreatedAtUnixMs int64 `json:"created_at_unix_ms"`
ThreadJSON string `json:"thread_json"`
DerivedJSON string `json:"derived_json"`
WorkspaceJSON string `json:"workspace_json"` // legacy compatibility payload; empty for new checkpoints
TranscriptMaxID int64 `json:"transcript_max_id"`
TurnsMaxID int64 `json:"turns_max_id"`
ToolCallsMaxID int64 `json:"tool_calls_max_id"`
RunEventsMaxID int64 `json:"run_events_max_id"`
}
ThreadCheckpointRecord is a persisted compatibility record for a single thread checkpoint.
Normal Flower runs no longer create new thread checkpoints, but legacy rows may still exist and need cleanup or best-effort restore handling.
type ThreadDeleteResourcesResult ¶
type ThreadDeleteResourcesResult struct {
CheckpointIDs []string
UploadsToDelete []UploadRecord
}
type ThreadProviderContinuation ¶
type ThreadProviderContinuation struct {
Kind string `json:"kind"`
ContinuationID string `json:"continuation_id"`
ProviderID string `json:"provider_id"`
Model string `json:"model"`
BaseURL string `json:"base_url"`
UpdatedAtUnixMs int64 `json:"updated_at_unix_ms"`
}
func (ThreadProviderContinuation) IsZero ¶
func (c ThreadProviderContinuation) IsZero() bool
func (ThreadProviderContinuation) Normalized ¶
func (c ThreadProviderContinuation) Normalized() ThreadProviderContinuation
type ThreadState ¶
type ThreadState struct {
EndpointID string `json:"endpoint_id"`
ThreadID string `json:"thread_id"`
OpenGoal string `json:"open_goal"`
LastAssistantSummary string `json:"last_assistant_summary"`
ProviderContinuation ThreadProviderContinuation `json:"provider_continuation,omitempty"`
UpdatedAtUnixMs int64 `json:"updated_at_unix_ms"`
}
type ThreadTodosSnapshot ¶
type ThreadTodosSnapshot struct {
EndpointID string `json:"endpoint_id"`
ThreadID string `json:"thread_id"`
Version int64 `json:"version"`
TodosJSON string `json:"todos_json"`
UpdatedAtUnixMs int64 `json:"updated_at_unix_ms"`
UpdatedByRunID string `json:"updated_by_run_id"`
UpdatedByToolID string `json:"updated_by_tool_id"`
}
ThreadTodosSnapshot stores the thread-level todo list snapshot.
type ThreadsCursor ¶
func DecodeCursor ¶
func DecodeCursor(raw string) (ThreadsCursor, bool)
type ToolCallRecord ¶
type ToolCallRecord struct {
RunID string `json:"run_id"`
ToolID string `json:"tool_id"`
ToolName string `json:"tool_name"`
Status string `json:"status"`
ArgsJSON string `json:"args_json"`
ResultJSON string `json:"result_json"`
ErrorCode string `json:"error_code"`
ErrorMessage string `json:"error_message"`
Retryable bool `json:"retryable"`
RecoveryAction string `json:"recovery_action"`
StartedAtUnixMs int64 `json:"started_at_unix_ms"`
EndedAtUnixMs int64 `json:"ended_at_unix_ms"`
LatencyMS int64 `json:"latency_ms"`
}
type UploadRecord ¶
type UploadRecord struct {
UploadID string `json:"upload_id"`
EndpointID string `json:"endpoint_id"`
StorageRelPath string `json:"storage_relpath"`
Name string `json:"name"`
MimeType string `json:"mime_type"`
SizeBytes int64 `json:"size_bytes"`
State string `json:"state"`
CreatedAtUnixMs int64 `json:"created_at_unix_ms"`
ClaimedAtUnixMs int64 `json:"claimed_at_unix_ms"`
DeleteAfterUnixMs int64 `json:"delete_after_unix_ms"`
}