tools

package
v1.26.15 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MPL-2.0 Imports: 60 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrToolNotFound          = fault.New("tool not found")
	ErrToolAlreadyRegistered = fault.New("tool already registered")
)
View Source
var DefaultTools = []string{
	"content_search",
	"system_robot_tool_catalog",
	"robot_switch",
	"robot_create",
	"robot_list",
	"robot_get",
	"robot_update",
	"robot_delete",
	"throw_an_error",
}

Functions

func Build

func Build() fx.Option

func ConfirmationDisabled

func ConfirmationDisabled(ctx context.Context) bool

func ContextWithConfirmationDisabled

func ContextWithConfirmationDisabled(ctx context.Context) context.Context

func ContextWithRunContext

func ContextWithRunContext(ctx context.Context, run RunContext) context.Context

Types

type CatalogueTool

type CatalogueTool struct {
	ID                   string
	CallableName         string
	Name                 string
	Description          string
	Source               string
	Available            bool
	RequiresConfirmation bool
}

type Handler

type Handler func(ctx context.Context, args json.RawMessage) (json.RawMessage, error)

Handler is a context.Context-based handler for use by non-ADK transports (e.g. the MCP SSE transport). It receives raw JSON arguments and returns raw JSON output, avoiding a dependency on google.golang.org/adk/tool.Context.

type Registry

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

func NewRegistry

func NewRegistry(
	logger *slog.Logger,
) *Registry

func (*Registry) AllToolIDs

func (p *Registry) AllToolIDs(ctx context.Context) []string

func (*Registry) GetTool

func (p *Registry) GetTool(ctx context.Context, name string) (*Tool, error)

func (*Registry) GetTools

func (p *Registry) GetTools(ctx context.Context, toolNames ...string) (Tools, error)

func (*Registry) GetToolsWithMissing

func (p *Registry) GetToolsWithMissing(ctx context.Context, toolNames ...string) (Tools, []string)

func (*Registry) HasTool

func (p *Registry) HasTool(name string) bool

func (*Registry) ListCatalogue

func (p *Registry) ListCatalogue(ctx context.Context) []CatalogueTool

func (*Registry) Register

func (p *Registry) Register(tool *Tool) error

func (*Registry) RegisterAlias

func (p *Registry) RegisterAlias(alias string, target string)

func (*Registry) Unregister

func (p *Registry) Unregister(name string)

func (*Registry) UnregisterPrefix

func (p *Registry) UnregisterPrefix(prefix string)

type RunContext

type RunContext struct {
	RobotID   opt.Optional[xid.ID]
	AccountID string
	SessionID string
}

func RunContextFromContext

func RunContextFromContext(ctx context.Context) RunContext

type Tool

type Tool struct {
	Definition *mcp.ToolDefinition
	// Source identifies where the tool came from for catalogues and UI labels.
	// Empty means a built-in Storyden tool.
	Source string
	// CallableName is the name exposed to ADK/model providers. Native tools use
	// Definition.Name; dynamic MCP tools may need a stricter generated name.
	CallableName string
	// Builder actually constructs the executor function dynamically. This is
	// useful for tools that depend on runtime context, like database data.
	Builder      func(context.Context) (adktool.Tool, error)
	Handler      Handler
	IsClientTool bool
}

Tool is a wrapper around an actual tool definition, it includes the actual executor as well as the definition and a flag for if it's a client-side tool.

func (*Tool) ADKName

func (t *Tool) ADKName() string

func (*Tool) Description

func (t *Tool) Description() string

func (*Tool) IsLongRunning

func (t *Tool) IsLongRunning() bool

func (*Tool) Name

func (t *Tool) Name() string

type ToolResult

type ToolResult[T any] struct {
	Result T      `json:"result,omitempty"`
	Error  string `json:"error,omitempty"`
}

ToolResult is just because adk doesn't allow returning an error. Since adk just serialises the return into json, this lets us tell the LLM about errors.

func NewError

func NewError[T any](err error) ToolResult[T]

func NewErrorMsg

func NewErrorMsg[T any](msg string) ToolResult[T]

func NewSuccess

func NewSuccess[T any](v T) ToolResult[T]

type Tools

type Tools []*Tool

func (Tools) ToADKTools

func (t Tools) ToADKTools(ctx context.Context) ([]adktool.Tool, error)

type Toolset

type Toolset struct {
	ToolList []adktool.Tool
	// contains filtered or unexported fields
}

Toolset implements adktool.Toolset

func (*Toolset) Name

func (d *Toolset) Name() string

func (*Toolset) Tools

func (d *Toolset) Tools(ctx adkagent.ReadonlyContext) ([]adktool.Tool, error)

Jump to

Keyboard shortcuts

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