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

exectool

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 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 Manifest

type Manifest struct {
	Tools []*Tool
}

Manifest is a parsed tool manifest.

func Load

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

Load reads and validates a manifest file.

func Parse

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

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

func (*Manifest) ExecuteTool

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

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

func (*Manifest) Tool

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

Tool returns the tool with the given name.

func (*Manifest) ToolInfos

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

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

type Tool

type Tool struct {
	Name           string
	Description    string
	Parameters     map[string]any
	Command        []string
	Timeout        time.Duration
	Workdir        string
	MaxOutputBytes int
	Confirm        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.

func (*Tool) Run

func (t *Tool) Run(ctx context.Context, arguments string) (string, error)

Run validates the arguments, builds the command line and runs it. Output is stdout followed by stderr, capped at MaxOutputBytes. A non-zero exit or a timeout is an error that still carries the output.

Jump to

Keyboard shortcuts

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