session

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TitleSourceAuto = "auto"
	TitleSourceUser = "user"

	TitleStatePending = "pending"
	TitleStateStable  = "stable"
)

Variables

This section is empty.

Functions

func RefreshTitle

func RefreshTitle(sess *Session) bool

RefreshTitle updates the session title when it is auto-managed.

Types

type Manager

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

Manager 会话管理器

func NewManager

func NewManager(workspace string) *Manager

NewManager 创建会话管理器

func (*Manager) Delete

func (m *Manager) Delete(key string) error

Delete 删除会话

func (*Manager) GetOrCreate

func (m *Manager) GetOrCreate(key string) *Session

GetOrCreate 获取或创建会话

func (*Manager) Save

func (m *Manager) Save(session *Session) error

Save 保存会话

type Message

type Message struct {
	Role      string          `json:"role"`
	Content   string          `json:"content"`
	Timeline  []TimelineEntry `json:"timeline,omitempty"`
	Timestamp time.Time       `json:"timestamp"`
}

Message 会话消息

type Session

type Session struct {
	Key              string    `json:"key"`
	Title            string    `json:"title,omitempty"`
	TitleSource      string    `json:"titleSource,omitempty"`
	TitleState       string    `json:"titleState,omitempty"`
	TitleUpdatedAt   time.Time `json:"titleUpdatedAt,omitempty"`
	Messages         []Message `json:"messages"`
	LastConsolidated int       `json:"lastConsolidated,omitempty"`
}

Session 会话

func (*Session) AddMessage

func (s *Session) AddMessage(role, content string)

AddMessage 添加消息到会话

func (*Session) AddMessageWithTimeline

func (s *Session) AddMessageWithTimeline(role, content string, timeline []TimelineEntry)

func (*Session) Clear

func (s *Session) Clear()

Clear 清空会话

func (*Session) GetHistory

func (s *Session) GetHistory(maxMessages ...int) []Message

GetHistory 获取历史记录

type TimelineActivity

type TimelineActivity struct {
	Type    string `json:"type"`
	Summary string `json:"summary"`
	Detail  string `json:"detail,omitempty"`
}

type TimelineEntry

type TimelineEntry struct {
	Kind     string            `json:"kind"`
	Activity *TimelineActivity `json:"activity,omitempty"`
	Text     string            `json:"text,omitempty"`
}

Jump to

Keyboard shortcuts

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