agent

package
v0.0.0-...-3024e77 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	SubagentResearch      SubagentType     = "research"
	SubagentArchitecture  SubagentType     = "architecture"
	SubagentUI            SubagentType     = "ui"
	SubagentUX            SubagentType     = "ux"
	SubagentSecurity      SubagentType     = "security"
	SubagentBackend       SubagentType     = "backend"
	SubagentDatabase      SubagentType     = "database"
	SubagentValidation    SubagentType     = "validation"
	ValidationPending     ValidationStatus = "pending"
	ValidationPassed      ValidationStatus = "passed"
	ValidationNeedsReview ValidationStatus = "needs_review"
)
View Source
const (
	WorkflowVision   = "vision"
	WorkflowResearch = "research"
	WorkflowPlanning = "planning"
	WorkflowApproval = "approval"
	WorkflowImpact   = "impact"
	WorkflowContext  = "context"
	WorkflowStatus   = "status"

	CapabilityPlanning = "planning"
	CapabilityResearch = "research"
	CapabilityVision   = "vision"
	CapabilityChange   = "change"
	CapabilityContext  = "context"

	ModelStrategyDefault = "default"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentMessage

type AgentMessage struct {
	ID        string `json:"id"`
	RunID     string `json:"run_id"`
	Role      string `json:"role"` // user, agent
	Content   string `json:"content"`
	CreatedAt string `json:"created_at"`
}

AgentMessage represents a single message in an agent conversation.

type AgentResponse

type AgentResponse struct {
	Message             string            `json:"message"`
	Status              string            `json:"status"`
	RequiresApproval    bool              `json:"requires_approval"`
	SuggestedNextAction string            `json:"suggested_next_action"`
	ContextUsed         []string          `json:"context_used"`
	WorkflowTriggered   string            `json:"workflow_triggered"`
	CreatedEntities     map[string]string `json:"created_entities"`
}

AgentResponse is the structured response from the agent.

type AgentRunRecord

type AgentRunRecord struct {
	ID        string `json:"id"`
	ProjectID string `json:"project_id"`
	Intent    string `json:"intent"`
	Status    string `json:"status"`
	Response  string `json:"response"` // JSON
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

AgentRunRecord represents a persisted agent execution.

type AgentRunRepository

type AgentRunRepository interface {
	CreateRun(run AgentRunRecord) (AgentRunRecord, error)
	GetRun(id string) (AgentRunRecord, error)
	UpdateRunStatus(id, status, response string) error
	ListRuns(projectID string, limit int) ([]AgentRunRecord, error)

	CreateMessage(msg AgentMessage) (AgentMessage, error)
	ListMessages(runID string) ([]AgentMessage, error)
}

AgentRunRepository persists agent runs and messages.

type CapabilitySelector

type CapabilitySelector interface {
	Select(intent IntentKind) string
}

CapabilitySelector picks the right capability for an intent.

type ContextLoader

type ContextLoader interface {
	Load(projectID string, keys []string) (ContextPayload, error)
}

ContextLoader loads minimal context for a given intent.

type ContextPayload

type ContextPayload struct {
	ProjectID   string
	Plans       []map[string]any
	Phases      []map[string]any
	Tasks       []map[string]any
	Decisions   []map[string]any
	Research    []map[string]any
	Knowledge   []map[string]any
	Visions     []map[string]any
	Validations []map[string]any
	Approved    struct {
		Requirements []string
		Decisions    []string
		Constraints  []string
	}
}

ContextPayload is loaded context for the response.

type DefaultCapabilitySelector

type DefaultCapabilitySelector struct{}

DefaultCapabilitySelector maps intents to capabilities.

func NewCapabilitySelector

func NewCapabilitySelector() *DefaultCapabilitySelector

NewCapabilitySelector creates a new DefaultCapabilitySelector.

func (*DefaultCapabilitySelector) Select

func (s *DefaultCapabilitySelector) Select(intent IntentKind) string

Select returns the capability for the given intent.

type DefaultIntentDetector

type DefaultIntentDetector struct{}

DefaultIntentDetector identifies user intent from input text.

func NewIntentDetector

func NewIntentDetector() *DefaultIntentDetector

NewIntentDetector creates a new DefaultIntentDetector.

func (*DefaultIntentDetector) DetectIntent

func (d *DefaultIntentDetector) DetectIntent(input string) IntentKind

DetectIntent analyzes input and returns the matched intent.

type DefaultResponseBuilder

type DefaultResponseBuilder struct{}

DefaultResponseBuilder builds AgentResponse values.

func NewResponseBuilder

func NewResponseBuilder() *DefaultResponseBuilder

NewResponseBuilder creates a DefaultResponseBuilder.

func (*DefaultResponseBuilder) BuildApprovalRequired

func (b *DefaultResponseBuilder) BuildApprovalRequired(message string, decision RouterDecision) AgentResponse

BuildApprovalRequired creates a response that requires user approval.

func (*DefaultResponseBuilder) BuildError

func (b *DefaultResponseBuilder) BuildError(err string) AgentResponse

BuildError creates an error response.

func (*DefaultResponseBuilder) BuildSuccess

func (b *DefaultResponseBuilder) BuildSuccess(message string, decision RouterDecision) AgentResponse

BuildSuccess creates a success response.

type DefaultRouter

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

DefaultRouter routes intents to workflows, capabilities, and strategies.

func NewRouter

NewRouter creates a new DefaultRouter.

func (*DefaultRouter) Route

func (r *DefaultRouter) Route(intent IntentKind, ctx ContextPayload) RouterDecision

Route produces a RouterDecision for the given intent and context.

type DefaultWorkflowSelector

type DefaultWorkflowSelector struct{}

DefaultWorkflowSelector maps intents to workflow types.

func NewWorkflowSelector

func NewWorkflowSelector() *DefaultWorkflowSelector

NewWorkflowSelector creates a new DefaultWorkflowSelector.

func (*DefaultWorkflowSelector) Select

func (s *DefaultWorkflowSelector) Select(intent IntentKind) string

Select returns the workflow type for the given intent.

type DelegatedJob

type DelegatedJob struct {
	ID            string           `json:"id"`
	ProjectID     string           `json:"project_id"`
	Intent        IntentKind       `json:"intent"`
	Capability    string           `json:"capability"`
	WorkflowType  string           `json:"workflow_type"`
	JobType       DelegatedJobType `json:"job_type"`
	Status        JobStatus        `json:"status"`
	ResultSummary string           `json:"result_summary"`
	CreatedAt     string           `json:"created_at"`
	CompletedAt   string           `json:"completed_at"`
}

DelegatedJob represents a temporary delegated job created by the agent.

func JobForIntent

func JobForIntent(projectID string, intent IntentKind, workflowType string) DelegatedJob

JobForIntent creates a DelegatedJob for the given intent.

type DelegatedJobRepository

type DelegatedJobRepository interface {
	CreateJob(job DelegatedJob) (DelegatedJob, error)
	GetJob(id string) (DelegatedJob, error)
	ListJobs(projectID string) ([]DelegatedJob, error)
	UpdateJob(id, status, summary string) error
}

DelegatedJobRepository persists delegated jobs.

type DelegatedJobType

type DelegatedJobType string

DelegatedJobType represents the type of a delegated job.

const (
	JobTypeVision     DelegatedJobType = "vision_job"
	JobTypeResearch   DelegatedJobType = "research_job"
	JobTypePlanning   DelegatedJobType = "planning_job"
	JobTypeValidation DelegatedJobType = "validation_job"
	JobTypeImpact     DelegatedJobType = "impact_job"
	JobTypeContext    DelegatedJobType = "context_job"
)

type Delegator

type Delegator interface {
	CreateJob(job DelegatedJob) (DelegatedJob, error)
	GetJob(id string) (DelegatedJob, error)
	ListJobs(projectID string) ([]DelegatedJob, error)
	UpdateJobStatus(id string, status JobStatus, summary string) error
}

Delegator creates delegated jobs.

type IntentDetector

type IntentDetector interface {
	DetectIntent(input string) IntentKind
}

IntentDetector detects user intent from input.

type IntentKind

type IntentKind string

IntentKind represents the detected user intent.

const (
	IntentCreateMasterPlan   IntentKind = "create_master_plan"
	IntentCreateSpecificPlan IntentKind = "create_specific_plan"
	IntentResearchTopic      IntentKind = "research_topic"
	IntentUpdatePlan         IntentKind = "update_plan"
	IntentChangeRequest      IntentKind = "change_request"
	IntentImplementationHelp IntentKind = "implementation_help"
	IntentProjectStatus      IntentKind = "project_status"
	IntentApprove            IntentKind = "approve"
	IntentReject             IntentKind = "reject"
	IntentValidate           IntentKind = "validate"
	IntentNextTask           IntentKind = "next_task"
	IntentAnalyzeProject     IntentKind = "analyze_project"
	IntentCreateProduct      IntentKind = "create_product"
	IntentDatabasePlan       IntentKind = "database_plan"
	IntentImpactAnalysis     IntentKind = "impact_analysis"
	IntentUnknown            IntentKind = "unknown"
)

type JobStatus

type JobStatus string

JobStatus represents the lifecycle status of a delegated job.

const (
	JobStatusPending   JobStatus = "pending"
	JobStatusRunning   JobStatus = "running"
	JobStatusCompleted JobStatus = "completed"
	JobStatusFailed    JobStatus = "failed"
	JobStatusCancelled JobStatus = "cancelled"
)

type PlanningGuard

type PlanningGuard interface {
	IsPlanningAllowed(projectID string) (ok bool, reason string)
}

PlanningGuard checks whether planning can proceed for a project. A nil guard allows planning without checks (for backward compat).

type ResponseBuilder

type ResponseBuilder interface {
	BuildSuccess(message string, decision RouterDecision) AgentResponse
	BuildApprovalRequired(message string, decision RouterDecision) AgentResponse
	BuildError(err string) AgentResponse
}

ResponseBuilder builds agent responses.

type Router

type Router interface {
	Route(intent IntentKind, context ContextPayload) RouterDecision
}

Router routes intents to workflows and capabilities.

type RouterDecision

type RouterDecision struct {
	Workflow         string   `json:"workflow"`
	Capability       string   `json:"capability"`
	ModelStrategy    string   `json:"model_strategy"`
	ContextKeys      []string `json:"context_keys"`
	RequiresApproval bool     `json:"requires_approval"`
}

RouterDecision is the output of the agent router.

type Service

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

Service is the main agent orchestrator.

func NewService

func NewService(
	detector IntentDetector,
	router Router,
	contextLoader ContextLoader,
	delegator Delegator,
	responseBuilder ResponseBuilder,
	runRepo AgentRunRepository,
) *Service

NewService creates a new agent service.

func (*Service) ProcessMessage

func (s *Service) ProcessMessage(projectID, userInput string) (AgentResponse, error)

ProcessMessage handles a user message and returns an agent response.

func (*Service) SetPlanningGuard

func (s *Service) SetPlanningGuard(g PlanningGuard)

SetPlanningGuard attaches an optional planning guard. When set, the service blocks planning intents (create_master_plan, create_specific_plan) until the guard is satisfied.

type StoreContextLoader

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

StoreContextLoader loads context from the store using repositories.

func NewContextLoader

func NewContextLoader(db *sql.DB) *StoreContextLoader

NewContextLoader creates a StoreContextLoader.

func (*StoreContextLoader) Load

func (l *StoreContextLoader) Load(projectID string, keys []string) (ContextPayload, error)

Load loads context data for the requested keys.

type StoreDelegator

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

StoreDelegator creates and manages delegated jobs via the store.

func NewDelegator

func NewDelegator(db *sql.DB, repo DelegatedJobRepository) *StoreDelegator

NewDelegator creates a new StoreDelegator.

func (*StoreDelegator) CreateJob

func (d *StoreDelegator) CreateJob(job DelegatedJob) (DelegatedJob, error)

CreateJob creates a new delegated job.

func (*StoreDelegator) GetJob

func (d *StoreDelegator) GetJob(id string) (DelegatedJob, error)

GetJob retrieves a delegated job by ID.

func (*StoreDelegator) ListJobs

func (d *StoreDelegator) ListJobs(projectID string) ([]DelegatedJob, error)

ListJobs lists delegated jobs for a project.

func (*StoreDelegator) UpdateJobStatus

func (d *StoreDelegator) UpdateJobStatus(id string, status JobStatus, summary string) error

UpdateJobStatus updates a job's status and optional summary.

type SubagentOrchestrator

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

func NewSubagentOrchestrator

func NewSubagentOrchestrator(repo SubagentTaskRepository) SubagentOrchestrator

func (SubagentOrchestrator) Create

func (o SubagentOrchestrator) Create(projectID string, agentType SubagentType, objective string) (SubagentTask, error)

func (SubagentOrchestrator) List

func (o SubagentOrchestrator) List(projectID string) ([]SubagentTask, error)

type SubagentTask

type SubagentTask struct {
	ID               string
	ProjectID        string
	AgentType        SubagentType
	Objective        string
	Capability       string
	Status           JobStatus
	Provenance       string
	ValidationStatus ValidationStatus
	Isolated         bool
	Temporary        bool
	MemoryPolicy     string
	ResultSummary    string
	CreatedAt        time.Time
	UpdatedAt        time.Time
}

func BuildSubagentTask

func BuildSubagentTask(projectID string, agentType SubagentType, objective string) SubagentTask

type SubagentTaskRepository

type SubagentTaskRepository interface {
	SaveSubagentTask(SubagentTask) (SubagentTask, error)
	ListSubagentTasks(projectID string) ([]SubagentTask, error)
}

type SubagentType

type SubagentType string

type ValidationStatus

type ValidationStatus string

type WorkflowSelector

type WorkflowSelector interface {
	Select(intent IntentKind) string
}

WorkflowSelector picks the right workflow for an intent.

Jump to

Keyboard shortcuts

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