threadstore

package
v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FollowupLaneQueued = "queued"
	FollowupLaneDraft  = "draft"
)
View Source
const (
	ThreadTitleSourceAuto         = "auto"
	ThreadTitleSourceAutoFallback = "auto_fallback"
	ThreadTitleSourceUser         = "user"
)
View Source
const (
	UploadStateStaged   = "staged"
	UploadStateLive     = "live"
	UploadStateDeleting = "deleting"

	UploadRefKindMessage    = "message"
	UploadRefKindQueuedTurn = "queued_turn"
)
View Source
const (
	// CheckpointKindPreRun identifies the legacy snapshot rows retained for compatibility.
	CheckpointKindPreRun = "pre_run"
)

Variables

View Source
var ErrFollowupsRevisionChanged = errors.New("followups revision changed")
View Source
var ErrInvalidFollowupOrder = errors.New("invalid followup order")
View Source
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 AutoThreadTitleCandidate

type AutoThreadTitleCandidate struct {
	EndpointID string `json:"endpoint_id"`
	ThreadID   string `json:"thread_id"`
}

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"`

	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 RunEventsQuery struct {
	Cursor   int64
	Limit    int
	Category string
}

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 SQLitePageStats struct {
	PageSize       int64
	PageCount      int64
	FreelistCount  int64
	AutoVacuumMode int64
}

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 Open

func Open(path string) (*Store, error)

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 (s *Store) AppendMessageWithUploadRefs(ctx context.Context, endpointID string, threadID string, m Message, updatedByID string, updatedByEmail string, uploadIDs []string, claimedAtUnixMs int64) (int64, error)

func (*Store) AppendRunEvent

func (s *Store) AppendRunEvent(ctx context.Context, rec RunEventRecord) error

func (*Store) BindUploadsToRef

func (s *Store) BindUploadsToRef(ctx context.Context, endpointID string, threadID string, refKind string, refID string, uploadIDs []string, claimedAtUnixMs int64) error

func (*Store) ClearThreadProviderContinuation

func (s *Store) ClearThreadProviderContinuation(ctx context.Context, endpointID string, threadID string) error

func (*Store) ClearThreadState

func (s *Store) ClearThreadState(ctx context.Context, endpointID string, threadID string) error

func (*Store) Close

func (s *Store) Close() error

func (*Store) CountFollowupsByLane

func (s *Store) CountFollowupsByLane(ctx context.Context, endpointID string, threadID string, lane string) (int, error)

func (*Store) CountFollowupsByThreadAndLane

func (s *Store) CountFollowupsByThreadAndLane(ctx context.Context, endpointID string, threadIDs []string, lane string) (map[string]int, error)

func (*Store) CountQueuedTurns

func (s *Store) CountQueuedTurns(ctx context.Context, endpointID string, threadID string) (int, error)

func (*Store) CountQueuedTurnsByThread

func (s *Store) CountQueuedTurnsByThread(ctx context.Context, endpointID string, threadIDs []string) (map[string]int, error)

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) CreateThread

func (s *Store) CreateThread(ctx context.Context, t Thread) error

func (*Store) CreateThreadCheckpoint

func (s *Store) CreateThreadCheckpoint(ctx context.Context, endpointID string, threadID string, checkpointID string, runID string, kind string) (ThreadCheckpointRecord, error)

func (*Store) DeleteFollowup

func (s *Store) DeleteFollowup(ctx context.Context, endpointID string, threadID string, followupID string) (int64, error)

func (*Store) DeleteFollowupResources

func (s *Store) DeleteFollowupResources(ctx context.Context, endpointID string, threadID string, followupID string) (FollowupDeleteResourcesResult, error)

func (*Store) DeleteQueuedTurn

func (s *Store) DeleteQueuedTurn(ctx context.Context, endpointID string, threadID string, queueID string) error

func (*Store) DeleteQueuedTurns

func (s *Store) DeleteQueuedTurns(ctx context.Context, endpointID string, threadID string) error

func (*Store) DeleteThread

func (s *Store) DeleteThread(ctx context.Context, endpointID string, threadID string) error

func (*Store) DeleteThreadContextData

func (s *Store) DeleteThreadContextData(ctx context.Context, endpointID string, threadID string) error

func (*Store) DeleteThreadMemoryItem

func (s *Store) DeleteThreadMemoryItem(ctx context.Context, endpointID string, threadID string, memoryID string) error

func (*Store) DeleteThreadResources

func (s *Store) DeleteThreadResources(ctx context.Context, endpointID string, threadID string) (ThreadDeleteResourcesResult, error)

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 (s *Store) FinalizeDeletedUploads(ctx context.Context, uploadIDs []string) (int64, error)

func (*Store) GetFirstUserThreadMessage

func (s *Store) GetFirstUserThreadMessage(ctx context.Context, endpointID string, threadID string) (*Message, error)

func (*Store) GetLatestThreadCheckpoint

func (s *Store) GetLatestThreadCheckpoint(ctx context.Context, endpointID string, threadID string) (*ThreadCheckpointRecord, error)

func (*Store) GetProviderCapability

func (s *Store) GetProviderCapability(ctx context.Context, providerID string, modelName string) (*ProviderCapabilityRecord, error)

func (*Store) GetQueuedTurn

func (s *Store) GetQueuedTurn(ctx context.Context, endpointID string, threadID string, queueID string) (*QueuedTurn, error)

func (*Store) GetThread

func (s *Store) GetThread(ctx context.Context, endpointID string, threadID string) (*Thread, error)

func (*Store) GetThreadCheckpoint

func (s *Store) GetThreadCheckpoint(ctx context.Context, endpointID string, threadID string, checkpointID string) (*ThreadCheckpointRecord, error)

func (*Store) GetThreadFollowupsRevision

func (s *Store) GetThreadFollowupsRevision(ctx context.Context, endpointID string, threadID string) (int64, error)

func (*Store) GetThreadOpenGoal

func (s *Store) GetThreadOpenGoal(ctx context.Context, endpointID string, threadID string) (string, error)

func (*Store) GetThreadProviderContinuation

func (s *Store) GetThreadProviderContinuation(ctx context.Context, endpointID string, threadID string) (*ThreadProviderContinuation, error)

func (*Store) GetThreadState

func (s *Store) GetThreadState(ctx context.Context, endpointID string, threadID string) (*ThreadState, error)

func (*Store) GetThreadTodosSnapshot

func (s *Store) GetThreadTodosSnapshot(ctx context.Context, endpointID string, threadID string) (ThreadTodosSnapshot, error)

func (*Store) GetToolCall

func (s *Store) GetToolCall(ctx context.Context, endpointID string, runID string, toolID string) (*ToolCallRecord, error)

func (*Store) GetTranscriptMessage

func (s *Store) GetTranscriptMessage(ctx context.Context, endpointID string, threadID string, messageID string) (*Message, error)

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) GetUpload

func (s *Store) GetUpload(ctx context.Context, endpointID string, uploadID string) (*UploadRecord, error)

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 (s *Store) ListAutoThreadTitleCandidates(ctx context.Context, limit int) ([]AutoThreadTitleCandidate, error)

func (*Store) ListCheckpointIDs

func (s *Store) ListCheckpointIDs(ctx context.Context) ([]string, error)

func (*Store) ListContextSnapshots

func (s *Store) ListContextSnapshots(ctx context.Context, endpointID string, threadID string, level string, limit int) ([]ContextSnapshotRecord, error)

func (*Store) ListConversationTurns

func (s *Store) ListConversationTurns(ctx context.Context, endpointID string, threadID string, limit int) ([]ConversationTurn, error)

func (*Store) ListExecutionSpansByRun

func (s *Store) ListExecutionSpansByRun(ctx context.Context, endpointID string, runID string, limit int) ([]ExecutionSpanRecord, error)

func (*Store) ListFollowupsByLane

func (s *Store) ListFollowupsByLane(ctx context.Context, endpointID string, threadID string, lane string, limit int) ([]QueuedTurn, error)

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 (s *Store) ListMemoryItemsByScopeKind(ctx context.Context, endpointID string, threadID string, scope string, kind string, limit int) ([]MemoryItemRecord, error)

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 (s *Store) ListQueuedTurns(ctx context.Context, endpointID string, threadID string, limit int) ([]QueuedTurn, error)

func (*Store) ListRecentExecutionSpansByThread

func (s *Store) ListRecentExecutionSpansByThread(ctx context.Context, endpointID string, threadID string, limit int) ([]ExecutionSpanRecord, error)

func (*Store) ListRecentMemoryItems

func (s *Store) ListRecentMemoryItems(ctx context.Context, endpointID string, threadID string, limit int) ([]MemoryItemRecord, error)

func (*Store) ListRecentStructuredUserInputs

func (s *Store) ListRecentStructuredUserInputs(ctx context.Context, endpointID string, threadID string, limit int) ([]StructuredUserInputRecord, error)

func (*Store) ListRecentThreadToolCalls

func (s *Store) ListRecentThreadToolCalls(ctx context.Context, endpointID string, threadID string, limit int) ([]ToolCallRecord, error)

func (*Store) ListRecentTranscriptMessages

func (s *Store) ListRecentTranscriptMessages(ctx context.Context, endpointID string, threadID string, limit int) ([]Message, error)

func (*Store) ListRequestUserInputSecretAnswers

func (s *Store) ListRequestUserInputSecretAnswers(ctx context.Context, endpointID string, threadID string, responseMessageID string) ([]RequestUserInputSecretAnswerRecord, error)

func (*Store) ListRunEvents

func (s *Store) ListRunEvents(ctx context.Context, endpointID string, runID string, limit int) ([]RunEventRecord, error)

func (*Store) ListRunEventsPage

func (s *Store) ListRunEventsPage(ctx context.Context, endpointID string, runID string, query RunEventsQuery) ([]RunEventRecord, int64, bool, error)

func (*Store) ListThreadCheckpointIDs

func (s *Store) ListThreadCheckpointIDs(ctx context.Context, endpointID string, threadID string) ([]string, error)

func (*Store) ListThreads

func (s *Store) ListThreads(ctx context.Context, endpointID string, limit int, cursor ThreadsCursor) ([]Thread, string, error)

func (*Store) MaybeCompact

func (s *Store) MaybeCompact(ctx context.Context) (SQLiteCompactionPlan, error)

func (*Store) PopNextQueuedTurn

func (s *Store) PopNextQueuedTurn(ctx context.Context, endpointID string, threadID string) (*QueuedTurn, error)

func (*Store) PrepareExpiredUploadsForDeletion

func (s *Store) PrepareExpiredUploadsForDeletion(ctx context.Context, nowUnixMs int64, limit int) ([]UploadRecord, error)

func (*Store) PruneThreadCheckpoints

func (s *Store) PruneThreadCheckpoints(ctx context.Context, endpointID string, threadID string, keep int) ([]string, error)

func (*Store) RecoverQueuedTurnsToDrafts

func (s *Store) RecoverQueuedTurnsToDrafts(ctx context.Context, endpointID string, threadID string) ([]QueuedTurn, int64, error)

func (*Store) RenameThread

func (s *Store) RenameThread(ctx context.Context, endpointID string, threadID string, title string, updatedByID string, updatedByEmail string) error

func (*Store) ReorderFollowups

func (s *Store) ReorderFollowups(ctx context.Context, endpointID string, threadID string, lane string, orderedIDs []string, expectedRevision int64) (int64, error)

func (*Store) ReplaceRequestUserInputSecretAnswers

func (s *Store) ReplaceRequestUserInputSecretAnswers(ctx context.Context, endpointID string, threadID string, responseMessageID string, records []RequestUserInputSecretAnswerRecord) error

func (*Store) ReplaceStructuredUserInputs

func (s *Store) ReplaceStructuredUserInputs(ctx context.Context, endpointID string, threadID string, responseMessageID string, records []StructuredUserInputRecord) error

func (*Store) ReplaceThreadTodosSnapshot

func (s *Store) ReplaceThreadTodosSnapshot(ctx context.Context, rec ThreadTodosSnapshot, expectedVersion *int64) (ThreadTodosSnapshot, error)

func (*Store) RescheduleUploadDeletion

func (s *Store) RescheduleUploadDeletion(ctx context.Context, uploadIDs []string, retryAtUnixMs int64) error

func (*Store) ResetStaleActiveThreadRunStates

func (s *Store) ResetStaleActiveThreadRunStates(ctx context.Context) (int64, error)

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 (s *Store) RestoreThreadCheckpoint(ctx context.Context, endpointID string, threadID string, checkpointID string) (*ThreadCheckpointRecord, error)

func (*Store) SQLitePageStats

func (s *Store) SQLitePageStats(ctx context.Context) (SQLitePageStats, error)

func (*Store) SetAutoThreadTitle

func (s *Store) SetAutoThreadTitle(ctx context.Context, endpointID string, threadID string, title string, inputMessageID string, modelID string, promptVersion string, generatedAtUnixMs int64, updatedByID string, updatedByEmail string) (bool, error)

func (*Store) SetFallbackThreadTitle

func (s *Store) SetFallbackThreadTitle(ctx context.Context, endpointID string, threadID string, title string, inputMessageID string, generatedAtUnixMs int64, updatedByID string, updatedByEmail string) (bool, error)

func (*Store) SetThreadCheckpointWorkspaceJSON

func (s *Store) SetThreadCheckpointWorkspaceJSON(ctx context.Context, endpointID string, threadID string, checkpointID string, workspaceJSON string) error

func (*Store) SetThreadOpenGoal

func (s *Store) SetThreadOpenGoal(ctx context.Context, endpointID string, threadID string, goal string) error

func (*Store) SetThreadProviderContinuation

func (s *Store) SetThreadProviderContinuation(ctx context.Context, endpointID string, threadID string, cont ThreadProviderContinuation) error

func (*Store) UpdateFollowupText

func (s *Store) UpdateFollowupText(ctx context.Context, endpointID string, threadID string, followupID string, textContent string) (int64, error)

func (*Store) UpdateQueuedTurn

func (s *Store) UpdateQueuedTurn(ctx context.Context, endpointID string, threadID string, queueID string, textContent string) error

func (*Store) UpdateThreadExecutionMode

func (s *Store) UpdateThreadExecutionMode(ctx context.Context, endpointID string, threadID string, executionMode string) error

func (*Store) UpdateThreadModelID

func (s *Store) UpdateThreadModelID(ctx context.Context, endpointID string, threadID string, modelID string) error

func (*Store) UpdateThreadModelLock

func (s *Store) UpdateThreadModelLock(ctx context.Context, endpointID string, threadID string, locked bool) error

func (*Store) UpdateThreadRunState

func (s *Store) UpdateThreadRunState(
	ctx context.Context,
	endpointID string,
	threadID string,
	runStatus string,
	runError string,
	waitingUserInputJSON string,
	updatedByID string,
	updatedByEmail string,
) error

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) UpsertRun

func (s *Store) UpsertRun(ctx context.Context, rec RunRecord) 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

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

type ThreadsCursor struct {
	UpdatedAtUnixMs int64
	ThreadID        string
}

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"`
}

type UploadRefRecord

type UploadRefRecord struct {
	ID              int64  `json:"id"`
	EndpointID      string `json:"endpoint_id"`
	UploadID        string `json:"upload_id"`
	ThreadID        string `json:"thread_id"`
	RefKind         string `json:"ref_kind"`
	RefID           string `json:"ref_id"`
	CreatedAtUnixMs int64  `json:"created_at_unix_ms"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL