Files
kandev/apps/backend/internal/task/repository/interface.go
T
jcfs 7b3e94d6dc feat(backend): add persistent agent session tracking
- Add AgentSession database entity with SQLite persistence
- Implement AgentSession CRUD operations in repository layer
- Update executor to use hybrid cache + database approach
- Add session restoration on startup (LoadActiveSessionsFromDB)
- Link comments to agent sessions via agent_session_id
- Fix SQLite NULL handling for nullable task fields
- Add dev database setup with seed data (make dev, make dev-db-reset)
- Update Makefile with dev targets for development mode

This enables agent sessions to persist across backend restarts,
solving the 'execution not found' error for resumed conversations.
2026-01-12 02:02:47 +00:00

78 lines
3.8 KiB
Go

package repository
import (
"context"
"github.com/kandev/kandev/internal/task/models"
v1 "github.com/kandev/kandev/pkg/api/v1"
)
// Repository defines the interface for task storage operations
type Repository interface {
// Workspace operations
CreateWorkspace(ctx context.Context, workspace *models.Workspace) error
GetWorkspace(ctx context.Context, id string) (*models.Workspace, error)
UpdateWorkspace(ctx context.Context, workspace *models.Workspace) error
DeleteWorkspace(ctx context.Context, id string) error
ListWorkspaces(ctx context.Context) ([]*models.Workspace, error)
// Task operations
CreateTask(ctx context.Context, task *models.Task) error
GetTask(ctx context.Context, id string) (*models.Task, error)
UpdateTask(ctx context.Context, task *models.Task) error
DeleteTask(ctx context.Context, id string) error
ListTasks(ctx context.Context, boardID string) ([]*models.Task, error)
ListTasksByColumn(ctx context.Context, columnID string) ([]*models.Task, error)
UpdateTaskState(ctx context.Context, id string, state v1.TaskState) error
AddTaskToBoard(ctx context.Context, taskID, boardID, columnID string, position int) error
RemoveTaskFromBoard(ctx context.Context, taskID, boardID string) error
// Board operations
CreateBoard(ctx context.Context, board *models.Board) error
GetBoard(ctx context.Context, id string) (*models.Board, error)
UpdateBoard(ctx context.Context, board *models.Board) error
DeleteBoard(ctx context.Context, id string) error
ListBoards(ctx context.Context, workspaceID string) ([]*models.Board, error)
// Column operations
CreateColumn(ctx context.Context, column *models.Column) error
GetColumn(ctx context.Context, id string) (*models.Column, error)
UpdateColumn(ctx context.Context, column *models.Column) error
DeleteColumn(ctx context.Context, id string) error
ListColumns(ctx context.Context, boardID string) ([]*models.Column, error)
// Comment operations
CreateComment(ctx context.Context, comment *models.Comment) error
GetComment(ctx context.Context, id string) (*models.Comment, error)
ListComments(ctx context.Context, taskID string) ([]*models.Comment, error)
DeleteComment(ctx context.Context, id string) error
// Agent Session operations
CreateAgentSession(ctx context.Context, session *models.AgentSession) error
GetAgentSession(ctx context.Context, id string) (*models.AgentSession, error)
GetAgentSessionByTaskID(ctx context.Context, taskID string) (*models.AgentSession, error)
GetActiveAgentSessionByTaskID(ctx context.Context, taskID string) (*models.AgentSession, error)
UpdateAgentSession(ctx context.Context, session *models.AgentSession) error
UpdateAgentSessionStatus(ctx context.Context, id string, status models.AgentSessionStatus, errorMessage string) error
ListAgentSessions(ctx context.Context, taskID string) ([]*models.AgentSession, error)
ListActiveAgentSessions(ctx context.Context) ([]*models.AgentSession, error)
DeleteAgentSession(ctx context.Context, id string) error
// Repository operations
CreateRepository(ctx context.Context, repository *models.Repository) error
GetRepository(ctx context.Context, id string) (*models.Repository, error)
UpdateRepository(ctx context.Context, repository *models.Repository) error
DeleteRepository(ctx context.Context, id string) error
ListRepositories(ctx context.Context, workspaceID string) ([]*models.Repository, error)
// Repository script operations
CreateRepositoryScript(ctx context.Context, script *models.RepositoryScript) error
GetRepositoryScript(ctx context.Context, id string) (*models.RepositoryScript, error)
UpdateRepositoryScript(ctx context.Context, script *models.RepositoryScript) error
DeleteRepositoryScript(ctx context.Context, id string) error
ListRepositoryScripts(ctx context.Context, repositoryID string) ([]*models.RepositoryScript, error)
// Close closes the repository (for database connections)
Close() error
}