Documentation
¶
Index ¶
- type Agent
- type AgentFinderAdapter
- type AgentRole
- type AgentStatus
- type AgentSystem
- func (s *AgentSystem) Engine() *engine.PolicyEngine
- func (s *AgentSystem) EvaluateCondition(ctx context.Context, condition string, contextData map[string]string) (bool, error)
- func (s *AgentSystem) FindAgentsForTask(ctx context.Context, task string) ([]*Agent, error)
- func (s *AgentSystem) GetAgent(ctx context.Context, agentID string) (*Agent, error)
- func (s *AgentSystem) GetAgentRoles(ctx context.Context) ([]string, error)
- func (s *AgentSystem) GetAgentsByRole(ctx context.Context, role string) ([]*Agent, error)
- func (s *AgentSystem) GetRoleCapabilities(ctx context.Context, role string) ([]string, error)
- func (s *AgentSystem) GetWorkflow(ctx context.Context, workflowName string) (*Workflow, error)
- func (s *AgentSystem) GetWorkflowEdges(ctx context.Context, workflowName, nodeID string) ([]WorkflowEdge, error)
- func (s *AgentSystem) GetWorkflows(ctx context.Context) ([]*Workflow, error)
- func (s *AgentSystem) LoadAgentDefinitions(ctx context.Context) error
- func (s *AgentSystem) Query(ctx context.Context, facts []string, query string) ([]map[string]string, error)
- func (s *AgentSystem) QueryWithAudit(ctx context.Context, facts []string, query string) ([]map[string]string, *core.AuditTrail, error)
- func (s *AgentSystem) SetAgentStatus(ctx context.Context, agentID string, status AgentStatus) error
- type ConditionEvaluatorAdapter
- type DatalogWorkflowLoader
- type DefaultNodeExecutor
- type Envelope
- type HydratedWorkflowExecutor
- func (e *HydratedWorkflowExecutor) Execute(ctx context.Context, initialInput interface{}) (*core.WorkflowResult, error)
- func (e *HydratedWorkflowExecutor) ExecuteWithSession(ctx context.Context, initialInput interface{}) (*core.WorkflowResult, *core.WorkflowInstance, error)
- func (e *HydratedWorkflowExecutor) WithAgentFinder(finder ports.AgentFinder) *HydratedWorkflowExecutor
- func (e *HydratedWorkflowExecutor) WithConditionEvaluator(eval ports.ConditionEvaluator) *HydratedWorkflowExecutor
- func (e *HydratedWorkflowExecutor) WithMaxRetries(retries int) *HydratedWorkflowExecutor
- func (e *HydratedWorkflowExecutor) WithNodeExecutor(exec NodeExecutor) *HydratedWorkflowExecutor
- func (e *HydratedWorkflowExecutor) WithSessionStore(store ports.SessionStateStore, sessionID string) *HydratedWorkflowExecutor
- func (e *HydratedWorkflowExecutor) WithTimeout(timeout time.Duration) *HydratedWorkflowExecutor
- type NodeExecutor
- type NodeResult
- type ParallelWorkflowExecutor
- func (e *ParallelWorkflowExecutor) ExecuteParallel(ctx context.Context, workflow *Workflow, initialInput interface{}) (*WorkflowResult, error)
- func (e *ParallelWorkflowExecutor) WithBarrierSync(barrier bool) *ParallelWorkflowExecutor
- func (e *ParallelWorkflowExecutor) WithMaxParallel(max int) *ParallelWorkflowExecutor
- type Workflow
- type WorkflowContext
- type WorkflowEdge
- type WorkflowExecutor
- func (e *WorkflowExecutor) Execute(ctx context.Context, workflowName string, initialInput interface{}) (*WorkflowResult, error)
- func (e *WorkflowExecutor) ExecuteWorkflow(ctx context.Context, workflow *Workflow, initialInput interface{}) (*WorkflowResult, error)
- func (e *WorkflowExecutor) WithLogger(logger core.Logger) *WorkflowExecutor
- func (e *WorkflowExecutor) WithMaxRetries(retries int) *WorkflowExecutor
- func (e *WorkflowExecutor) WithNodeExecutor(exec NodeExecutor) *WorkflowExecutor
- func (e *WorkflowExecutor) WithTimeout(timeout time.Duration) *WorkflowExecutor
- type WorkflowNode
- type WorkflowResult
- type WorkflowStatus
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 ¶
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 ¶
FindAgentsForTask finds agents capable of performing a task
func (*AgentSystem) GetAgentRoles ¶
func (s *AgentSystem) GetAgentRoles(ctx context.Context) ([]string, error)
GetAgentRoles retrieves all defined agent roles
func (*AgentSystem) GetAgentsByRole ¶
GetAgentsByRole retrieves all agents with the specified role
func (*AgentSystem) GetRoleCapabilities ¶
GetRoleCapabilities returns capabilities for a given role
func (*AgentSystem) GetWorkflow ¶
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 and is loaded as a PERSISTENT unit, so a policy reload does not silently strip the agent registry. Callers may also load custom rules by calling Engine().Runtime().AddPolicy() directly after this call (those belong to the user program and are replaced by a reload).
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 ¶
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 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 (e *HydratedWorkflowExecutor) WithAgentFinder(finder ports.AgentFinder) *HydratedWorkflowExecutor
func (*HydratedWorkflowExecutor) WithConditionEvaluator ¶
func (e *HydratedWorkflowExecutor) WithConditionEvaluator(eval ports.ConditionEvaluator) *HydratedWorkflowExecutor
func (*HydratedWorkflowExecutor) WithMaxRetries ¶
func (e *HydratedWorkflowExecutor) WithMaxRetries(retries int) *HydratedWorkflowExecutor
func (*HydratedWorkflowExecutor) WithNodeExecutor ¶
func (e *HydratedWorkflowExecutor) WithNodeExecutor(exec NodeExecutor) *HydratedWorkflowExecutor
func (*HydratedWorkflowExecutor) WithSessionStore ¶
func (e *HydratedWorkflowExecutor) WithSessionStore(store ports.SessionStateStore, sessionID string) *HydratedWorkflowExecutor
func (*HydratedWorkflowExecutor) WithTimeout ¶
func (e *HydratedWorkflowExecutor) WithTimeout(timeout time.Duration) *HydratedWorkflowExecutor
type NodeExecutor ¶
type NodeExecutor interface {
Execute(ctx context.Context, node *WorkflowNode, input interface{}, agent *Agent) (interface{}, error)
}
type NodeResult ¶
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" )