toolmeta

package
v0.68.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package toolmeta describes generated model-facing tools: the name, the family it belongs to, and the exact input schema bound to one action.

It deliberately depends on nothing but pkg/tools. The runner, the delegate preset resolver and every generated tool_gen.go import it, so any dependency on a domain package would close an import cycle. It lives in internal/core for exactly that reason; see internal/core/doc.go for the admission rule.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandWritten

func HandWritten(name string) bool

HandWritten reports whether a tool name is an accepted exception to "every model-facing tool is generated". The list is closed: memory was the last union awaiting a split, so the pendingSplit map that held it is gone rather than kept empty — an empty second mechanism only invites a third entry.

func Match

func Match(selector string, tool ActionTool) bool

Match reports whether a selector from a delegate preset's tools: list or from excluded_tools refers to this tool. A selector is either an exact tool name or a family name; family membership comes from the declaration, so a plugin named "goal_helper" is never swept in by the family "goal".

func MatchAny

func MatchAny(selectors []string, tool ActionTool) bool

MatchAny reports whether any selector matches the tool.

Types

type ActionTool

type ActionTool struct {
	// Name is the model-facing tool name, e.g. "recally_feed_add".
	Name string
	// Family groups tools that share a domain, e.g. "recally".
	Family string
	// Resource is the family's sub-resource, e.g. "feed". Empty when the
	// family owns the action directly.
	Resource string
	// Action is the dispatch key inside the family, e.g. "feed_add".
	Action string
	// Description is the declared model-facing description. Operation-backed
	// tools leave it empty and pass prose in from their hand-written adapter.
	Description string
	// InputSchemaJSON is the generated JSON Schema for this tool's arguments.
	InputSchemaJSON string
}

ActionTool is one generated tool: an exact schema bound to one action. Family and Resource are carried, not inferred — a plugin free to call itself "goal_helper" must never be mistaken for a member of the goal family.

func (ActionTool) Definition

func (a ActionTool) Definition(description string) tools.Definition

Definition builds the model-facing definition. description wins when non-empty: operation-backed tools keep their prose in the hand-written adapter next to the handler, declaration-backed tools carry it in the spec.

func (ActionTool) InputSchema

func (a ActionTool) InputSchema() map[string]any

InputSchema decodes the generated schema. It panics on malformed JSON because the input is a compile-time constant produced by toolgen.

type Registry

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

Registry is a lookup over the generated tools a build actually registered. Family answers from this metadata rather than by splitting a name on "_", which would misread every plugin and MCP tool that happens to contain one.

func NewRegistry

func NewRegistry(all ...ActionTool) *Registry

NewRegistry indexes tools by name. A duplicate name is a build-time bug in toolgen's uniqueness check; last one wins here rather than panicking at startup.

func (*Registry) Action

func (r *Registry) Action(name string) string

Action returns the action a registered tool performs, or "" for a name this registry does not know. A split tool carries its action in its name, so an observability attribute can read it here instead of from an argument that no longer exists.

func (*Registry) Family

func (r *Registry) Family(name string) string

Family returns the family a registered tool belongs to, or "" when the name is not a generated tool (plugins, MCP, hand-written core tools).

func (*Registry) Lookup

func (r *Registry) Lookup(name string) (ActionTool, bool)

Lookup returns the declaration for a tool name.

func (*Registry) MatchAnyName

func (r *Registry) MatchAnyName(selectors []string, name string) bool

MatchAnyName reports whether any selector matches the named tool.

func (*Registry) MatchName

func (r *Registry) MatchName(selector, name string) bool

MatchName is Match for a call site that only has a tool name: the runner's excluded_tools filter and the delegate preset whitelist both work off tools.Definition, which carries no family.

A name this registry does not know matches only itself, so a plugin called "goal_helper" is not swept up by the family selector "goal".

func (*Registry) Names

func (r *Registry) Names() []string

Names lists every registered tool name in a stable order.

func (*Registry) SelectsNothing

func (r *Registry) SelectsNothing(selector string, names []string) bool

SelectsNothing reports whether a selector matches none of the given tools, so a caller can warn about a stale entry in a user-written preset instead of silently hiding every tool.

Jump to

Keyboard shortcuts

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