tool

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithInvocation

func ContextWithInvocation(ctx context.Context, invocation Invocation) context.Context

func Def

func Def(name, description string, argsProto any) *aop.ToolDefinition

Def builds a complete Definition from a name, description, and an args struct prototype.

func ParseArgs

func ParseArgs[T any](arguments string) (T, error)

ParseArgs unmarshals the raw JSON arguments string into a typed struct.

func ResultHasImages

func ResultHasImages(r *Result) bool

func ResultHasMedia

func ResultHasMedia(r *Result) bool

func ResultText

func ResultText(r *Result) string

func SchemaOf

func SchemaOf(proto any) map[string]any

SchemaOf generates a JSON Schema (as map[string]any) from a Go struct.

func WorkDirFromContext

func WorkDirFromContext(ctx context.Context, fallback string) string

Types

type Definition

type Definition = aop.ToolDefinition

Definition describes a tool the LLM can invoke — the AOP transport proto.

type Executor

type Executor interface {
	ToolDefinitions() []*aop.ToolDefinition
	ExecuteTool(ctx context.Context, name, arguments string) (*Result, error)
}

Executor is the minimal interface the agent loop needs to discover and invoke tools. CommandRegistry satisfies it directly.

func EmptyExecutor

func EmptyExecutor() Executor

EmptyExecutor returns an Executor with no tools.

type Invocation

type Invocation struct {
	WorkDir   string
	CallID    string
	SessionID string
	TurnID    string
	Emitter   string
}

Invocation carries executor-owned context that must not become model-facing tool arguments.

func InvocationFromContext

func InvocationFromContext(ctx context.Context) Invocation

type Result

type Result = aop.ToolResult

Result is the value returned by Tool.Execute — the AOP tool result proto.

func ErrorResult

func ErrorResult(msg string) *Result

func TerminateResult

func TerminateResult(s string) *Result

func TextResult

func TextResult(s string) *Result

type Tool

type Tool interface {
	Name() string
	Description() string
	Definition() *aop.ToolDefinition
	Execute(ctx context.Context, arguments string) (*Result, error)
}

Tool is a single tool that an LLM agent can invoke.

Jump to

Keyboard shortcuts

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