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

tools

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: EUPL-1.2 Imports: 21 Imported by: 0

Documentation

Overview

Package tools définit l'interface des outils de l'agent et les outils fichiers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Truncate

func Truncate(s string, limit int) string

Truncate coupe s à limit caractères et signale la troncature.

Types

type Option

type Option func(*options)

Option configure FS.

func WithReadFilter

func WithReadFilter(f func(tool, absPath string) bool) Option

WithReadFilter fait ignorer à grep et glob les fichiers pour lesquels f renvoie false.

type Registry

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

Registry indexe les outils par nom.

func NewRegistry

func NewRegistry(ts ...Tool) *Registry

func (*Registry) Defs

func (r *Registry) Defs() []llm.ToolDef

Defs renvoie les définitions triées par nom.

func (*Registry) Get

func (r *Registry) Get(name string) (Tool, bool)

type Result

type Result struct {
	Content    string
	IsError    bool
	Path       string
	HashBefore string
	HashAfter  string
	// Denied vaut "policy" quand l'outil a refusé l'appel par règle (vide sinon).
	Denied string
	// ServerDown porte l'identifiant d'un serveur MCP qui vient de tomber pendant
	// cet appel (vide sinon) ; signalé une seule fois par serveur.
	ServerDown string
}

Result est le résultat d'une exécution d'outil.

type Risk

type Risk int

Risk classe l'effet d'un outil.

const (
	Read Risk = iota
	Write
	Exec
	Network
)

type Target

type Target struct {
	Paths   []string // chemins absolus nettoyés
	Command string
	// ForceAsk impose une validation humaine : Permissions.Check renvoie Ask
	// (Deny si une règle deny correspond), quelles que soient les règles allow.
	ForceAsk bool
}

Target décrit ce qu'une invocation touche (pour le moteur de permissions).

type Tool

type Tool interface {
	Name() string
	Description() string
	Schema() json.RawMessage
	Risk() Risk
	Target(args json.RawMessage) (Target, error)
	// Run renvoie une error uniquement en cas d'annulation du contexte.
	Run(ctx context.Context, args json.RawMessage) (Result, error)
}

Tool est un outil appelable par le modèle.

func FS

func FS(root string, limit int, opts ...Option) []Tool

FS renvoie les outils fichiers et recherche ancrés sur root.

func Shell

func Shell(root string, timeout time.Duration, limit int) Tool

Shell renvoie l'outil d'exécution de commandes, ancré sur root.

Jump to

Keyboard shortcuts

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