tool

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package tool provides ADK-Go tool.Tool adapters for agent-go consumers.

Package tool provides shared tool system types and definitions for agent-go consumers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAdkTool added in v0.2.0

func NewAdkTool(cfg AdkToolConfig, handler func(name string, args json.RawMessage) *ToolResult) adktool.Tool

NewAdkTool creates an ADK-compatible tool from a handler and config.

func ToOpenAIDefinitions added in v0.2.0

func ToOpenAIDefinitions(defs []ToolDefinition) []fwllm.OpenAIToolDefinition

ToOpenAIDefinitions converts a slice of ToolDefinition (ADK format) to OpenAI-compatible tool definitions for use with non-ADK LLM calls.

Types

type AdkToolConfig added in v0.2.0

type AdkToolConfig struct {
	Name        string
	Description string
	Parameters  map[string]any // OpenAI-style parameter definitions
}

AdkToolConfig configures an ADK tool adapter.

type ApprovalMode

type ApprovalMode string
const (
	ApprovalModeAuto    ApprovalMode = "auto"
	ApprovalModeDefault ApprovalMode = "default"
	ApprovalModeManual  ApprovalMode = "manual"
)

func ParseApprovalMode

func ParseApprovalMode(s string) ApprovalMode

type AskQuestionsArgs

type AskQuestionsArgs struct {
	Questions []QuestionItem `json:"questions"`
}

type DelegateTaskArgs

type DelegateTaskArgs struct {
	Description string   `json:"description"`
	FilePaths   []string `json:"filePaths"`
}

type EditFileArgs

type EditFileArgs struct {
	Path  string          `json:"path"`
	Edits json.RawMessage `json:"edits"`
}

type FileSearchArgs

type FileSearchArgs struct {
	Glob string `json:"glob"`
}

type GrepSearchArgs

type GrepSearchArgs struct {
	Query          string `json:"query"`
	IsRegexp       bool   `json:"isRegexp,omitempty"`
	IncludePattern string `json:"includePattern,omitempty"`
}

type ListDirArgs

type ListDirArgs struct {
	Path string `json:"path"`
}

type MemoryArgs

type MemoryArgs struct {
	Action  string `json:"action"`
	Path    string `json:"path"`
	Content string `json:"content,omitempty"`
}

type NewWorkspaceArgs

type NewWorkspaceArgs struct {
	Description string `json:"description"`
	Template    string `json:"template,omitempty"`
}

type QuestionItem

type QuestionItem struct {
	Header string `json:"header"`
	Answer string `json:"answer"`
}

type ReadFileArgs

type ReadFileArgs struct {
	Path      string `json:"path"`
	StartLine int    `json:"startLine,omitempty"`
	EndLine   int    `json:"endLine,omitempty"`
}

type RiskLevel

type RiskLevel string
const (
	RiskSafe      RiskLevel = "safe"
	RiskModerate  RiskLevel = "moderate"
	RiskDangerous RiskLevel = "dangerous"
)

type RunCommandArgs

type RunCommandArgs struct {
	Command string `json:"command"`
}

type SubTaskDelegate

type SubTaskDelegate func(ctx context.Context, description string, filePaths []string, workspaceRoot string) *SubTaskResult

type SubTaskResult

type SubTaskResult struct {
	Success      bool     `json:"success"`
	Summary      string   `json:"summary"`
	FilesChanged []string `json:"files_changed"`
	Error        string   `json:"error,omitempty"`
}

type TokenUsageInfo

type TokenUsageInfo struct {
	PromptTokens     int `json:"prompt_tokens"`
	CompletionTokens int `json:"completion_tokens"`
	TotalTokens      int `json:"total_tokens"`
	ContextWindow    int `json:"context_window"`
}

type ToolDefinition

type ToolDefinition struct {
	Name        string
	Description string
	Parameters  any
}

ToolDefinition 工具定义(供 LLM function calling 使用)

func DefaultToolDefinitions added in v0.2.0

func DefaultToolDefinitions() []ToolDefinition

DefaultToolDefinitions returns a shared set of 18 tool definitions in ToolDefinition format (framework-neutral, no application-specific names). These are the standard tools available to all agent-go based applications. Application-specific tools (e.g., logo generator, FFmpeg) should be defined in the application layer, not here.

type ToolExecutor

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

ToolExecutor 基于注册表的工具执行器

func NewToolExecutor

func NewToolExecutor() *ToolExecutor

NewToolExecutor 创建空的工具执行器

func (*ToolExecutor) Execute

func (e *ToolExecutor) Execute(toolName string, args json.RawMessage) *ToolResult

Execute 统一执行入口

func (*ToolExecutor) Get

func (e *ToolExecutor) Get(name string) (ToolHandler, bool)

Get 获取已注册的工具处理器

func (*ToolExecutor) ListTools

func (e *ToolExecutor) ListTools() []string

ListTools 列出所有已注册的工具名

func (*ToolExecutor) Register

func (e *ToolExecutor) Register(name string, handler ToolHandler)

Register 注册一个工具处理器

type ToolHandler

type ToolHandler func(args json.RawMessage) *ToolResult

ToolHandler 单个工具的执行函数类型

type ToolResult

type ToolResult struct {
	Success    bool            `json:"success"`
	Output     string          `json:"output,omitempty"`
	Error      string          `json:"error,omitempty"`
	Data       json.RawMessage `json:"data,omitempty"`
	Diff       string          `json:"diff,omitempty"`
	BackupPath string          `json:"backup_path,omitempty"`
	FileExists bool            `json:"file_exists,omitempty"`
}

ToolResult 工具执行结果

type WriteFileArgs

type WriteFileArgs struct {
	Path    string `json:"path"`
	Content string `json:"content"`
}

Jump to

Keyboard shortcuts

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