multiagent

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	ID           string
	Role         AgentRole
	Capabilities []string
	Config       map[string]string
	Status       AgentStatus
}

Agent represents an agent in the system

type AgentFinderAdapter

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

func NewAgentFinderAdapter

func NewAgentFinderAdapter(agentSystem *AgentSystem) *AgentFinderAdapter

func (*AgentFinderAdapter) FindAgentsByRole

func (f *AgentFinderAdapter) FindAgentsByRole(ctx context.Context, role string) ([]string, error)

type AgentRole

type AgentRole string

AgentRole represents the role of an agent

type AgentStatus

type AgentStatus string

AgentStatus represents the current status of an agent

const (
	StatusAvailable AgentStatus = "available"
	StatusBusy      AgentStatus = "busy"
	StatusOffline   AgentStatus = "offline"
)

type AgentSystem

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

AgentSystem manages agents and workflows using Datalog

Example
ctx := context.Background()

system, _ := NewAgentSystem(ctx)
system.LoadAgentDefinitions(ctx)

// Query: Which agents can generate a document?
agents, _ := system.FindAgentsForTask(ctx, "generate_document")
fmt.Println("=== Agents for generate_document ===")
for _, a := range agents {
	fmt.Printf("- %s (%s): %v\n", a.ID, a.Role, a.Capabilities)
}

// Query: What can a supervisor do?
caps, _ := system.GetRoleCapabilities(ctx, "supervisor")
fmt.Println("\n=== Supervisor capabilities ===")
for _, c := range caps {
	fmt.Printf("- %s\n", c)
}

// Query: Get workflow structure
wf, _ := system.GetWorkflow(ctx, "content-pipeline")
fmt.Printf("\n=== Workflow: %s ===\n", wf.Name)
for _, n := range wf.Nodes {
	fmt.Printf("Node: %s (type: %s, agent: %s)\n", n.ID, n.Type, n.Agent)
}

func NewAgentSystem

func NewAgentSystem(ctx context.Context) (*AgentSystem, error)

NewAgentSystem creates a new agent system

func (*AgentSystem) Engine

func (s *AgentSystem) Engine() *engine.PolicyEngine

Engine returns the underlying policy engine for external access

func (*AgentSystem) EvaluateCondition

func (s *AgentSystem) EvaluateCondition(ctx context.Context, condition string, contextData map[string]string) (bool, error)

EvaluateCondition evaluates a conditional edge

func (*AgentSystem) FindAgentsForTask

func (s *AgentSystem) FindAgentsForTask(ctx context.Context, task string) ([]*Agent, error)

FindAgentsForTask finds agents capable of performing a task

func (*AgentSystem) GetAgent

func (s *AgentSystem) GetAgent(ctx context.Context, agentID string) (*Agent, error)

GetAgent retrieves an agent by ID

func (*AgentSystem) GetAgentRoles

func (s *AgentSystem) GetAgentRoles(ctx context.Context) ([]string, error)

GetAgentRoles retrieves all defined agent roles

func (*AgentSystem) GetAgentsByRole

func (s *AgentSystem) GetAgentsByRole(ctx context.Context, role string) ([]*Agent, error)

GetAgentsByRole retrieves all agents with the specified role

func (*AgentSystem) GetRoleCapabilities

func (s *AgentSystem) GetRoleCapabilities(ctx context.Context, role string) ([]string, error)

GetRoleCapabilities returns capabilities for a given role

func (*AgentSystem) GetWorkflow

func (s *AgentSystem) GetWorkflow(ctx context.Context, workflowName string) (*Workflow, error)

GetWorkflow retrieves a workflow by name

func (*AgentSystem) GetWorkflowEdges

func (s *AgentSystem) GetWorkflowEdges(ctx context.Context, workflowName, nodeID string) ([]WorkflowEdge, error)

GetWorkflowEdges returns edges for a specific node

func (*AgentSystem) GetWorkflows

func (s *AgentSystem) GetWorkflows(ctx context.Context) ([]*Workflow, error)

GetWorkflows retrieves all available workflows

func (*AgentSystem) LoadAgentDefinitions

func (s *AgentSystem) LoadAgentDefinitions(ctx context.Context) error

LoadAgentDefinitions loads agent definitions from Datalog. The default registry is embedded in the binary from assets/agent_registry.dlog. Callers may also load custom rules by calling Engine().Runtime().AddPolicy() directly after this call.

func (*AgentSystem) Query

func (s *AgentSystem) Query(ctx context.Context, facts []string, query string) ([]map[string]string, error)

Query executes a Datalog query against the agent system

func (*AgentSystem) QueryWithAudit

func (s *AgentSystem) QueryWithAudit(ctx context.Context, facts []string, query string) ([]map[string]string, *core.AuditTrail, error)

QueryWithAudit executes a Datalog query and returns results with an audit trail. This provides transparency into which rules were matched and from which tier.

func (*AgentSystem) SetAgentStatus

func (s *AgentSystem) SetAgentStatus(ctx context.Context, agentID string, status AgentStatus) error

SetAgentStatus updates the status of an agent

type ConditionEvaluatorAdapter

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

func NewConditionEvaluatorAdapter

func NewConditionEvaluatorAdapter(agentSystem *AgentSystem) *ConditionEvaluatorAdapter

func (*ConditionEvaluatorAdapter) EvaluateCondition

func (e *ConditionEvaluatorAdapter) EvaluateCondition(ctx context.Context, condition string, facts map[string]interface{}) (bool, error)

type DatalogWorkflowLoader

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

func NewDatalogWorkflowLoader

func NewDatalogWorkflowLoader(agentSystem *AgentSystem) *DatalogWorkflowLoader

func (*DatalogWorkflowLoader) LoadWorkflow

func (l *DatalogWorkflowLoader) LoadWorkflow(ctx context.Context, workflowID string) (*core.WorkflowDef, error)

type DefaultNodeExecutor

type DefaultNodeExecutor struct{}

func (*DefaultNodeExecutor) Execute

func (e *DefaultNodeExecutor) Execute(ctx context.Context, node *WorkflowNode, input interface{}, agent *Agent) (interface{}, error)

type Envelope

type Envelope = core.Envelope

Envelope wraps the input/output for agent execution

type HydratedWorkflowExecutor

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

func NewHydratedWorkflowExecutor

func NewHydratedWorkflowExecutor(workflowDef *core.WorkflowDef) *HydratedWorkflowExecutor

func (*HydratedWorkflowExecutor) Execute

func (e *HydratedWorkflowExecutor) Execute(ctx context.Context, initialInput interface{}) (*core.WorkflowResult, error)

func (*HydratedWorkflowExecutor) ExecuteWithSession

func (e *HydratedWorkflowExecutor) ExecuteWithSession(ctx context.Context, initialInput interface{}) (*core.WorkflowResult, *core.WorkflowInstance, error)

func (*HydratedWorkflowExecutor) WithAgentFinder

func (*HydratedWorkflowExecutor) WithConditionEvaluator

func (*HydratedWorkflowExecutor) WithMaxRetries

func (e *HydratedWorkflowExecutor) WithMaxRetries(retries int) *HydratedWorkflowExecutor

func (*HydratedWorkflowExecutor) WithNodeExecutor

func (*HydratedWorkflowExecutor) WithSessionStore

func (e *HydratedWorkflowExecutor) WithSessionStore(store ports.SessionStateStore, sessionID string) *HydratedWorkflowExecutor

func (*HydratedWorkflowExecutor) WithTimeout

type NodeExecutor

type NodeExecutor interface {
	Execute(ctx context.Context, node *WorkflowNode, input interface{}, agent *Agent) (interface{}, error)
}

type NodeResult

type NodeResult struct {
	NodeID     string
	AgentID    string
	Input      interface{}
	Output     interface{}
	Error      error
	StartTime  time.Time
	EndTime    time.Duration
	RetryCount int
}

type ParallelWorkflowExecutor

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

func NewParallelWorkflowExecutor

func NewParallelWorkflowExecutor(agentSystem *AgentSystem) *ParallelWorkflowExecutor

func (*ParallelWorkflowExecutor) ExecuteParallel

func (e *ParallelWorkflowExecutor) ExecuteParallel(ctx context.Context, workflow *Workflow, initialInput interface{}) (*WorkflowResult, error)

func (*ParallelWorkflowExecutor) WithBarrierSync

func (e *ParallelWorkflowExecutor) WithBarrierSync(barrier bool) *ParallelWorkflowExecutor

func (*ParallelWorkflowExecutor) WithMaxParallel

func (e *ParallelWorkflowExecutor) WithMaxParallel(max int) *ParallelWorkflowExecutor

type Workflow

type Workflow struct {
	ID      string
	Name    string
	Version string
	Nodes   []WorkflowNode
	Edges   []WorkflowEdge
}

Workflow represents a workflow defined in Datalog

type WorkflowContext

type WorkflowContext map[string]interface{}

type WorkflowEdge

type WorkflowEdge struct {
	From      string
	To        string
	Condition string // Datalog query for conditional edges
}

WorkflowEdge represents an edge between workflow nodes

type WorkflowExecutor

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

func NewWorkflowExecutor

func NewWorkflowExecutor(agentSystem *AgentSystem) *WorkflowExecutor

func (*WorkflowExecutor) Execute

func (e *WorkflowExecutor) Execute(ctx context.Context, workflowName string, initialInput interface{}) (*WorkflowResult, error)

func (*WorkflowExecutor) ExecuteWorkflow

func (e *WorkflowExecutor) ExecuteWorkflow(ctx context.Context, workflow *Workflow, initialInput interface{}) (*WorkflowResult, error)

func (*WorkflowExecutor) WithLogger

func (e *WorkflowExecutor) WithLogger(logger core.Logger) *WorkflowExecutor

func (*WorkflowExecutor) WithMaxRetries

func (e *WorkflowExecutor) WithMaxRetries(retries int) *WorkflowExecutor

func (*WorkflowExecutor) WithNodeExecutor

func (e *WorkflowExecutor) WithNodeExecutor(exec NodeExecutor) *WorkflowExecutor

func (*WorkflowExecutor) WithTimeout

func (e *WorkflowExecutor) WithTimeout(timeout time.Duration) *WorkflowExecutor

type WorkflowNode

type WorkflowNode struct {
	ID     string
	Type   string // "agent", "action", "condition", "parallel", "merge"
	Agent  string // agent role or action name
	Config map[string]string
}

WorkflowNode represents a node in a workflow

type WorkflowResult

type WorkflowResult struct {
	WorkflowID  string
	Status      WorkflowStatus
	Output      interface{}
	NodeResults map[string]*NodeResult
	Error       error
	StartTime   time.Time
	EndTime     time.Time
}

type WorkflowStatus

type WorkflowStatus string
const (
	WorkflowStatusPending   WorkflowStatus = "pending"
	WorkflowStatusRunning   WorkflowStatus = "running"
	WorkflowStatusCompleted WorkflowStatus = "completed"
	WorkflowStatusFailed    WorkflowStatus = "failed"
	WorkflowStatusCancelled WorkflowStatus = "cancelled"
)

Jump to

Keyboard shortcuts

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