Documentation
¶
Index ¶
- Constants
- func CompletePrompt(ctx context.Context, provider LLMProvider, prompt string) (string, error)
- func GetAgentFromContext(ctx context.Context) (string, error)
- func InitializeDefaultRoles(rbac *RBACManager) error
- func WithAgent(agentID string) func(context.Context) context.Context
- type ContextKey
- type Executor
- type FunctionCall
- type FunctionDefinition
- type ImageContent
- type LLMConfig
- type LLMProvider
- type Message
- type ParameterDefinition
- type Permission
- type PermissionAction
- type RBACManager
- func (rm *RBACManager) AddRole(role *Role) error
- func (rm *RBACManager) AssignRole(agentID, roleName string) error
- func (rm *RBACManager) GetAgentRoles(agentID string) []string
- func (rm *RBACManager) GetEffectivePermissions(agentID string) []Permission
- func (rm *RBACManager) HasPermission(agentID string, resource ResourceType, action PermissionAction) bool
- type RBACMiddleware
- func (m *RBACMiddleware) AgentManagementMiddleware(action PermissionAction) func(context.Context, string) error
- func (m *RBACMiddleware) MemoryAccessMiddleware(action PermissionAction) func(context.Context, string) error
- func (m *RBACMiddleware) RequirePermission(resource ResourceType, action PermissionAction) func(http.Handler) http.Handler
- func (m *RBACMiddleware) TaskExecutionMiddleware(next func(context.Context, *tasks.Task) error) func(context.Context, *tasks.Task) error
- func (m *RBACMiddleware) TeamManagementMiddleware(action PermissionAction) func(context.Context, string) error
- func (m *RBACMiddleware) ToolExecutionMiddleware(next func(context.Context, Tool) error) func(context.Context, Tool) error
- type ResourceType
- type Role
- type Tool
Constants ¶
const ( RoleAdmin = "admin" RoleManager = "manager" RoleWorker = "worker" RoleObserver = "observer" RoleTaskCreator = "task_creator" )
Default role names
Variables ¶
This section is empty.
Functions ¶
func CompletePrompt ¶
CompletePrompt is a helper function for completing a single prompt
func GetAgentFromContext ¶
GetAgentFromContext retrieves agent ID from context
func InitializeDefaultRoles ¶
func InitializeDefaultRoles(rbac *RBACManager) error
InitializeDefaultRoles sets up the default roles in the RBAC manager
Types ¶
type ContextKey ¶
type ContextKey string
ContextKey type for context values
const ( // ContextKeyAgent is the key for agent ID in context ContextKeyAgent ContextKey = "agent_id" )
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor handles task execution for agents
func NewExecutor ¶
func NewExecutor(llm LLMProvider) *Executor
NewExecutor creates a new executor instance
type FunctionCall ¶
FunctionCall represents a function call in the conversation
type FunctionDefinition ¶
type FunctionDefinition struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters map[string]ParameterDefinition `json:"parameters"`
}
FunctionDefinition represents an OpenAI function definition
func ToFunctionDefinition ¶
func ToFunctionDefinition(tool Tool) FunctionDefinition
ToFunctionDefinition converts a tool to a function definition
type ImageContent ¶
ImageContent represents an image in the conversation
type LLMConfig ¶
type LLMConfig struct {
Model string
Temperature float64
MaxTokens int
TopP float64
FrequencyPenalty float64
PresencePenalty float64
Stop []string
APIKey string
BaseURL string
APIVersion string
Timeout float64
}
LLMConfig holds configuration for an LLM provider
func NewLLMConfig ¶
func NewLLMConfig() *LLMConfig
NewLLMConfig creates a new LLM configuration with default values
type LLMProvider ¶
type LLMProvider interface {
// Complete generates a completion for a prompt
Complete(ctx context.Context, prompt string) (string, error)
// CompleteWithFunctions generates a completion with function calling support
CompleteWithFunctions(ctx context.Context, prompt string, functions []types.Function) (string, error)
// Chat generates a response in a chat conversation
Chat(ctx context.Context, messages []types.Message) (string, error)
// GetAPIKey returns the API key for the provider
GetAPIKey() string
// GetConfig returns the current configuration
GetConfig() *LLMConfig
// SupportsFunction returns whether the provider supports function calling
SupportsFunction() bool
// GetContextWindowSize returns the context window size for the model
GetContextWindowSize() int
}
LLMProvider defines the interface for language model providers
type Message ¶
type Message struct {
Role string // system, user, or assistant
Content string
FunctionCall *FunctionCall `json:"function_call,omitempty"`
Images []ImageContent `json:"images,omitempty"`
}
Message represents a chat message in the conversation
type ParameterDefinition ¶
type ParameterDefinition struct {
Type string `json:"type"`
Description string `json:"description"`
Required bool `json:"required"`
Enum []string `json:"enum,omitempty"`
}
ParameterDefinition defines a parameter for function calling
type Permission ¶
type Permission struct {
Resource ResourceType
Action PermissionAction
Conditions map[string]interface{} // Additional constraints like time windows, resource tags
}
Permission defines a single permission on a resource
type PermissionAction ¶
type PermissionAction string
PermissionAction defines allowed actions on resources
const ( ActionRead PermissionAction = "read" ActionWrite PermissionAction = "write" ActionExecute PermissionAction = "execute" ActionDelete PermissionAction = "delete" ActionGrant PermissionAction = "grant" )
type RBACManager ¶
type RBACManager struct {
// contains filtered or unexported fields
}
RBACManager handles role-based access control
func NewRBACManager ¶
func NewRBACManager() *RBACManager
NewRBACManager creates a new RBAC manager instance
func (*RBACManager) AddRole ¶
func (rm *RBACManager) AddRole(role *Role) error
AddRole adds a new role to the system
func (*RBACManager) AssignRole ¶
func (rm *RBACManager) AssignRole(agentID, roleName string) error
AssignRole assigns a role to an agent
func (*RBACManager) GetAgentRoles ¶
func (rm *RBACManager) GetAgentRoles(agentID string) []string
GetAgentRoles returns all roles assigned to an agent
func (*RBACManager) GetEffectivePermissions ¶
func (rm *RBACManager) GetEffectivePermissions(agentID string) []Permission
GetEffectivePermissions returns all permissions an agent has (including inherited)
func (*RBACManager) HasPermission ¶
func (rm *RBACManager) HasPermission(agentID string, resource ResourceType, action PermissionAction) bool
HasPermission checks if an agent has a specific permission
type RBACMiddleware ¶
type RBACMiddleware struct {
// contains filtered or unexported fields
}
RBACMiddleware provides middleware functions for RBAC
func NewRBACMiddleware ¶
func NewRBACMiddleware(rbac *RBACManager) *RBACMiddleware
NewRBACMiddleware creates a new RBAC middleware instance
func (*RBACMiddleware) AgentManagementMiddleware ¶
func (m *RBACMiddleware) AgentManagementMiddleware(action PermissionAction) func(context.Context, string) error
AgentManagementMiddleware checks permissions for agent operations
func (*RBACMiddleware) MemoryAccessMiddleware ¶
func (m *RBACMiddleware) MemoryAccessMiddleware(action PermissionAction) func(context.Context, string) error
MemoryAccessMiddleware checks permissions for memory operations
func (*RBACMiddleware) RequirePermission ¶
func (m *RBACMiddleware) RequirePermission(resource ResourceType, action PermissionAction) func(http.Handler) http.Handler
RequirePermission creates middleware that checks for specific permission
func (*RBACMiddleware) TaskExecutionMiddleware ¶
func (m *RBACMiddleware) TaskExecutionMiddleware(next func(context.Context, *tasks.Task) error) func(context.Context, *tasks.Task) error
TaskExecutionMiddleware checks permissions before task execution
func (*RBACMiddleware) TeamManagementMiddleware ¶
func (m *RBACMiddleware) TeamManagementMiddleware(action PermissionAction) func(context.Context, string) error
TeamManagementMiddleware checks permissions for team operations
type ResourceType ¶
type ResourceType string
ResourceType defines types of resources that can be protected
const ( ResourceTask ResourceType = "task" ResourceMemory ResourceType = "memory" ResourceTool ResourceType = "tool" ResourceAgent ResourceType = "agent" ResourceTeam ResourceType = "team" )
type Role ¶
type Role struct {
Name string
Description string
Permissions []Permission
Hierarchy int // Role level in hierarchy (higher number = more privileges)
ParentRole string // Name of parent role for inheritance
}
Role represents a collection of permissions
func DefaultRoles ¶
func DefaultRoles() []*Role
DefaultRoles returns a set of predefined roles with their permissions
type Tool ¶
type Tool interface {
// Name returns the name of the tool
Name() string
// Description returns a description of what the tool does
Description() string
// Parameters returns the parameters that the tool accepts
Parameters() map[string]ParameterDefinition
// Execute executes the tool with the given input
Execute(input string) (string, error)
}
Tool represents a capability that can be used by agents