session

package
v0.1.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNoReplySession

func IsNoReplySession(metrics MessageMetrics) bool

func IsZeroMessageSession

func IsZeroMessageSession(metrics MessageMetrics) bool

Types

type ActiveSkill

type ActiveSkill struct {
	Name        string            `json:"name"`
	Args        map[string]string `json:"args,omitempty"`
	ActivatedAt time.Time         `json:"activated_at,omitempty"`
}

type CleanupResult

type CleanupResult struct {
	DeletedIDs []string
}

type Conversation

type Conversation struct {
	Meta     ConversationMeta   `json:"meta,omitempty"`
	Timeline []llm.Message      `json:"timeline"`
	Assets   ConversationAssets `json:"assets,omitempty"`
}

type ConversationAssets

type ConversationAssets struct {
	Images map[llm.AssetID]ImageAssetMeta `json:"images,omitempty"`
}

type ConversationMeta

type ConversationMeta map[string]any

type ImageAssetMeta

type ImageAssetMeta struct {
	ImageID   int    `json:"image_id"`
	MediaType string `json:"media_type"`
	FileName  string `json:"file_name,omitempty"`
	CachePath string `json:"cache_path"`
	ByteSize  int64  `json:"byte_size"`
	Width     int    `json:"width,omitempty"`
	Height    int    `json:"height,omitempty"`
}

type MessageMetrics

type MessageMetrics struct {
	RawMessageCount               int
	UserEffectiveInputCount       int
	AssistantEffectiveOutputCount int
}

func CountMessageMetrics

func CountMessageMetrics(messages []llm.Message) MessageMetrics

type Session

type Session struct {
	ID           string            `json:"id"`
	Workspace    string            `json:"workspace"`
	Title        string            `json:"title,omitempty"`
	CreatedAt    time.Time         `json:"created_at"`
	UpdatedAt    time.Time         `json:"updated_at"`
	Conversation Conversation      `json:"conversation,omitempty"`
	Messages     []llm.Message     `json:"messages,omitempty"`
	Mode         planpkg.AgentMode `json:"mode,omitempty"`
	Plan         planpkg.State     `json:"plan,omitempty"`
	ActiveSkill  *ActiveSkill      `json:"active_skill,omitempty"`
}

func New

func New(workspace string) *Session

type SessionEvent

type SessionEvent struct {
	EventID       string          `json:"event_id"`
	SessionID     string          `json:"session_id"`
	Seq           int64           `json:"seq"`
	Type          string          `json:"type"`
	TS            time.Time       `json:"ts"`
	SchemaVersion int             `json:"schema_version"`
	Payload       json.RawMessage `json:"payload,omitempty"`
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore(dir string) (*Store, error)

func (*Store) CleanupZeroMessageSessions

func (s *Store) CleanupZeroMessageSessions(workspace, activeSessionID string) (CleanupResult, error)

func (*Store) Delete

func (s *Store) Delete(id string) error

func (*Store) DeleteInWorkspace

func (s *Store) DeleteInWorkspace(workspace, id string) error

func (*Store) List

func (s *Store) List(limit int) ([]Summary, []string, error)

func (*Store) Load

func (s *Store) Load(id string) (*Session, error)

func (*Store) ReadEvents

func (s *Store) ReadEvents(sessionID string, afterSeq int64) ([]SessionEvent, error)

func (*Store) ReadFrom

func (s *Store) ReadFrom(sessionID string, offset int64, limit int) ([]SessionEvent, int64, error)

func (*Store) Replay

func (s *Store) Replay(sessionID string) (*Session, error)

func (*Store) Save

func (s *Store) Save(session *Session) error

func (*Store) Snapshot

func (s *Store) Snapshot(sessionID string) (err error)

type Summary

type Summary struct {
	ID                            string    `json:"id"`
	Workspace                     string    `json:"workspace"`
	Title                         string    `json:"title,omitempty"`
	Preview                       string    `json:"preview,omitempty"`
	CreatedAt                     time.Time `json:"created_at"`
	UpdatedAt                     time.Time `json:"updated_at"`
	LastUserMessage               string    `json:"last_user_message,omitempty"`
	MessageCount                  int       `json:"message_count"`
	RawMessageCount               int       `json:"raw_msg_count"`
	UserEffectiveInputCount       int       `json:"user_effective_input_count"`
	AssistantEffectiveOutputCount int       `json:"assistant_effective_output_count"`
	ZeroMsgSession                bool      `json:"zero_msg_session"`
	NoReplySession                bool      `json:"no_reply_session"`
}

Jump to

Keyboard shortcuts

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