Documentation
¶
Overview ¶
Package store defines the persistence interface and shared models for teams, tasks, workflows, and messages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureSchema ¶
EnsureSchema creates the store at home, runs migrations, and closes it; used to bootstrap the DB.
Types ¶
type Message ¶
type Message struct {
MessageID int64
TeamID string
Sender string
Recipient string
Content string
CreatedAt time.Time
ProcessedAt *time.Time
}
Message is used for agent↔agent or human↔manager communication (mailbox).
type OpenOptions ¶
type OpenOptions struct {
Driver string // "sqlite" (default) or "postgres"
Home string // for sqlite: directory containing protected/db.sqlite
DSN string // for postgres: connection string; or env DATABASE_URL
}
OpenOptions configures how to open the store (driver and location).
type Repo ¶
Repo is a git repository linked to a team (source path, approval mode, optional test command).
type Store ¶
type Store interface {
// Teams
ListTeams(ctx context.Context) ([]Team, error)
GetTeamByName(ctx context.Context, name string) (Team, error)
CreateTeam(ctx context.Context, name string) (Team, error)
DeleteTeam(ctx context.Context, name string) error
// Agents
ListAgents(ctx context.Context, teamName string) ([]Agent, error)
CreateAgent(ctx context.Context, teamName, name, role string) error
// Tasks
ListTasks(ctx context.Context, teamName string, limit int) ([]Task, error)
ListTasksInStage(ctx context.Context, teamName, stage string, limit int) ([]Task, error)
CreateTask(ctx context.Context, teamName, title, status string, workflowID *string) (int64, error)
UpdateTask(ctx context.Context, taskID int64, status string, assignee *string) error
ClaimTask(ctx context.Context, teamName string, taskID int64, assignee string) (bool, error)
SetTaskFailed(ctx context.Context, taskID int64) error
RequeueTask(ctx context.Context, teamName string, taskID int64) error
SetTaskCancelled(ctx context.Context, teamName string, taskID int64) error
ClearTaskGitFields(ctx context.Context, taskID int64) error
UpdateTaskGitFields(ctx context.Context, taskID int64, worktreePath, branchName, baseSHA, repoName *string) error
RewindTask(ctx context.Context, teamName string, taskID int64) error
CreateTaskComment(ctx context.Context, teamName string, taskID int64, author, body string) (int64, error)
ListTaskComments(ctx context.Context, teamName string, taskID int64) ([]TaskComment, error)
AddTaskAttachment(ctx context.Context, teamName string, taskID int64, filePath string) error
RemoveTaskAttachment(ctx context.Context, teamName string, taskID int64, filePath string) error
ListTaskAttachments(ctx context.Context, teamName string, taskID int64) ([]TaskAttachment, error)
AddTaskDependency(ctx context.Context, teamName string, taskID, dependsOnTaskID int64) error
ListTaskDependencies(ctx context.Context, teamName string, taskID int64) ([]int64, error)
NextRunnableTaskForTeam(ctx context.Context, teamName string) (*Task, error)
GetTaskByIDAndTeam(ctx context.Context, teamName string, taskID int64) (*Task, error)
UpdateTaskStage(ctx context.Context, taskID int64, stage string) error
SetTaskWorkflowAndStage(ctx context.Context, taskID int64, workflowID, stage string) error
// Task reviews (agent-to-agent or human)
CreateTaskReview(ctx context.Context, teamName string, taskID int64, reviewerAgent, outcome, comments string) (int64, error)
ListTaskReviews(ctx context.Context, teamName string, taskID int64) ([]TaskReview, error)
// Repos
ListRepos(ctx context.Context, teamName string) ([]Repo, error)
CreateRepo(ctx context.Context, teamName, name, source, approval string, testCmd *string) error
SetRepoApproval(ctx context.Context, teamName, repoName, approval string) error
// Workflows
ListWorkflows(ctx context.Context, teamName string) ([]Workflow, error)
CreateWorkflow(ctx context.Context, teamName, name string, version int, sourcePath string) (string, error)
CreateWorkflowWithStages(ctx context.Context, teamName, name string, version int, sourcePath string, stages []WorkflowStage, transitions []WorkflowTransition) (string, error)
GetWorkflowStages(ctx context.Context, workflowID string) ([]WorkflowStage, error)
GetWorkflowTransitions(ctx context.Context, workflowID string) ([]WorkflowTransition, error)
GetWorkflowIDByTeamAndName(ctx context.Context, teamName, name string, version int) (string, error)
GetWorkflowInitialStage(ctx context.Context, workflowID string) (string, error)
// Network allowlist
ListAllowedDomains(ctx context.Context) ([]string, error)
ResetAllowlist(ctx context.Context) error
AllowDomain(ctx context.Context, domain string) error
DisallowDomain(ctx context.Context, domain string) error
// Messages
CreateMessage(ctx context.Context, teamName, sender, recipient, content string) (int64, error)
ListMessages(ctx context.Context, teamName string, recipient string, limit int) ([]Message, error)
ListUnprocessedMessages(ctx context.Context, teamName string, recipient string, limit int) ([]Message, error)
MarkMessageProcessed(ctx context.Context, messageID int64) error
// Lifecycle
SeedDemo(ctx context.Context) error
Close() error
}
Store is the persistence interface for teams, tasks, workflows, messages, and network allowlist. Implementations: *sqlite.Store (SQLite) and *postgres.Store (PostgreSQL).
func OpenWithOptions ¶
func OpenWithOptions(opts OpenOptions) (Store, error)
OpenWithOptions opens a store based on driver and options. Driver "" or "sqlite" uses Home or DSN. For driver "postgres", the caller must use postgres.Open(dsn) from internal/store/postgres to avoid import cycles.
type Task ¶
type Task struct {
TaskID int64
Title string
Status string
Assignee *string
DRI *string // Directly Responsible Individual (set on first assignment, never changes)
AttemptCount int
WorkflowID *string
CurrentStage *string
WorktreePath *string // Git worktree path (e.g. ~/.agentary/teams/<team>/worktrees/<repo>-T<id>)
BranchName *string // agentary/<team_id>/<team>/T<NNNN>
BaseSHA *string // Base commit when branch was created
RepoName *string // Optional repo name for this task
CreatedAt time.Time
UpdatedAt time.Time
}
Task is a work item with status, assignee, workflow stage, and optional git worktree info.
type TaskAttachment ¶
TaskAttachment is a file attachment on a task.
type TaskComment ¶
type TaskComment struct {
CommentID int64
TaskID int64
TeamID string
Author string
Body string
CreatedAt time.Time
}
TaskComment is a comment on a task (author and body).
type TaskReview ¶
type TaskReview struct {
ReviewID int64
TaskID int64
TeamID string
ReviewerAgent string
Outcome string // "approved" or "changes_requested"
Comments string
CreatedAt time.Time
}
TaskReview is an agent-to-agent or human review submission for a task.
type WorkflowStage ¶
type WorkflowStage struct {
WorkflowID string
StageName string
StageType string // agent, human, auto, terminal
Outcomes string // comma-separated outcomes, empty for terminal
CandidateAgents string // comma-separated agent names; if set, scheduler picks assignee from this pool
}
WorkflowStage is a stage in a workflow (agent, human, auto, terminal).