Documentation
¶
Overview ¶
Package tools defines the Tool interface and Registry for agent tool execution.
Index ¶
- func AgentIDFromContext(ctx context.Context) string
- func ProjectIDFromContext(ctx context.Context) string
- func TaskIDFromContext(ctx context.Context) string
- func TeamIDFromContext(ctx context.Context) string
- func WithAgentID(ctx context.Context, agentID string) context.Context
- func WithProjectID(ctx context.Context, projectID string) context.Context
- func WithTaskID(ctx context.Context, taskID string) context.Context
- func WithTeamID(ctx context.Context, teamID string) context.Context
- type PolicyEngine
- type Registry
- func (r *Registry) AllDefs() []provider.ToolDef
- func (r *Registry) Execute(ctx context.Context, name string, args map[string]any) (any, error)
- func (r *Registry) Get(name string) (Tool, bool)
- func (r *Registry) Names() []string
- func (r *Registry) Register(tool Tool)
- func (r *Registry) RegisterMCP(serverName string, tools []Tool)
- func (r *Registry) SetPolicyEngine(pe PolicyEngine)
- func (r *Registry) UnregisterMCP(serverName string)
- type Tool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AgentIDFromContext ¶
AgentIDFromContext returns the agent ID from context, if set.
func ProjectIDFromContext ¶
ProjectIDFromContext returns the project ID from context, if set.
func TaskIDFromContext ¶
TaskIDFromContext returns the task ID from context, if set.
func TeamIDFromContext ¶
TeamIDFromContext returns the team ID from context, if set.
func WithAgentID ¶
WithAgentID returns a context with the agent ID set.
func WithProjectID ¶
WithProjectID returns a context with the project ID set.
func WithTaskID ¶
WithTaskID returns a context with the task ID set.
Types ¶
type PolicyEngine ¶
type PolicyEngine interface {
// IsAllowed checks whether agentID (in teamID) may call toolName.
// Returns (allowed, reason).
IsAllowed(ctx context.Context, toolName, agentID, teamID string) (bool, string)
}
PolicyEngine enforces access control on tool execution.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry merges built-in tools into a unified, policy-enforced registry.
func (*Registry) Execute ¶
Execute runs a tool by name with the given arguments. If a policy engine is set, access control is checked before execution.
func (*Registry) RegisterMCP ¶
RegisterMCP registers MCP tools with a server-prefixed name.
func (*Registry) SetPolicyEngine ¶
func (r *Registry) SetPolicyEngine(pe PolicyEngine)
SetPolicyEngine attaches a PolicyEngine for access control enforcement.
func (*Registry) UnregisterMCP ¶
UnregisterMCP removes all tools registered under the given MCP server name.
type Tool ¶
type Tool interface {
// Name returns the unique identifier for this tool.
Name() string
// Definition returns the tool schema exposed to the LLM.
Definition() provider.ToolDef
// Execute runs the tool with the given arguments and returns the result.
Execute(ctx context.Context, args map[string]any) (any, error)
}
Tool is an agent-callable function with a well-defined schema.