tools

package
v0.0.0-...-14e3c9d Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BashCommand = Command{
	Name:        "bash",
	Description: "Execute a bash command",
	Schema: map[string]interface{}{
		"type": "object",
		"properties": map[string]interface{}{
			"command": map[string]interface{}{
				"type":        "string",
				"description": "The bash command to execute",
			},
		},
		"required": []string{"command"},
	},
}

Functions

func GenerateCommandDocs

func GenerateCommandDocs(commands []Command, additionalDocs []string, envVariables map[string]interface{}) string

func GuardMultilineInput

func GuardMultilineInput(action string, getFirstMultilineCmd func(string) *regexp.Regexp) string

func RegisterSpecializedTools

func RegisterSpecializedTools(registry *tools.Registry) error

Types

type Bundle

type Bundle struct {
	Path         string    `json:"path"`
	Commands     []Command `json:"commands"`
	StateCommand string    `json:"state_command,omitempty"`
}

type Command

type Command struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	EndName     string                 `json:"end_name,omitempty"`
	Schema      map[string]interface{} `json:"schema,omitempty"`
}

func (Command) GetFunctionCallingTool

func (c Command) GetFunctionCallingTool() map[string]interface{}

type Environment

type Environment interface {
	Communicate(input string, timeout int, check string, errorMsg string) (string, error)
	ReadFile(path string, encoding string, errors string) (string, error)
	WriteFile(path string, content string) error
	SetEnvVariables(envVariables map[string]interface{}) error
}

type ToolConfig

type ToolConfig struct {
	Filter                          *ToolFilterConfig      `json:"filter"`
	Bundles                         []Bundle               `json:"bundles"`
	EnvVariables                    map[string]interface{} `json:"env_variables"`
	RegistryVariables               map[string]interface{} `json:"registry_variables"`
	SubmitCommand                   string                 `json:"submit_command"`
	EnableBashTool                  bool                   `json:"enable_bash_tool"`
	FormatErrorTemplate             string                 `json:"format_error_template"`
	CommandDocs                     string                 `json:"command_docs"`
	MultiLineCommandEndings         map[string]string      `json:"multi_line_command_endings"`
	SubmitCommandEndName            string                 `json:"submit_command_end_name"`
	ResetCommands                   []interface{}          `json:"reset_commands"`
	ExecutionTimeout                int                    `json:"execution_timeout"`
	InstallTimeout                  int                    `json:"install_timeout"`
	TotalExecutionTimeout           int                    `json:"total_execution_timeout"`
	MaxConsecutiveExecutionTimeouts int                    `json:"max_consecutive_execution_timeouts"`
	// contains filtered or unexported fields
}

func NewToolConfig

func NewToolConfig() *ToolConfig

func (*ToolConfig) Commands

func (c *ToolConfig) Commands() []Command

func (*ToolConfig) Initialize

func (c *ToolConfig) Initialize()

func (*ToolConfig) StateCommands

func (c *ToolConfig) StateCommands() []string

func (*ToolConfig) Tools

func (c *ToolConfig) Tools() []map[string]interface{}

func (*ToolConfig) UseFunctionCalling

func (c *ToolConfig) UseFunctionCalling() bool

type ToolFilterConfig

type ToolFilterConfig struct {
	BlocklistErrorTemplate string            `json:"blocklist_error_template"`
	Blocklist              []string          `json:"blocklist"`
	BlocklistStandalone    []string          `json:"blocklist_standalone"`
	BlockUnlessRegex       map[string]string `json:"block_unless_regex"`
}

func DefaultToolFilterConfig

func DefaultToolFilterConfig() *ToolFilterConfig

type ToolHandler

type ToolHandler struct {
	Config          *ToolConfig
	ResetCommands   []string
	CommandPatterns map[string]*regexp.Regexp
	Logger          tools.Logger
	MockState       map[string]string
}

func NewToolHandler

func NewToolHandler(config *ToolConfig, logger tools.Logger) *ToolHandler

func (*ToolHandler) CheckForSubmissionCmd

func (h *ToolHandler) CheckForSubmissionCmd(output string) bool

func (*ToolHandler) GetState

func (h *ToolHandler) GetState(env Environment) (map[string]string, error)

func (*ToolHandler) GuardMultilineInput

func (h *ToolHandler) GuardMultilineInput(action string) string

func (*ToolHandler) Install

func (h *ToolHandler) Install(env Environment) error

func (*ToolHandler) ParseActions

func (h *ToolHandler) ParseActions(output map[string]interface{}) (string, string, error)

func (*ToolHandler) Reset

func (h *ToolHandler) Reset(env Environment) error

func (*ToolHandler) ShouldBlockAction

func (h *ToolHandler) ShouldBlockAction(action string) bool

Jump to

Keyboard shortcuts

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