Documentation
¶
Index ¶
- Variables
- type Item
- type Message
- type Migration
- type MigrationManager
- type Opt
- type SQLiteSessionStore
- func (s *SQLiteSessionStore) AddSession(ctx context.Context, session *Session) error
- func (s *SQLiteSessionStore) Close() error
- func (s *SQLiteSessionStore) DeleteSession(ctx context.Context, id string) error
- func (s *SQLiteSessionStore) GetSession(ctx context.Context, id string) (*Session, error)
- func (s *SQLiteSessionStore) GetSessions(ctx context.Context) ([]*Session, error)
- func (s *SQLiteSessionStore) UpdateSession(ctx context.Context, session *Session) error
- type Session
- func (s *Session) AddMessage(msg *Message)
- func (s *Session) AddSubSession(subSession *Session)
- func (s *Session) GetAllMessages() []Message
- func (s *Session) GetLastAssistantMessageContent() string
- func (s *Session) GetMessages(a *agent.Agent) []chat.Message
- func (s *Session) GetMostRecentAgentFilename() string
- type Store
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptyID = errors.New("session ID cannot be empty") ErrNotFound = errors.New("session not found") )
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct { // Message holds a regular conversation message Message *Message `json:"message,omitempty"` // SubSession holds a complete sub-session from task transfers SubSession *Session `json:"sub_session,omitempty"` // Summary is a summary of the session up until this point Summary string `json:"summary,omitempty"` }
Item represents either a message or a sub-session
func NewMessageItem ¶
NewMessageItem creates a SessionItem containing a message
func NewSubSessionItem ¶
NewSubSessionItem creates a SessionItem containing a sub-session
func (*Item) IsSubSession ¶
IsSubSession returns true if this item contains a sub-session
type Message ¶
type Message struct { AgentFilename string `json:"agentFilename"` AgentName string `json:"agentName"` // TODO: rename to agent_name Message chat.Message `json:"message"` }
Message is a message from an agent
func SystemMessage ¶
func UserMessage ¶
type Migration ¶
type Migration struct { ID int Name string Description string UpSQL string DownSQL string AppliedAt time.Time }
Migration represents a database migration
type MigrationManager ¶
type MigrationManager struct {
// contains filtered or unexported fields
}
MigrationManager handles database migrations
func NewMigrationManager ¶
func NewMigrationManager(db *sql.DB) *MigrationManager
NewMigrationManager creates a new migration manager
func (*MigrationManager) GetAppliedMigrations ¶
func (m *MigrationManager) GetAppliedMigrations(ctx context.Context) ([]Migration, error)
GetAppliedMigrations returns a list of applied migrations
func (*MigrationManager) InitializeMigrations ¶
func (m *MigrationManager) InitializeMigrations(ctx context.Context) error
InitializeMigrations sets up the migrations table and runs pending migrations
func (*MigrationManager) RunPendingMigrations ¶
func (m *MigrationManager) RunPendingMigrations(ctx context.Context) error
RunPendingMigrations executes all migrations that haven't been applied yet
type SQLiteSessionStore ¶
type SQLiteSessionStore struct {
// contains filtered or unexported fields
}
SQLiteSessionStore implements Store using SQLite
func (*SQLiteSessionStore) AddSession ¶
func (s *SQLiteSessionStore) AddSession(ctx context.Context, session *Session) error
AddSession adds a new session to the store
func (*SQLiteSessionStore) Close ¶
func (s *SQLiteSessionStore) Close() error
Close closes the database connection
func (*SQLiteSessionStore) DeleteSession ¶
func (s *SQLiteSessionStore) DeleteSession(ctx context.Context, id string) error
DeleteSession deletes a session by ID
func (*SQLiteSessionStore) GetSession ¶
GetSession retrieves a session by ID
func (*SQLiteSessionStore) GetSessions ¶
func (s *SQLiteSessionStore) GetSessions(ctx context.Context) ([]*Session, error)
GetSessions retrieves all sessions
func (*SQLiteSessionStore) UpdateSession ¶
func (s *SQLiteSessionStore) UpdateSession(ctx context.Context, session *Session) error
UpdateSession updates an existing session
type Session ¶
type Session struct { // ID is the unique identifier for the session ID string `json:"id"` // Title is the title of the session, set by the runtime Title string `json:"title"` // Messages holds the conversation history (messages and sub-sessions) Messages []Item `json:"messages"` // CreatedAt is the time the session was created CreatedAt time.Time `json:"created_at"` // ToolsApproved is a flag to indicate if the tools have been approved ToolsApproved bool `json:"tools_approved"` // SendUserMessage is a flag to indicate if the user message should be sent SendUserMessage bool InputTokens int `json:"input_tokens"` OutputTokens int `json:"output_tokens"` Cost float64 `json:"cost"` }
Session represents the agent's state including conversation history and variables
func (*Session) AddMessage ¶
AddMessage adds a message to the session
func (*Session) AddSubSession ¶
AddSubSession adds a sub-session to the session
func (*Session) GetAllMessages ¶
GetAllMessages extracts all messages from the session, including from sub-sessions
func (*Session) GetLastAssistantMessageContent ¶
func (*Session) GetMostRecentAgentFilename ¶
type Store ¶
type Store interface { AddSession(ctx context.Context, session *Session) error GetSession(ctx context.Context, id string) (*Session, error) GetSessions(ctx context.Context) ([]*Session, error) DeleteSession(ctx context.Context, id string) error UpdateSession(ctx context.Context, session *Session) error }
Store defines the interface for session storage
func NewSQLiteSessionStore ¶
NewSQLiteSessionStore creates a new SQLite session store