threadstore

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FollowupLaneQueued = "queued"
	FollowupLaneDraft  = "draft"
)
View Source
const (
	ThreadTitleSourceAuto = "auto"
	ThreadTitleSourceUser = "user"
)
View Source
const (
	RuntimeRestartedRunErrorCode    = "runtime_restarted"
	RuntimeRestartedRunErrorMessage = "The local runtime restarted before this reply finished."
)
View Source
const (
	ThreadDeleteSnapshotSchemaV1 = 1

	ThreadDeleteOperationPending   = "pending"
	ThreadDeleteOperationCommitted = "committed"
	ThreadDeleteOperationFailed    = "failed"
)
View Source
const (
	UploadStateStaged   = "staged"
	UploadStateLive     = "live"
	UploadStateDeleting = "deleting"

	UploadRefKindMessage    = "message"
	UploadRefKindQueuedTurn = "queued_turn"
)
View Source
const (
	CheckpointKindPreRun = "pre_run"
)
View Source
const ForkSnapshotSchemaVersion = 1

Variables

View Source
var (
	ErrForkOperationConflict   = errors.New("thread fork operation conflicts with existing request")
	ErrForkDestinationConflict = errors.New("thread fork destination conflicts with existing operation")
	ErrForkOperationFailed     = errors.New("thread fork operation is failed")
	ErrForkResultConflict      = errors.New("thread fork result conflicts with source snapshot")
)
View Source
var ErrDuplicateUserTurnMessage = errors.New("duplicate user turn message")
View Source
var ErrFlowerIdempotencyCollision = errors.New("flower idempotency collision")
View Source
var ErrFollowupsRevisionChanged = errors.New("followups revision changed")
View Source
var ErrInvalidFollowupOrder = errors.New("invalid followup order")
View Source
var ErrThreadContextBoundaryChanged = errors.New("thread context boundary changed")
View Source
var ErrThreadIDRetired = errors.New("thread id retired")
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 ChildPermissionSnapshotRecord added in v0.7.2

type ChildPermissionSnapshotRecord struct {
	ChildSnapshotID   string
	EndpointID        string
	ParentSnapshotID  string
	SpawnToolCallID   string
	ParentThreadID    string
	ParentRunID       string
	SubagentID        string
	ChildThreadID     string
	ChildRunID        string
	State             string
	SnapshotJSON      string
	SnapshotHash      string
	RegistryHash      string
	SchemaHash        string
	PresentationHash  string
	CreatedAtUnixMs   int64
	FinalizedAtUnixMs int64
}

type CommitForkOperationRequest added in v0.9.0

type CommitForkOperationRequest struct {
	OperationID      string
	FloretTurnRefs   []ForkTurnRef
	FloretResultJSON string
	UpdatedAtUnixMs  int64
}

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 records product-message and Floret turn correlation for one semantic turn. AssistantMessageID is a presentation/correlation id; Floret-backed turns must not require it to own a transcript row.

type DelegatedApprovalDecisionRequest added in v0.7.2

type DelegatedApprovalDecisionRequest struct {
	EndpointID       string
	ParentThreadID   string
	ActionID         string
	RefHash          string
	Version          int64
	SurfaceEpoch     int64
	Approved         bool
	NextActionJSON   string
	NextVersion      int64
	ResolvedAtUnixMs int64
	ActorScope       string
	IdempotencyKey   string
	ResponseJSON     string
}

type DelegatedApprovalDecisionResult added in v0.7.2

type DelegatedApprovalDecisionResult struct {
	Accepted bool
	Replayed bool
	Conflict bool
	Record   DelegatedApprovalRecord
}

type DelegatedApprovalRecord added in v0.7.2

type DelegatedApprovalRecord struct {
	ActionID            string
	EndpointID          string
	ParentThreadID      string
	ParentUserPublicID  string
	ParentRunID         string
	ParentTurnID        string
	SubagentID          string
	ChildThreadID       string
	ChildRunID          string
	ChildTurnID         string
	ChildToolCallID     string
	ApprovalID          string
	RefHash             string
	RequestFingerprint  string
	State               string
	Status              string
	DeliveryState       string
	ChildExecutionState string
	Version             int64
	SurfaceEpoch        int64
	RequestedAtUnixMs   int64
	ResolvedAtUnixMs    int64
	ExpiresAtUnixMs     int64
	ActionJSON          string
	CreatedAtUnixMs     int64
	UpdatedAtUnixMs     int64
}

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 FlowerActivitySnapshot added in v0.7.2

type FlowerActivitySnapshot struct {
	ActivityRevision    int64
	LastMessageAtUnixMs int64
	ActivitySignature   string
	WaitingPromptID     string
}

type FlowerHandoffRecord added in v0.7.1

type FlowerHandoffRecord struct {
	HandoffID           string `json:"handoff_id"`
	EndpointID          string `json:"endpoint_id"`
	SourceThreadID      string `json:"source_thread_id"`
	DestinationThreadID string `json:"destination_thread_id"`
	IdempotencyKey      string `json:"idempotency_key"`
	EnvelopeHash        string `json:"envelope_hash"`
	State               string `json:"state"`
	EnvelopeJSON        string `json:"envelope_json"`
	CreatedAtUnixMs     int64  `json:"created_at_unix_ms"`
	UpdatedAtUnixMs     int64  `json:"updated_at_unix_ms"`
}

type FlowerThreadMetadata added in v0.7.1

type FlowerThreadMetadata struct {
	EndpointID          string `json:"endpoint_id"`
	ThreadID            string `json:"thread_id"`
	OwnerKind           string `json:"owner_kind"`
	OwnerID             string `json:"owner_id"`
	ParentThreadID      string `json:"parent_thread_id"`
	ParentRunID         string `json:"parent_run_id"`
	ContextJSON         string `json:"context_json"`
	ActionJSON          string `json:"action_json"`
	UpdatedAtUnixMs     int64  `json:"updated_at_unix_ms"`
	HomeRuntimeID       string `json:"home_runtime_id"`
	HomeRuntimeKind     string `json:"home_runtime_kind"`
	OriginEnvPublicID   string `json:"origin_env_public_id"`
	PrimaryTargetID     string `json:"primary_target_id"`
	ActiveTargetIDsJSON string `json:"active_target_ids_json"`
}

type FlowerTransferRecord added in v0.7.1

type FlowerTransferRecord struct {
	TransferID          string `json:"transfer_id"`
	EndpointID          string `json:"endpoint_id"`
	SourceThreadID      string `json:"source_thread_id"`
	DestinationThreadID string `json:"destination_thread_id"`
	IdempotencyKey      string `json:"idempotency_key"`
	ManifestHash        string `json:"manifest_hash"`
	ApprovalHash        string `json:"approval_hash"`
	State               string `json:"state"`
	PlanJSON            string `json:"plan_json"`
	CreatedAtUnixMs     int64  `json:"created_at_unix_ms"`
	UpdatedAtUnixMs     int64  `json:"updated_at_unix_ms"`
}

type FollowupDeleteResourcesResult

type FollowupDeleteResourcesResult struct {
	Revision        int64
	UploadsToDelete []UploadRecord
}

type ForkOperation added in v0.9.0

type ForkOperation struct {
	OperationID                    string
	EndpointID                     string
	SourceThreadID                 string
	DestinationThreadID            string
	RequestFingerprint             string
	Status                         ForkOperationStatus
	SnapshotSchemaVersion          int
	SnapshotJSON                   string
	FloretResultJSON               string
	RetryCount                     int
	ErrorCode                      string
	ErrorMessage                   string
	SourceBroadcastedAtUnixMs      int64
	DestinationBroadcastedAtUnixMs int64
	CreatedAtUnixMs                int64
	UpdatedAtUnixMs                int64
}

type ForkOperationStatus added in v0.9.0

type ForkOperationStatus string
const (
	ForkOperationPending   ForkOperationStatus = "pending"
	ForkOperationCommitted ForkOperationStatus = "committed"
	ForkOperationFailed    ForkOperationStatus = "failed"
)

type ForkThreadRequest added in v0.7.1

type ForkThreadRequest struct {
	OperationID           string
	EndpointID            string
	SourceThreadID        string
	DestinationThreadID   string
	Title                 string
	CreatedByUserPublicID string
	CreatedByUserEmail    string
	CreatedAtUnixMs       int64
}

type ForkTurnRef added in v0.7.2

type ForkTurnRef struct {
	SourceTurnID      string
	SourceRunID       string
	DestinationTurnID string
	DestinationRunID  string
	CreatedAtUnixMs   int64
}

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 PermissionSnapshotRecord added in v0.7.2

type PermissionSnapshotRecord struct {
	SnapshotID       string
	EndpointID       string
	OwnerThreadID    string
	OwnerRunID       string
	PermissionType   string
	SnapshotJSON     string
	SnapshotHash     string
	RegistryHash     string
	SchemaHash       string
	PresentationHash string
	CreatedAtUnixMs  int64
}

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 ProviderContinuationState added in v0.7.1

type ProviderContinuationState struct {
	Kind       string            `json:"kind,omitempty"`
	ID         string            `json:"id,omitempty"`
	Attributes map[string]string `json:"attributes,omitempty"`
}

func (ProviderContinuationState) IsZero added in v0.7.1

func (s ProviderContinuationState) IsZero() bool

type QueuedThread added in v0.7.2

type QueuedThread struct {
	EndpointID           string `json:"endpoint_id"`
	ThreadID             string `json:"thread_id"`
	RunStatus            string `json:"run_status"`
	RunErrorCode         string `json:"run_error_code"`
	RunError             string `json:"run_error"`
	WaitingUserInputJSON string `json:"waiting_user_input_json"`
	NamespacePublicID    string `json:"namespace_public_id"`
	QueuedTurnCount      int    `json:"queued_turn_count"`
	FirstQueuedAtUnixMs  int64  `json:"first_queued_at_unix_ms"`
	FirstQueuedSortIndex int64  `json:"first_queued_sort_index"`
	FirstQueuedTurnID    string `json:"first_queued_turn_id"`
}

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"`
	ContextActionJSON string `json:"context_action_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 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 StartUserTurn added in v0.7.2

type StartUserTurn struct {
	EndpointID              string
	ThreadID                string
	UserMessage             Message
	UploadIDs               []string
	Run                     RunRecord
	Turn                    ConversationTurn
	RunState                ThreadRunStateWrite
	SourceQueueID           string
	RequireSourceQueue      bool
	StructuredUserInputs    []StructuredUserInputRecord
	RequestUserInputSecrets []RequestUserInputSecretAnswerRecord
	UploadClaimedAtUnixMs   int64
}

type StartUserTurnResult added in v0.7.2

type StartUserTurnResult struct {
	UserMessageID              string
	UserMessageRowID           int64
	UserMessageJSON            string
	UserMessageCreatedAtUnixMs int64
	ConversationTurnRowID      int64
	FollowupsRevision          int64
	UploadsToDelete            []UploadRecord
}

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 OpenResettingInvalidSchema added in v0.7.1

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

func (*Store) AppendConversationTurn

func (s *Store) AppendConversationTurn(ctx context.Context, rec ConversationTurn) (int64, 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) CommitForkOperation added in v0.9.0

func (s *Store) CommitForkOperation(ctx context.Context, req CommitForkOperationRequest) (*Thread, error)

func (*Store) ConfirmThreadDeleteFilesCleaned added in v0.9.0

func (s *Store) ConfirmThreadDeleteFilesCleaned(ctx context.Context, operationID string) (ThreadDeleteOperation, error)

func (*Store) ConfirmThreadDeleteFloretDeleted added in v0.9.0

func (s *Store) ConfirmThreadDeleteFloretDeleted(ctx context.Context, operationID string) (ThreadDeleteOperation, error)

func (*Store) ConfirmThreadDeleteReadStateDeleted added in v0.9.0

func (s *Store) ConfirmThreadDeleteReadStateDeleted(ctx context.Context, operationID string) (ThreadDeleteOperation, 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) CurrentThreadContextBoundary added in v0.7.2

func (s *Store) CurrentThreadContextBoundary(ctx context.Context, endpointID string, threadID string) (ThreadContextBoundary, 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) FinalizeChildPermissionSnapshot added in v0.7.2

func (s *Store) FinalizeChildPermissionSnapshot(ctx context.Context, endpointID string, childSnapshotID string, childThreadID string, childRunID string, finalizedAtUnixMs int64) (bool, error)

func (*Store) FinalizeDeletedUploads

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

func (*Store) GetChildPermissionSnapshotBySpawnToolCall added in v0.7.2

func (s *Store) GetChildPermissionSnapshotBySpawnToolCall(ctx context.Context, endpointID string, spawnToolCallID string) (ChildPermissionSnapshotRecord, bool, error)

func (*Store) GetDelegatedApprovalRequest added in v0.7.2

func (s *Store) GetDelegatedApprovalRequest(ctx context.Context, endpointID string, parentThreadID string, actionID string) (DelegatedApprovalRecord, bool, error)

func (*Store) GetFinalizedChildPermissionSnapshot added in v0.7.2

func (s *Store) GetFinalizedChildPermissionSnapshot(ctx context.Context, endpointID string, childThreadID string, childRunID string) (ChildPermissionSnapshotRecord, bool, error)

func (*Store) GetFinalizedChildPermissionSnapshotByThread added in v0.7.2

func (s *Store) GetFinalizedChildPermissionSnapshotByThread(ctx context.Context, endpointID string, childThreadID string) (ChildPermissionSnapshotRecord, bool, error)

func (*Store) GetFirstUserThreadMessage

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

func (*Store) GetFlowerHandoffByIdempotencyKey added in v0.7.1

func (s *Store) GetFlowerHandoffByIdempotencyKey(ctx context.Context, endpointID string, idempotencyKey string) (*FlowerHandoffRecord, error)

func (*Store) GetFlowerThreadMetadata added in v0.7.1

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

func (*Store) GetFlowerTransferByIdempotencyKey added in v0.7.1

func (s *Store) GetFlowerTransferByIdempotencyKey(ctx context.Context, endpointID string, idempotencyKey string) (*FlowerTransferRecord, error)

func (*Store) GetForkOperation added in v0.9.0

func (s *Store) GetForkOperation(ctx context.Context, operationID string) (*ForkOperation, error)

func (*Store) GetLatestThreadCheckpoint

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

func (*Store) GetPermissionSnapshot added in v0.7.2

func (s *Store) GetPermissionSnapshot(ctx context.Context, endpointID string, snapshotID string) (PermissionSnapshotRecord, bool, 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) GetRun added in v0.7.2

func (s *Store) GetRun(ctx context.Context, endpointID string, runID string) (*RunRecord, 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) GetThreadDeleteOperation added in v0.9.0

func (s *Store) GetThreadDeleteOperation(ctx context.Context, endpointID string, threadID string) (*ThreadDeleteOperation, 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) InsertChildPermissionSnapshot added in v0.7.2

func (s *Store) InsertChildPermissionSnapshot(ctx context.Context, rec ChildPermissionSnapshotRecord) error

func (*Store) InsertChildPermissionSnapshotProvisional added in v0.7.2

func (s *Store) InsertChildPermissionSnapshotProvisional(ctx context.Context, rec ChildPermissionSnapshotRecord) error

func (*Store) InsertFlowerHandoff added in v0.7.1

func (s *Store) InsertFlowerHandoff(ctx context.Context, rec FlowerHandoffRecord) (FlowerHandoffRecord, error)

func (*Store) InsertFlowerTransfer added in v0.7.1

func (s *Store) InsertFlowerTransfer(ctx context.Context, rec FlowerTransferRecord) (FlowerTransferRecord, error)

func (*Store) InsertPermissionSnapshot added in v0.7.2

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

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

func (*Store) ListConversationTurnsBefore added in v0.7.2

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

func (*Store) ListDelegatedApprovalRequestsForThread added in v0.7.2

func (s *Store) ListDelegatedApprovalRequestsForThread(ctx context.Context, endpointID string, parentThreadID string, limit int) ([]DelegatedApprovalRecord, error)

func (*Store) ListExecutionSpansByRun

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

func (*Store) ListFlowerThreadMetadataByParent added in v0.7.2

func (s *Store) ListFlowerThreadMetadataByParent(ctx context.Context, endpointID string, parentThreadID string) ([]FlowerThreadMetadata, 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) ListPendingForkOperations added in v0.9.0

func (s *Store) ListPendingForkOperations(ctx context.Context, limit int) ([]ForkOperation, error)

func (*Store) ListPendingThreadDeleteOperations added in v0.9.0

func (s *Store) ListPendingThreadDeleteOperations(ctx context.Context, limit int) ([]ThreadDeleteOperation, error)

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) ListThreadContextRunEvents added in v0.7.2

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

func (*Store) ListThreads

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

func (*Store) ListThreadsWithQueuedTurns added in v0.7.2

func (s *Store) ListThreadsWithQueuedTurns(ctx context.Context, limit int) ([]QueuedThread, error)

func (*Store) ListUnbroadcastCommittedForkOperations added in v0.9.0

func (s *Store) ListUnbroadcastCommittedForkOperations(ctx context.Context, limit int) ([]ForkOperation, error)

func (*Store) MarkDelegatedApprovalAckUnknown added in v0.7.2

func (s *Store) MarkDelegatedApprovalAckUnknown(ctx context.Context, endpointID string, parentThreadID string, actionID string, reason string, nextActionJSON string, nowUnixMs int64) (bool, error)

func (*Store) MarkDelegatedApprovalCanceled added in v0.8.0

func (s *Store) MarkDelegatedApprovalCanceled(ctx context.Context, endpointID string, parentThreadID string, actionID string, nextVersion int64, nextActionJSON string, reason string, nowUnixMs int64) (bool, error)

func (*Store) MarkDelegatedApprovalDelivered added in v0.7.2

func (s *Store) MarkDelegatedApprovalDelivered(ctx context.Context, endpointID string, parentThreadID string, actionID string, version int64, nextActionJSON string, deliveredAtUnixMs int64) (bool, error)

func (*Store) MarkDelegatedApprovalUnavailable added in v0.7.2

func (s *Store) MarkDelegatedApprovalUnavailable(ctx context.Context, endpointID string, parentThreadID string, actionID string, reason string, nextActionJSON string, nowUnixMs int64) (bool, error)

func (*Store) MarkForkOperationBroadcasted added in v0.9.0

func (s *Store) MarkForkOperationBroadcasted(ctx context.Context, operationID string, source bool, atUnixMs int64) error

func (*Store) MarkPendingDelegatedApprovalsUnavailable added in v0.7.2

func (s *Store) MarkPendingDelegatedApprovalsUnavailable(ctx context.Context, reason string, nowUnixMs int64) (int64, error)

func (*Store) MarkThreadDeleteFailed added in v0.9.0

func (s *Store) MarkThreadDeleteFailed(ctx context.Context, operationID string, errorCode string, errorMessage string) (ThreadDeleteOperation, 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) PrepareForkOperation added in v0.9.0

func (s *Store) PrepareForkOperation(ctx context.Context, req ForkThreadRequest) (*ForkOperation, error)

func (*Store) PrepareThreadDeleteOperation added in v0.9.0

func (s *Store) PrepareThreadDeleteOperation(ctx context.Context, endpointID string, threadID string, deleteFlowerReadState bool) (ThreadDeleteOperation, error)

func (*Store) PruneThreadCheckpoints

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

func (*Store) RecordForkOperationFailure added in v0.9.0

func (s *Store) RecordForkOperationFailure(ctx context.Context, operationID string, code string, message string, terminal bool, updatedAtUnixMs int64) error

func (*Store) RecordThreadDeleteRetry added in v0.9.0

func (s *Store) RecordThreadDeleteRetry(ctx context.Context, operationID string, errorCode string, errorMessage string) (ThreadDeleteOperation, 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) 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) 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) SetThreadPinned added in v0.7.1

func (s *Store) SetThreadPinned(ctx context.Context, endpointID string, threadID string, pinned bool, updatedByID string, updatedByEmail string) (int64, error)

func (*Store) SetThreadProviderContinuation

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

func (*Store) SetThreadProviderContinuationIfBoundaryMatches added in v0.7.2

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

func (*Store) StartUserTurn added in v0.7.2

func (s *Store) StartUserTurn(ctx context.Context, rec StartUserTurn) (StartUserTurnResult, error)

func (*Store) SubmitDelegatedApprovalDecisionCAS added in v0.7.2

func (s *Store) SubmitDelegatedApprovalDecisionCAS(ctx context.Context, req DelegatedApprovalDecisionRequest) (DelegatedApprovalDecisionResult, error)

func (*Store) UpdateFollowupText

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

func (*Store) UpdatePendingDelegatedApprovalPresentation added in v0.8.0

func (s *Store) UpdatePendingDelegatedApprovalPresentation(ctx context.Context, rec DelegatedApprovalRecord) (bool, error)

func (*Store) UpdateQueuedTurn

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

func (*Store) UpdateThreadLastMessagePreview added in v0.7.2

func (s *Store) UpdateThreadLastMessagePreview(ctx context.Context, endpointID string, threadID string, preview string, atUnixMs int64, updatedByID string, updatedByEmail string) error

func (*Store) UpdateThreadModelAndReasoningSelection added in v0.7.2

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

func (*Store) UpdateThreadModelID

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

func (*Store) UpdateThreadPermissionType added in v0.7.2

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

func (*Store) UpdateThreadReasoningSelection added in v0.7.2

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

func (*Store) UpdateThreadRunState

func (s *Store) UpdateThreadRunState(
	ctx context.Context,
	endpointID string,
	threadID string,
	runStatus string,
	runErrorCode 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) UpsertDelegatedApprovalRequest added in v0.7.2

func (s *Store) UpsertDelegatedApprovalRequest(ctx context.Context, rec DelegatedApprovalRecord) error

func (*Store) UpsertExecutionSpan

func (s *Store) UpsertExecutionSpan(ctx context.Context, rec ExecutionSpanRecord) error

func (*Store) UpsertFlowerThreadMetadata added in v0.7.1

func (s *Store) UpsertFlowerThreadMetadata(ctx context.Context, rec FlowerThreadMetadata) error

func (*Store) UpsertMemoryItem

func (s *Store) UpsertMemoryItem(ctx context.Context, rec MemoryItemRecord) error

func (*Store) UpsertProjectedMessage added in v0.7.2

func (s *Store) UpsertProjectedMessage(ctx context.Context, endpointID string, threadID string, m Message, updatedByID string, updatedByEmail string) (int64, error)

UpsertProjectedMessage stores or replaces one host-owned transcript message identified by endpoint, thread, and message id.

func (*Store) UpsertProjectedThread added in v0.7.2

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

UpsertProjectedThread stores a host-owned thread projection without assuming the normal user-created thread lifecycle.

func (*Store) UpsertProjectedThreadWithFlowerMetadata added in v0.7.2

func (s *Store) UpsertProjectedThreadWithFlowerMetadata(ctx context.Context, t Thread, meta FlowerThreadMetadata) error

UpsertProjectedThreadWithFlowerMetadata atomically stores a projected thread and its Flower ownership metadata, so projection-only threads cannot leak into ordinary thread-list queries between separate writes.

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"`
	ReasoningSelectionJSON string `json:"reasoning_selection_json"`
	PermissionType         string `json:"permission_type"`
	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"`
	RunErrorCode           string `json:"run_error_code"`
	RunError               string `json:"run_error"`
	WaitingUserInputJSON   string `json:"waiting_user_input_json"`
	LastContextRunID       string `json:"last_context_run_id"`
	PinnedAtUnixMs         int64  `json:"pinned_at_unix_ms"`

	FlowerActivityRevision        int64  `json:"flower_activity_revision"`
	FlowerActivitySignature       string `json:"flower_activity_signature"`
	FlowerActivityWaitingPromptID string `json:"flower_activity_waiting_prompt_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"`

	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 record for a single thread checkpoint.

type ThreadContextBoundary added in v0.7.2

type ThreadContextBoundary struct {
	TurnRowID int64
	MessageID int64
}

type ThreadDeleteOperation added in v0.9.0

type ThreadDeleteOperation struct {
	OperationID                string
	EndpointID                 string
	ThreadID                   string
	Status                     string
	Snapshot                   ThreadDeleteSnapshotV1
	SnapshotValid              bool
	SnapshotErrorCode          string
	ProductDataDeletedAtUnixMs int64
	FilesCleanedAtUnixMs       int64
	FloretDeletedAtUnixMs      int64
	ReadStateDeletedAtUnixMs   int64
	RetryCount                 int
	ErrorCode                  string
	ErrorMessage               string
	CreatedAtUnixMs            int64
	UpdatedAtUnixMs            int64
	CommittedAtUnixMs          int64
}

type ThreadDeleteResourcesResult

type ThreadDeleteResourcesResult struct {
	CheckpointIDs   []string
	UploadsToDelete []UploadRecord
}

type ThreadDeleteSnapshotV1 added in v0.9.0

type ThreadDeleteSnapshotV1 struct {
	SchemaVersion         int      `json:"schema_version"`
	CheckpointIDs         []string `json:"checkpoint_ids"`
	UploadCleanupIDs      []string `json:"upload_cleanup_ids"`
	DeleteFlowerReadState bool     `json:"delete_flower_read_state"`
}

type ThreadProviderContinuation

type ThreadProviderContinuation struct {
	State           ProviderContinuationState `json:"state"`
	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 ThreadRunStateWrite added in v0.7.2

type ThreadRunStateWrite struct {
	Status                string
	ErrorCode             string
	ErrorMessage          string
	WaitingUserInputJSON  string
	UpdatedByUserPublicID string
	UpdatedByUserEmail    string
	UpdatedAtUnixMs       int64
}

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 {
	PinnedAtUnixMs  int64
	CreatedAtUnixMs 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