Documentation
¶
Index ¶
- Constants
- func GetAdvisorDepth(ctx context.Context) int
- func GetAdvisorRecordSink(ctx context.Context) (any, bool)
- func IsMCPToolName(name string) bool
- func IsNormalizedToolName(name string) bool
- func NormalizeToolName(sourceID, toolName string) string
- func ParseNormalizedToolName(name string) (string, string, bool)
- func WithAdvisorContext(ctx context.Context, ac *AdvisorContext) context.Context
- func WithAdvisorDepth(ctx context.Context, depth int) context.Context
- func WithAdvisorRecordSink(ctx context.Context, sink any) context.Context
- type AdvisorContext
- type ContentType
- type ToolCall
- type ToolContent
- type ToolResult
- type ToolVisibility
- type VirtualTool
- type VirtualToolHandler
- type VirtualToolRegistry
Constants ¶
const ( BuiltinAdvisorSourceID = "advisor" BuiltinAdvisorToolName = "advisor" )
Variables ¶
This section is empty.
Functions ¶
func GetAdvisorDepth ¶
GetAdvisorDepth retrieves the current adviser call depth from context.
func GetAdvisorRecordSink ¶
GetAdvisorRecordSink retrieves the record sink from the context.
func IsMCPToolName ¶
IsMCPToolName checks whether a tool name is a normalized MCP tool. Deprecated: use IsNormalizedToolName for protocol-neutral code.
func IsNormalizedToolName ¶
IsNormalizedToolName checks whether a tool name is a normalized server tool name.
func NormalizeToolName ¶
NormalizeToolName converts source/tool pair to normalized tool name.
func ParseNormalizedToolName ¶
ParseNormalizedToolName parses normalized name and returns sourceID/toolName.
func WithAdvisorContext ¶
func WithAdvisorContext(ctx context.Context, ac *AdvisorContext) context.Context
WithAdvisorContext attaches advisor context to the context.
func WithAdvisorDepth ¶
WithAdvisorDepth sets the adviser call depth in context.
Types ¶
type AdvisorContext ¶
AdvisorContext holds conversation state for the advisor tool.
func GetAdvisorContext ¶
func GetAdvisorContext(ctx context.Context) (*AdvisorContext, bool)
GetAdvisorContext retrieves advisor context from the context.
type ContentType ¶
type ContentType string
ContentType identifies the kind of content a tool produced.
const ( ContentTypeText ContentType = "text" ContentTypeImage ContentType = "image" ContentTypeBlob ContentType = "blob" )
type ToolContent ¶
type ToolContent struct {
Type ContentType `json:"type"`
// Text is populated when Type == ContentTypeText.
Text string `json:"text,omitempty"`
// Data is base64-encoded binary, populated when Type == ContentTypeImage or ContentTypeBlob.
Data string `json:"data,omitempty"`
// MIMEType is populated when Type == ContentTypeImage or ContentTypeBlob.
MIMEType string `json:"mimeType,omitempty"`
}
ToolContent is a single piece of content from a tool result. It is protocol-agnostic — adapters convert it to the wire format required by each upstream model API.
type ToolResult ¶
type ToolResult struct {
Contents []ToolContent
IsError bool
}
ToolResult is the structured return value from a servertool execution.
func ErrorToolResult ¶
func ErrorToolResult(text string) ToolResult
ErrorToolResult constructs an error ToolResult with a single text content item.
func TextToolResult ¶
func TextToolResult(text string) ToolResult
TextToolResult constructs a ToolResult with a single text content item.
func (ToolResult) FirstText ¶
func (r ToolResult) FirstText() string
FirstText returns the text of the first text content item, or empty string if none.
type ToolVisibility ¶
type ToolVisibility string
ToolVisibility controls whether a tool is exposed to clients or kept server-side.
const ( ToolVisibilityClient ToolVisibility = "client" ToolVisibilityServer ToolVisibility = "server" )
type VirtualTool ¶
type VirtualTool struct {
Name string
Description string
InputSchema any
Handler VirtualToolHandler
Visibility ToolVisibility
}
VirtualTool is an in-process tool definition.
type VirtualToolHandler ¶
type VirtualToolHandler func(ctx context.Context, call ToolCall) (ToolResult, error)
VirtualToolHandler executes an in-process protocol-neutral tool.
type VirtualToolRegistry ¶
type VirtualToolRegistry struct {
// contains filtered or unexported fields
}
VirtualToolRegistry holds registered in-process tools.
func NewVirtualToolRegistry ¶
func NewVirtualToolRegistry() *VirtualToolRegistry
func (*VirtualToolRegistry) Get ¶
func (r *VirtualToolRegistry) Get(name string) (VirtualTool, bool)
func (*VirtualToolRegistry) ListVirtualTools ¶
func (r *VirtualToolRegistry) ListVirtualTools() []VirtualTool
func (*VirtualToolRegistry) Register ¶
func (r *VirtualToolRegistry) Register(tool VirtualTool)