tools

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecutionContext

type ExecutionContext struct {
	WorkflowID string
	StepID     string
	AgentID    string
	RunID      string
	Context    context.Context
	Timeout    time.Duration
}

ExecutionContext provides context for tool execution

type Provider

type Provider interface {
	// GetType returns the tool type this provider handles
	GetType() ast.ToolType

	// AddToolDefinition adds a tool definition to the provider
	// and returns the tools available from the definition.
	// This could return multiple tools if the definition is a MCP server.
	AddToolDefinition(tool *ast.Tool) ([]Tool, error)

	// ExecuteTool executes a tool with the given parameters
	ExecuteTool(execCtx *execcontext.ExecutionContext, toolName string, parameters json.RawMessage) (*Result, error)

	// Close cleans up resources
	Close() error
}

ToolProvider defines the interface for tool providers

type Registry

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

ToolRegistry manages tool providers and available tools

func NewRegistry

func NewRegistry() *Registry

NewToolRegistry creates a new tool registry

func (*Registry) ExecuteTool

func (tr *Registry) ExecuteTool(execCtx *execcontext.ExecutionContext, toolName string, parameters json.RawMessage) (*Result, error)

GetProvider returns a provider by name

func (*Registry) GetToolsForAgent

func (tr *Registry) GetToolsForAgent(agentName string) []Tool

func (*Registry) RegisterProvider

func (tr *Registry) RegisterProvider(provider Provider) error

RegisterProvider registers a tool provider

func (*Registry) RegisterToolsForAgent

func (tr *Registry) RegisterToolsForAgent(agent *ast.Agent) error

RegisterToolsForAgent registers tools for an agent This will add the tools to the tool registry and return the tools available from the agent.

type Result

type Result struct {
	ToolName string                 `json:"tool_name"`
	Success  bool                   `json:"success"`
	Output   interface{}            `json:"output,omitempty"`
	Error    string                 `json:"error,omitempty"`
	Duration time.Duration          `json:"duration"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

Result represents the result of a tool execution

type Tool

type Tool struct {
	Name        string      `json:"name"`
	Description string      `json:"description"`
	Parameters  schema.JSON `json:"parameters"`
}

Tool represents a tool available to an agent This is a simplified version of the ast.Tool type which is used to provide

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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