session

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

func NewManager

func NewManager(db *sql.DB, logger *slog.Logger) *Manager

func (*Manager) EndSession

func (m *Manager) EndSession(ctx context.Context, sessionID string) error

EndSession sets ended_at on the session.

func (*Manager) EndStaleSessions

func (m *Manager) EndStaleSessions(ctx context.Context, maxAge time.Duration) (int, error)

EndStaleSessions ends sessions with no activity for longer than maxAge. Returns the count of sessions closed.

func (*Manager) GetActiveSession

func (m *Manager) GetActiveSession(ctx context.Context, sourceSessionID string) (*Session, error)

GetActiveSession returns the active (not ended) session for sourceSessionID, or nil.

func (*Manager) RecordActivity

func (m *Manager) RecordActivity(ctx context.Context, sessionID string) error

RecordActivity bumps last_activity_at and increments message_count.

func (*Manager) SessionStats

func (m *Manager) SessionStats(ctx context.Context) (total int, active int, err error)

SessionStats returns total and active session counts.

func (*Manager) StartSession

func (m *Manager) StartSession(ctx context.Context, sourceTool, sourceSessionID, projectID, directory string) (string, error)

StartSession creates a new live session or resumes an existing active one matching sourceSessionID.

type Session

type Session struct {
	ID              string     `json:"id"`
	ProjectID       *string    `json:"project_id,omitempty"`
	Source          string     `json:"source"`
	SourceSessionID string     `json:"source_session_id,omitempty"`
	Title           string     `json:"title,omitempty"`
	Directory       string     `json:"directory,omitempty"`
	CreatedAt       *time.Time `json:"created_at,omitempty"`
	LastActivityAt  *time.Time `json:"last_activity_at,omitempty"`
	EndedAt         *time.Time `json:"ended_at,omitempty"`
	MessageCount    int        `json:"message_count"`
	SourceTool      string     `json:"source_tool,omitempty"`
	Metadata        any        `json:"metadata,omitempty"`
}

Jump to

Keyboard shortcuts

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