Files
kandev/apps/backend/pkg/api/v1/task.go
T
João Salavisa 82e8c8905b feat: replace agent_type with agent_profile_id (#14)
* feat: replace agent_type with agent_profile_id

- Replace agent_type field with agent_profile_id across backend and frontend
- Add ProfileResolver interface and StoreProfileResolver implementation
- Update task creation/update to use agent_profile_id
- Change default agent runtime from docker to standalone
- Fix workspace state types to include all required fields
- Fix websocket handlers type mismatches for environments, executors, workspaces
- Update integration tests to use agent_profile_id

* feat: pass model as CLI argument to agents

- Add ModelFlag field to AgentTypeConfig for specifying the CLI flag
- Set ModelFlag to '--model' for all agents (auggie, claude, codex, gemini, opencode, copilot)
- Update launchStandalone to append model flag to agent command
- Update launchDocker/buildContainerConfig to append model flag to container command
- Model is passed when both agent supports ModelFlag and profile has Model configured

* fix: make WebSocket message handling async to prevent blocking

When a long-running handler like orchestrator.prompt was executing,
it blocked the ReadPump loop, preventing other requests (like
workspace.tree.get) from being processed until the handler completed.

Now each message is handled in its own goroutine, allowing concurrent
message handling so file tree requests work while the agent is working.

* feat: show task description as first message in chat

- Add 'Task' label with distinct styling (lighter background, border)
- Pass taskDescription from page to TaskChatPanel component
- Differentiate from regular user messages visually
2026-01-14 12:29:58 +00:00

131 lines
6.2 KiB
Go

package v1
import "time"
// TaskState represents the state of a task
type TaskState string
const (
TaskStateTODO TaskState = "TODO"
TaskStateCreated TaskState = "CREATED"
TaskStateScheduling TaskState = "SCHEDULING"
TaskStateInProgress TaskState = "IN_PROGRESS"
TaskStateReview TaskState = "REVIEW"
TaskStateBlocked TaskState = "BLOCKED"
TaskStateWaitingForInput TaskState = "WAITING_FOR_INPUT"
TaskStateCompleted TaskState = "COMPLETED"
TaskStateFailed TaskState = "FAILED"
TaskStateCancelled TaskState = "CANCELLED"
)
// Task represents a Kanban task
type Task struct {
ID string `json:"id"`
WorkspaceID string `json:"workspace_id"`
BoardID string `json:"board_id"`
Title string `json:"title"`
Description string `json:"description"`
State TaskState `json:"state"`
Priority int `json:"priority"`
AgentProfileID *string `json:"agent_profile_id,omitempty"`
RepositoryURL *string `json:"repository_url,omitempty"`
Branch *string `json:"branch,omitempty"`
AssignedAgentID *string `json:"assigned_agent_id,omitempty"`
CreatedBy string `json:"created_by"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
// CreateTaskRequest for creating a new task
type CreateTaskRequest struct {
Title string `json:"title" binding:"required,max=500"`
Description string `json:"description" binding:"required"`
Priority int `json:"priority" binding:"min=0,max=10"`
AgentProfileID *string `json:"agent_profile_id,omitempty"`
RepositoryURL *string `json:"repository_url,omitempty"`
Branch *string `json:"branch,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
// UpdateTaskRequest for updating an existing task
type UpdateTaskRequest struct {
Title *string `json:"title,omitempty" binding:"omitempty,max=500"`
Description *string `json:"description,omitempty"`
Priority *int `json:"priority,omitempty" binding:"omitempty,min=0,max=10"`
AgentType *string `json:"agent_type,omitempty"`
RepositoryURL *string `json:"repository_url,omitempty"`
Branch *string `json:"branch,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
// UpdateTaskStateRequest for changing task state
type UpdateTaskStateRequest struct {
State TaskState `json:"state" binding:"required"`
}
// TaskEvent for task history/audit
type TaskEvent struct {
ID int64 `json:"id"`
TaskID string `json:"task_id"`
EventType string `json:"event_type"`
OldState *TaskState `json:"old_state,omitempty"`
NewState *TaskState `json:"new_state,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
CreatedBy *string `json:"created_by,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
// Comment represents a comment on a task (user or agent)
type Comment struct {
ID string `json:"id"`
TaskID string `json:"task_id"`
AuthorType string `json:"author_type"` // "user" or "agent"
Type string `json:"type,omitempty"`
AuthorID string `json:"author_id,omitempty"`
Content string `json:"content"`
RequestsInput bool `json:"requests_input"` // True if agent is requesting user input
Metadata map[string]interface{} `json:"metadata,omitempty"`
AgentSessionID string `json:"agent_session_id,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
// CreateCommentRequest for adding a comment to a task
type CreateCommentRequest struct {
TaskID string `json:"task_id" binding:"required"`
Content string `json:"content" binding:"required"`
AuthorType string `json:"author_type,omitempty"` // Defaults to "user" if not specified
Type string `json:"type,omitempty"`
RequestsInput bool `json:"requests_input,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
// PermissionOption represents a permission choice presented to the user
type PermissionOption struct {
OptionID string `json:"option_id"`
Name string `json:"name"`
Kind string `json:"kind"` // allow_once, allow_always, reject_once, reject_always
}
// PermissionRequest represents an agent's request for user permission
type PermissionRequest struct {
RequestID string `json:"request_id"` // Unique ID for this request (JSON-RPC ID)
TaskID string `json:"task_id"` // Task the agent is working on
InstanceID string `json:"instance_id"` // Agent instance ID
SessionID string `json:"session_id"` // ACP session ID
ToolCallID string `json:"tool_call_id"` // Tool call requesting permission
Title string `json:"title"` // Human-readable title
Description string `json:"description,omitempty"` // Additional context
Options []PermissionOption `json:"options"` // Available choices
CreatedAt time.Time `json:"created_at"`
}
// PermissionResponse represents the user's response to a permission request
type PermissionResponse struct {
RequestID string `json:"request_id" binding:"required"` // The request being responded to
OptionID string `json:"option_id,omitempty"` // Selected option (if not cancelled)
Cancelled bool `json:"cancelled,omitempty"` // True if user cancelled
}