package store import ( "context" "errors" "time" ) var ( // ErrSessionNotFound 会话不存在。 ErrSessionNotFound = errors.New("session not found") ) // SessionRepository 会话持久化接口。 type SessionRepository interface { // Save 创建或更新会话(UPSERT)。 Save(ctx context.Context, s SessionRecord) error // FindByID 根据 ID 查询会话。 FindByID(ctx context.Context, id string) (*SessionRecord, error) // FindByUser 查询用户的会话列表(分页,按 updated_at 降序)。 // 返回 (列表, 总数, error)。 FindByUser(ctx context.Context, userID string, page, size int) ([]SessionRecord, int, error) // UpdateTitle 更新会话标题。 UpdateTitle(ctx context.Context, id string, title string) error // UpdateConfig 更新会话配置。 UpdateConfig(ctx context.Context, id string, configJSON []byte) error // Touch 刷新 updated_at。 Touch(ctx context.Context, id string) error // Delete 删除会话。 Delete(ctx context.Context, id string) error } // SessionRecord 持久化会话模型(store 层)。 type SessionRecord struct { ID string UserID string Title string Config []byte // JSON 编码的 SessionConfig CreatedAt time.Time UpdatedAt time.Time }