Help us shape the future of Go! Take the 2026 Go Developer Survey

exectool

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package exectool runs command-line tools declared in a YAML manifest.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tool

type Tool struct {
	Name                 string
	Description          string
	Parameters           map[string]any
	Command              []string
	Timeout              time.Duration
	Workdir              string
	MaxOutputBytes       int
	RequiresConfirmation bool
	// AllowFlagValues lets an argument value begin with "-". Off by default,
	// so a model cannot turn a value into a command-line option.
	AllowFlagValues bool
	// contains filtered or unexported fields
}

Tool is one declared command-line tool.

func (*Tool) Argv

func (t *Tool) Argv(arguments string) ([]string, error)

Argv validates JSON arguments against the tool's parameters and expands the command templates. Each template expands inside its own element, so an argument value can never add an element or reach a shell.

type ToolManifestExecutor

type ToolManifestExecutor struct {
	Tools []*Tool
}

Manifest is a parsed tool manifest.

func Load

func Load(path string) (*ToolManifestExecutor, error)

Load reads and validates a manifest file.

func Parse

func Parse(data []byte) (*ToolManifestExecutor, error)

Parse decodes and validates a manifest. Every problem found is reported, not only the first.

func (*ToolManifestExecutor) ExecuteTool

func (m *ToolManifestExecutor) ExecuteTool(ctx context.Context, name string, arguments string) (string, error)

ExecuteTool runs the named tool with JSON arguments. It satisfies loop.ToolExecutor.

func (*ToolManifestExecutor) Tool

func (m *ToolManifestExecutor) Tool(name string) (*Tool, bool)

Tool returns the tool with the given name.

func (*ToolManifestExecutor) ToolInfos

func (m *ToolManifestExecutor) ToolInfos() ([]*schema.ToolInfo, error)

ToolInfos returns the Eino definitions of every tool, for binding to a model.

type Unknown

type Unknown struct{}

Unknown is the executor when no manifest is given: every call fails.

func (Unknown) ExecuteTool

func (Unknown) ExecuteTool(_ context.Context, name, _ string) (string, error)

Jump to

Keyboard shortcuts

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