chatstore

package
v0.20260522.1 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssistantDisplayParts

func AssistantDisplayParts(m Message) (reasoning string, visibleContent string)

func BackfillAssistantUsageFromTextIfEmpty

func BackfillAssistantUsageFromTextIfEmpty(m *Message, prior []Message)

func ChatIDHex

func ChatIDHex(title string, ts time.Time) string

func ChatsDir

func ChatsDir(projectHex string) (string, error)

func FinishSessionLoad

func FinishSessionLoad(s *Session)

func IsPlaceholderChatID

func IsPlaceholderChatID(id string) bool

func MessageCheckpointTagVisible

func MessageCheckpointTagVisible(m Message) bool

func MigrateImagePathsAfterChatRename

func MigrateImagePathsAfterChatRename(projectHex string, s *Session, oldChatID, newChatID string) error

func MigrateLegacyCheckpointsToBase0

func MigrateLegacyCheckpointsToBase0(s *Session)

func NewPlaceholderChatID

func NewPlaceholderChatID(t time.Time) string

func PlansDir

func PlansDir(projectHex string) (string, error)

func ProjectWelcomeStats

func ProjectWelcomeStats(projectHex string) (chatCount int, userSum, reasonSum, respSum int64, err error)

func PruneUnreferencedSessionImages

func PruneUnreferencedSessionImages(s *Session)

func ReconcileCheckpointLast

func ReconcileCheckpointLast(s *Session)

func RemoveBrokenSessionImageFiles

func RemoveBrokenSessionImageFiles(s *Session) int

func RemoveSessionPath

func RemoveSessionPath(projectHex, chatID string) error

func RenameSessionFile

func RenameSessionFile(projectHex, oldID, newID string) error

func RepairSessionMalformedImages

func RepairSessionMalformedImages(s *Session) (brokenDropped int, userMsgsAdjusted int, emptyRewrites int)

func RewriteEmptyUserMsgsAfterImageRepair

func RewriteEmptyUserMsgsAfterImageRepair(s *Session) int

func SessionPath

func SessionPath(projectHex, chatIDHex string) (string, error)

func StripAllImgPlaceholders

func StripAllImgPlaceholders(content string) string

func StripImgPlaceholderTags

func StripImgPlaceholderTags(content string) string

func StripStaleUserImgPlaceholdersFromSession

func StripStaleUserImgPlaceholdersFromSession(s *Session) int

func StripUnresolvedImgPlaceholders

func StripUnresolvedImgPlaceholders(content string, imageFiles map[int]string) string

func SubchatPath

func SubchatPath(projectHex, idHex string) (string, error)

func SubchatsDir

func SubchatsDir(projectHex string) (string, error)

func TempDir added in v0.20260522.0

func TempDir(projectHex string) (string, error)

func WriteSession

func WriteSession(projectHex string, s *Session) error

Types

type MainOrphanSegment

type MainOrphanSegment struct {
	ForkAtInclusive int       `json:"fork_at"`
	Messages        []Message `json:"messages"`
}

type Message

type Message struct {
	Role          string     `json:"role"`
	Content       string     `json:"content"`
	ToolCallID    string     `json:"tool_call_id,omitempty"`
	ToolCalls     []ToolCall `json:"tool_calls,omitempty"`
	ReasoningText string     `json:"reasoning_text,omitempty"`

	CheckpointSeq       int    `json:"cp_seq,omitempty"`
	CpSeqSet            bool   `json:"cp_set,omitempty"`
	CheckpointBranchKey string `json:"cp_branch,omitempty"`
	CommitOID           string `json:"commit_oid,omitempty"`

	UserPromptTokens int64 `json:"user_prompt_tokens"`
	ReasoningTokens  int64 `json:"reasoning_tokens"`
	ResponseTokens   int64 `json:"response_tokens"`
	TurnTotalTokens  int64 `json:"turn_total_tokens"`
}

type Session

type Session struct {
	ID                string    `json:"id"`
	Title             string    `json:"title"`
	CreatedAt         time.Time `json:"created_at"`
	LastMessageAt     time.Time `json:"last_message_at"`
	LastUserMessageAt time.Time `json:"last_user_message_at,omitempty"`
	LegacyTools       bool      `json:"legacy_tools,omitempty"`
	Messages          []Message `json:"messages"`

	CheckpointLast           int                 `json:"checkpoint_last"`
	CheckpointCP0            bool                `json:"cp0,omitempty"`
	CheckpointBranchSuffix   string              `json:"cp_branch_suffix,omitempty"`
	ForkChildCount           map[int]int         `json:"fork_child_count,omitempty"`
	MainOrphans              []MainOrphanSegment `json:"main_orphans,omitempty"`
	LastCommitOID            string              `json:"last_commit_oid,omitempty"`
	ImageSeq                 int                 `json:"image_seq,omitempty"`
	ImageFiles               map[int]string      `json:"image_files,omitempty"`
	ActivatedInstructionDirs []string            `json:"activated_instruction_dirs,omitempty"`
}

func FindByTitle

func FindByTitle(projectHex, title string) (*Session, error)

func ListRecent

func ListRecent(projectHex string, n int) ([]*Session, error)

func ReadSession

func ReadSession(projectHex, chatIDHex string) (*Session, error)

func SessionWithLatestUserMessage

func SessionWithLatestUserMessage(projectHex string) (*Session, error)

type ToolCall

type ToolCall struct {
	ID        string `json:"id,omitempty"`
	Name      string `json:"name"`
	Arguments string `json:"arguments"`
}

Jump to

Keyboard shortcuts

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