tool

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// Namespace prefix for all AI engine annotations.
	AnnotationKeyPrefix = "ai-engine.malonaz.com/"

	// The fully qualified gRPC service name that backs this tool.
	AnnotationKeyGRPCService = AnnotationKeyPrefix + "grpc-service"
	// The fully qualified gRPC method name that backs this tool.
	AnnotationKeyGRPCMethod = AnnotationKeyPrefix + "grpc-method"
	// The fully qualified protobuf message name used as the tool's input/output schema.
	AnnotationKeyProtoMessage = AnnotationKeyPrefix + "proto-message"

	// The type of tool: discovery, generate-message, or generate-rpc-request.
	AnnotationKeyToolType = AnnotationKeyPrefix + "tool-type"
	// When "true", indicates the tool has no side effects (safe to call speculatively).
	AnnotationKeyNoSideEffect = AnnotationKeyPrefix + "no-side-effect"
	// A comma-separated field mask applied to the generated message to restrict which fields are populated.
	AnnotationKeyGenerationFieldMask = AnnotationKeyPrefix + "generation-field-mask"

	// When present, indicates the tool was registered via a discovery tool set and must be discovered before use.
	AnnotationKeyDiscoverableTool = AnnotationKeyPrefix + "discoverable-tool"
	// The name of the tool set this tool belongs to, used to resolve discovery tool calls.
	AnnotationKeyToolSetName = AnnotationKeyPrefix + "tool-set-name"
	// When "true", indicates this tool is pre-discovered and available without requiring a discovery tool call.
	AnnotationKeyPreDiscoveredTool = AnnotationKeyPrefix + "pre-discovered-tool"
	// The comma-separated list of tool names returned by a discovery tool call.
	AnnotationKeyDiscoveredTools = AnnotationKeyPrefix + "discovered-tools"

	// Tool type indicating a discovery tool that reveals other tools to the model.
	AnnotationValueToolTypeDiscovery = "discovery"
	// Tool type indicating the tool generates a standalone protobuf message.
	AnnotationValueToolTypeGenerateMessage = "generate-message"
	// Tool type indicating the tool generates a gRPC request to be dispatched.
	AnnotationValueToolTypeGenerateRPCRequest = "generate-rpc-request"
)

Variables

This section is empty.

Functions

func CreateDiscoveryTool

func CreateDiscoveryTool(request *CreateDiscoveryToolRequest) *aipb.Tool

func MessageToolRequest

func MessageToolRequest(message proto.Message, options ...Option) *pb.CreateToolRequest

MessageToolRequest builds a CreateToolRequest whose schema mirrors the given message, so the resulting tool call parses straight back into it.

func MethodToolRequest

func MethodToolRequest(method Method, options ...Option) *pb.CreateToolRequest

MethodToolRequest builds a CreateToolRequest whose schema mirrors the given method's request message.

func NewSchemaConfiguration

func NewSchemaConfiguration(options ...Option) *pb.SchemaConfiguration

NewSchemaConfiguration builds a schema configuration from options, for the APIs that take one directly (e.g. CreateServiceToolSet).

func ParseDiscoveryToolCall

func ParseDiscoveryToolCall(toolCall *aipb.ToolCall) (*aipb.ToolCallDiscovery, error)

func ParseToolCall

func ParseToolCall(schema *pbjson.SchemaBuilder, toolCall *aipb.ToolCall, toolSets []*aipb.ToolSet) (*pb.ParseToolCallResponse, error)

func ParseToolCallMessage

func ParseToolCallMessage(schemaBuilder *pbjson.SchemaBuilder, toolCall *aipb.ToolCall) (*structpb.Struct, error)

Types

type CreateDiscoveryToolRequest

type CreateDiscoveryToolRequest struct {
	Name        string
	Description string
	Tools       []*aipb.Tool
}

type Method

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

Method identifies a gRPC method to build a tool from.

func NewMethod

func NewMethod(grpcFullMethodName string) Method

NewMethod accepts a generated gRPC full method name, e.g. userservicepb.UserService_CreateContact_FullMethodName.

gRPC spells these "/package.Service/Method", while protobuf descriptor lookups use the dotted "package.Service.Method" form.

func (Method) FullName

func (m Method) FullName() string

FullName returns the dotted "package.Service.Method" form. This is what ToolCallRpc.method_full_name carries, and what the middleware matches on (it resolves gRPC's slashed name to a descriptor before comparing), so the same value serves both tool dispatch and hook registration.

type Option

type Option func(*pb.SchemaConfiguration)

Option configures the schema derived from a descriptor.

func WithFieldMask

func WithFieldMask(fieldMask *pbfieldmask.FieldMask) Option

WithFieldMask restricts the tool schema to the masked fields.

func WithMaxDepth

func WithMaxDepth(maxDepth int32) Option

WithMaxDepth bounds how deep the schema recurses. Left unset, the server applies its own default rather than us forking that policy client-side.

func WithResponseReadMask

func WithResponseReadMask() Option

WithResponseReadMask lets the model request only the response fields it needs. Method tools only.

func WithResponseSchema

func WithResponseSchema(maxDepth int32) Option

WithResponseSchema includes the response schema in the tool description, bounded by maxDepth. Verbose, so use with care. Method tools only.

func WithSummary

func WithSummary(summary string) Option

WithSummary injects a required summary field, documented with the given string: a human-readable account of the call for approval surfaces that never show raw arguments or resource names.

func WithTitle

func WithTitle(title string) Option

WithTitle injects a required title field, documented with the given string, that the model fills first. Useful when surfacing tool calls for approval.

Jump to

Keyboard shortcuts

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