tools

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const GenerateImageToolName = "GenerateImage"
View Source
const GenerateVideoToolName = "GenerateVideo"

Variables

View Source
var DefaultResultLimiter = NewResultLimiter("", 200*1024)

DefaultResultLimiter 默认结果限制器 默认限制: 200KB (200 * 1024 chars)

View Source
var GlobalPlanModeState = &PlanModeState{}

GlobalPlanModeState is the global plan mode state

View Source
var GlobalRegistry = NewRegistry()

全局注册中心

Functions

func AllToolsWithBasePath

func AllToolsWithBasePath(basePath string) []tool.BaseTool

AllToolsWithBasePath instantiates every built-in tool bound to basePath and returns them as eino tool.BaseTool values ready for compose.ToolsNodeConfig. basePath is used as the working directory / base path for tools that operate on the filesystem or shell (Glob, Grep, Read, Edit, Write, Bash, Task*).

func ApplyLocalModelRuntimeMode

func ApplyLocalModelRuntimeMode(provider, model, mode string) error

ApplyLocalModelRuntimeMode applies an administrator lifecycle decision immediately.

func CanParallelize

func CanParallelize(call1, call2 ToolCall) bool

CanParallelize 检查两个工具调用是否可以并行执行 规则: 1. 两者都必须是只读工具 2. 不能访问相同的文件路径(写入冲突)

func GenerateImage

func GenerateImage(ctx context.Context, model types.ModelConfig, request ImageGenerationRequest) (string, error)

GenerateImage invokes an image model directly without involving a chat model.

func GeneratedImageHandler

func GeneratedImageHandler(w http.ResponseWriter, r *http.Request)

GeneratedImageHandler serves only random generated files and never lists the directory.

func GeneratedImagesDir

func GeneratedImagesDir() string

func GetMaxResultCharsFromRegistry

func GetMaxResultCharsFromRegistry(toolName string) int

GetMaxResultCharsFromRegistry 从注册中心获取工具的最大结果限制

func ToolNames

func ToolNames() []string

ToolNames returns the names of all available tools

func ToolsByNamesWithBasePath

func ToolsByNamesWithBasePath(basePath string, names []string) []tool.BaseTool

ToolsByNamesWithBasePath instantiates only the selected built-in tools.

func TraceTool

func TraceTool(t tool.BaseTool) tool.BaseTool

TraceTool adds the tool name and call site to execution failures. Wrapping at this common boundary avoids duplicate logging in every tool.

func WalkGlob

func WalkGlob(root, pattern string) ([]string, error)

WalkGlob walks the directory tree and matches files

Types

type Adapter

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

Adapter 把 BaseTool 适配为 eino tool

func (*Adapter) Info

func (a *Adapter) Info(ctx context.Context) (*schema.ToolInfo, error)

func (*Adapter) InvokableRun

func (a *Adapter) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

type AskUserQuestionTool

type AskUserQuestionTool struct{}

AskUserQuestionTool asks the user multiple choice questions

func NewAskUserQuestionTool

func NewAskUserQuestionTool() *AskUserQuestionTool

func (*AskUserQuestionTool) Info

func (*AskUserQuestionTool) InvokableRun

func (t *AskUserQuestionTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*AskUserQuestionTool) ValidateInput

func (t *AskUserQuestionTool) ValidateInput(ctx context.Context, input string) *ValidationResult

type BaseTool

type BaseTool interface {
	Info(ctx context.Context) (*schema.ToolInfo, error)
	ValidateInput(ctx context.Context, input string) *ValidationResult
	InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)
}

BaseTool 基础工具接口

type BashInput

type BashInput struct {
	Command string `json:"command"`           // Command to execute
	Timeout int    `json:"timeout,omitempty"` // Timeout in seconds (default 30)
}

BashInput for bash tool

type BashOutput

type BashOutput struct {
	Stdout   string `json:"stdout"`      // Standard output
	Stderr   string `json:"stderr"`      // Standard error
	ExitCode int    `json:"exit_code"`   // Exit code
	Duration int64  `json:"duration_ms"` // Execution duration in milliseconds
}

BashOutput for bash result

type BashTool

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

BashTool executes bash commands

func NewBashTool

func NewBashTool(workingDir string) *BashTool

func (*BashTool) Getenv

func (t *BashTool) Getenv(key string) string

Getenv gets an environment variable

func (*BashTool) Info

func (t *BashTool) Info(ctx context.Context) (*schema.ToolInfo, error)

func (*BashTool) InvokableRun

func (t *BashTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*BashTool) Setenv

func (t *BashTool) Setenv(key, value string)

Setenv sets an environment variable

func (*BashTool) ValidateInput

func (t *BashTool) ValidateInput(ctx context.Context, input string) *ValidationResult

type EnterPlanModeInput

type EnterPlanModeInput struct {
	Reason string `json:"reason,omitempty"` // Reason for entering plan mode
}

EnterPlanModeInput for enter plan mode tool

type EnterPlanModeOutput

type EnterPlanModeOutput struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

EnterPlanModeOutput for enter plan mode result

type EnterPlanModeTool

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

EnterPlanModeTool enters plan mode for implementation planning

func NewEnterPlanModeTool

func NewEnterPlanModeTool() *EnterPlanModeTool

func (*EnterPlanModeTool) Info

func (*EnterPlanModeTool) InvokableRun

func (t *EnterPlanModeTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*EnterPlanModeTool) ValidateInput

func (t *EnterPlanModeTool) ValidateInput(ctx context.Context, input string) *ValidationResult

type ExitPlanModeInput

type ExitPlanModeInput struct {
	Approved bool   `json:"approved"`           // Whether the plan is approved
	Feedback string `json:"feedback,omitempty"` // User feedback on the plan
}

ExitPlanModeInput for exit plan mode tool

type ExitPlanModeOutput

type ExitPlanModeOutput struct {
	Success    bool   `json:"success"`
	Message    string `json:"message"`
	CanProceed bool   `json:"can_proceed"`
}

ExitPlanModeOutput for exit plan mode result

type ExitPlanModeTool

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

ExitPlanModeTool exits plan mode with approval

func NewExitPlanModeTool

func NewExitPlanModeTool() *ExitPlanModeTool

func (*ExitPlanModeTool) Info

func (*ExitPlanModeTool) InvokableRun

func (t *ExitPlanModeTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*ExitPlanModeTool) ValidateInput

func (t *ExitPlanModeTool) ValidateInput(ctx context.Context, input string) *ValidationResult

type FileEditInput

type FileEditInput struct {
	FilePath  string `json:"file_path"`  // Path to file to edit
	OldString string `json:"old_string"` // String to replace
	NewString string `json:"new_string"` // Replacement string
}

FileEditInput for file edit tool

type FileEditOutput

type FileEditOutput struct {
	Success    bool   `json:"success"`     // Whether edit was successful
	NewContent string `json:"new_content"` // New file content (optional)
	Replaced   int    `json:"replaced"`    // Number of replacements made
}

FileEditOutput for file edit result

type FileEditTool

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

FileEditTool performs exact string replacements in files

func NewFileEditTool

func NewFileEditTool(basePath ...string) *FileEditTool

func (*FileEditTool) Info

func (t *FileEditTool) Info(ctx context.Context) (*schema.ToolInfo, error)

func (*FileEditTool) InvokableRun

func (t *FileEditTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*FileEditTool) ValidateInput

func (t *FileEditTool) ValidateInput(ctx context.Context, input string) *ValidationResult

type FileReadInput

type FileReadInput struct {
	FilePath        string `json:"file_path"`                   // Path to file to read
	Offset          int    `json:"offset,omitempty"`            // Line offset to start reading from
	Limit           int    `json:"limit,omitempty"`             // Maximum number of lines to read
	ShowLineNumbers bool   `json:"show_line_numbers,omitempty"` // Include line numbers in output
}

FileReadInput for file read tool

type FileReadOutput

type FileReadOutput struct {
	Content   string `json:"content"`   // File content
	Lines     int    `json:"lines"`     // Number of lines read
	Truncated bool   `json:"truncated"` // Whether output was truncated
	FullPath  string `json:"full_path"` // Full resolved path
	FileSize  int64  `json:"file_size"` // Original file size in bytes
}

FileReadOutput for file read result

type FileReadTool

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

FileReadTool reads files from the filesystem

func NewFileReadTool

func NewFileReadTool(basePath ...string) *FileReadTool

func (*FileReadTool) Info

func (t *FileReadTool) Info(ctx context.Context) (*schema.ToolInfo, error)

func (*FileReadTool) InvokableRun

func (t *FileReadTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*FileReadTool) ValidateInput

func (t *FileReadTool) ValidateInput(ctx context.Context, input string) *ValidationResult

type FileWriteInput

type FileWriteInput struct {
	FilePath string `json:"file_path"`        // Path to file to write
	Content  string `json:"content"`          // Content to write
	Append   bool   `json:"append,omitempty"` // Append to file instead of overwriting
}

FileWriteInput for file write tool

type FileWriteOutput

type FileWriteOutput struct {
	Success      bool   `json:"success"`       // Whether write was successful
	BytesWritten int64  `json:"bytes_written"` // Number of bytes written
	FullPath     string `json:"full_path"`     // Full path to written file
}

FileWriteOutput for file write result

type FileWriteTool

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

FileWriteTool writes files to the filesystem

func NewFileWriteTool

func NewFileWriteTool(basePath ...string) *FileWriteTool

func (*FileWriteTool) Info

func (t *FileWriteTool) Info(ctx context.Context) (*schema.ToolInfo, error)

func (*FileWriteTool) InvokableRun

func (t *FileWriteTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*FileWriteTool) ValidateInput

func (t *FileWriteTool) ValidateInput(ctx context.Context, input string) *ValidationResult

type GlobInput

type GlobInput struct {
	Pattern string `json:"pattern"` // Glob pattern (e.g., "**/*.go")
	Path    string `json:"path"`    // Base path to search from (optional, defaults to current directory)
}

GlobInput for glob tool

type GlobTool

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

GlobTool matches files by glob patterns

func NewGlobTool

func NewGlobTool(basePath ...string) *GlobTool

func (*GlobTool) Info

func (t *GlobTool) Info(ctx context.Context) (*schema.ToolInfo, error)

func (*GlobTool) InvokableRun

func (t *GlobTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*GlobTool) ValidateInput

func (t *GlobTool) ValidateInput(ctx context.Context, input string) *ValidationResult

type GrepInput

type GrepInput struct {
	Pattern       string `json:"pattern"`                  // Regex pattern to search
	Path          string `json:"path"`                     // Path to search in
	Glob          string `json:"glob,omitempty"`           // File glob filter (e.g., "*.go")
	Context       int    `json:"context,omitempty"`        // Lines of context before/after
	CaseSensitive bool   `json:"case_sensitive,omitempty"` // Case sensitive search
	Regex         bool   `json:"regex,omitempty"`          // Treat pattern as regex (default true)
	Head          int    `json:"head,omitempty"`           // Limit number of results
	Invert        bool   `json:"invert,omitempty"`         // Invert match (like grep -v)
}

GrepInput for grep tool

type GrepMatch

type GrepMatch struct {
	File string `json:"file"` // File path
	Line int    `json:"line"` // Line number
	Text string `json:"text"` // Line content
}

GrepMatch represents a single grep match

func GrepSimple

func GrepSimple(pattern, path string, regex bool) ([]GrepMatch, error)

GrepSimple does a simple regex search without ripgrep

type GrepOutput

type GrepOutput struct {
	Matches []GrepMatch `json:"matches"`
	Count   int         `json:"count"`
	Pattern string      `json:"pattern"`
	Path    string      `json:"path"`
}

GrepOutput for grep results

type GrepTool

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

GrepTool searches file contents using regex

func NewGrepTool

func NewGrepTool(basePath ...string) *GrepTool

func (*GrepTool) Info

func (t *GrepTool) Info(ctx context.Context) (*schema.ToolInfo, error)

func (*GrepTool) InvokableRun

func (t *GrepTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*GrepTool) ValidateInput

func (t *GrepTool) ValidateInput(ctx context.Context, input string) *ValidationResult

type ImageGenerationRequest

type ImageGenerationRequest struct {
	Prompt         string `json:"prompt"`
	NegativePrompt string `json:"negative_prompt,omitempty"`
	SourceURL      string `json:"source_url,omitempty"`
	Size           string `json:"size,omitempty"`
	Quality        string `json:"quality,omitempty"`
}

type ImageGenerationTool

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

func NewImageGenerationTool

func NewImageGenerationTool(model types.ModelConfig) *ImageGenerationTool

func (*ImageGenerationTool) Info

func (*ImageGenerationTool) InvokableRun

func (t *ImageGenerationTool) InvokableRun(ctx context.Context, input string, _ ...tool.Option) (string, error)

type LimitedTool

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

LimitedTool 带结果限制的工具包装器

func WrapToolWithLimiter

func WrapToolWithLimiter(t BaseTool, limiter *ResultLimiter) *LimitedTool

WrapToolWithLimiter 包装工具,添加结果大小限制

func (*LimitedTool) Info

func (t *LimitedTool) Info(ctx context.Context) (*schema.ToolInfo, error)

func (*LimitedTool) InvokableRun

func (t *LimitedTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*LimitedTool) ValidateInput

func (t *LimitedTool) ValidateInput(ctx context.Context, input string) *ValidationResult

type MatchedFiles

type MatchedFiles struct {
	Files []string `json:"files"`
	Count int      `json:"count"`
}

MatchedFiles represents the result of a glob operation

type OptionalValidateTool

type OptionalValidateTool interface {
	ValidateInput(ctx context.Context, input string) *ValidationResult
}

OptionalValidateTool 可选验证接口(简化工具可不实现)

type ParallelToolExecutor

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

ParallelToolExecutor 并行执行工具的帮助类

func NewParallelToolExecutor

func NewParallelToolExecutor(maxWorkers int) *ParallelToolExecutor

NewParallelToolExecutor 创建并行执行器

func (*ParallelToolExecutor) ExecuteParallel

func (p *ParallelToolExecutor) ExecuteParallel(ctx context.Context, calls []ToolCall) []ToolResult

ExecuteParallel 并行执行多个只读工具调用 只读工具: Glob, Grep, WebSearch, WebFetch, Read (对于读取) 等 注意: 这个方法主要用于外部批量调用,对于 ADK 框架内的工具调用, 并行化需要在框架层面处理

type PlanModeState

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

PlanModeState tracks plan mode state

func (*PlanModeState) Enter

func (s *PlanModeState) Enter() bool

func (*PlanModeState) Exit

func (s *PlanModeState) Exit() bool

func (*PlanModeState) GetPhase

func (s *PlanModeState) GetPhase() string

func (*PlanModeState) IsInPlanMode

func (s *PlanModeState) IsInPlanMode() bool

func (*PlanModeState) SetPhase

func (s *PlanModeState) SetPhase(phase string)

type QuestionInput

type QuestionInput struct {
	Question    string           `json:"question"`         // The question to ask
	Options     []QuestionOption `json:"options"`          // Answer options
	Header      string           `json:"header,omitempty"` // Short header for the question
	MultiSelect bool             `json:"multi_select"`     // Allow multiple selections
}

QuestionInput for ask user question tool

type QuestionOption

type QuestionOption struct {
	Label       string `json:"label"`                 // Display label
	Description string `json:"description,omitempty"` // Option description
}

QuestionOption represents a single choice option

type QuestionOutput

type QuestionOutput struct {
	Answer  string   `json:"answer"`  // Selected option label
	Answers []string `json:"answers"` // Multiple selected labels (if multi_select)
	Success bool     `json:"success"` // Whether an answer was received
}

QuestionOutput for ask user question result

type Registry

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

Registry 工具注册中心

func NewRegistry

func NewRegistry() *Registry

NewRegistry 创建新的注册中心

func (*Registry) CreateTool

func (r *Registry) CreateTool(name string, basePath string) (BaseTool, error)

CreateTool 根据名称创建工具实例

func (*Registry) Get

func (r *Registry) Get(name string) (ToolMeta, bool)

Get 获取工具元信息

func (*Registry) GetDefaultRisk

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

GetDefaultRisk 获取工具的默认风险级别

func (*Registry) GetMaxResultChars

func (r *Registry) GetMaxResultChars(name string) int

GetMaxResultChars 获取工具的最大结果字符数限制

func (*Registry) GetToolInfo

func (r *Registry) GetToolInfo(name string, basePath string) (*schema.ToolInfo, error)

GetToolInfo 获取工具的 schema.ToolInfo

func (*Registry) IsReadOnly

func (r *Registry) IsReadOnly(name string) bool

IsReadOnly 判断工具是否为只读

func (*Registry) List

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

List 返回所有已注册的工具名称

func (*Registry) ListReadOnly

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

ListReadOnly 返回所有只读工具名称(可用于并行执行)

func (*Registry) Locker

func (r *Registry) Locker() *sync.Mutex

Locker 返回注册中心的锁,用于外部同步

func (*Registry) Register

func (r *Registry) Register(meta ToolMeta)

Register 注册工具

type ResultLimiter

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

ResultLimiter 工具结果大小限制器

func NewResultLimiter

func NewResultLimiter(tempDir string, maxCharSize int) *ResultLimiter

NewResultLimiter 创建结果限制器 tempDir: 临时文件目录,maxCharSize: 最大字符数限制

func (*ResultLimiter) LimitResult

func (r *ResultLimiter) LimitResult(result string, toolName string) (string, bool)

LimitResult 检查并限制结果大小 如果结果超过限制,写入临时文件并返回文件路径

type SearchResult

type SearchResult struct {
	Title   string `json:"title"`
	URL     string `json:"url"`
	Snippet string `json:"snippet"`
}

SearchResult represents a single search result

type SleepInput

type SleepInput struct {
	Seconds float64 `json:"seconds"` // Number of seconds to sleep
}

SleepInput for sleep tool

type SleepOutput

type SleepOutput struct {
	Slept float64 `json:"slept"` // Actual seconds slept
}

SleepOutput for sleep result

type SleepTool

type SleepTool struct{}

SleepTool waits for a specified duration

func NewSleepTool

func NewSleepTool() *SleepTool

func (*SleepTool) Info

func (t *SleepTool) Info(ctx context.Context) (*schema.ToolInfo, error)

func (*SleepTool) InvokableRun

func (t *SleepTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*SleepTool) ValidateInput

func (t *SleepTool) ValidateInput(ctx context.Context, input string) *ValidationResult

type Task

type Task struct {
	ID          string     `json:"id"`
	Content     string     `json:"content"`
	Status      TaskStatus `json:"status"`
	Owner       string     `json:"owner,omitempty"`
	BlockedBy   []string   `json:"blocked_by,omitempty"`
	Blocking    []string   `json:"blocking,omitempty"`
	CreatedAt   int64      `json:"created_at"`
	UpdatedAt   int64      `json:"updated_at"`
	CompletedAt *int64     `json:"completed_at,omitempty"`
}

Task represents a tracked task

type TaskCreateInput

type TaskCreateInput struct {
	Content   string   `json:"content"`              // Task description
	Owner     string   `json:"owner,omitempty"`      // Owner of the task
	BlockedBy []string `json:"blocked_by,omitempty"` // Task IDs this is blocked by
}

TaskCreateInput for task create tool

type TaskCreateTool

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

TaskCreateTool creates a new task

func NewTaskCreateTool

func NewTaskCreateTool(taskDir ...string) *TaskCreateTool

func (*TaskCreateTool) Info

func (*TaskCreateTool) InvokableRun

func (t *TaskCreateTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*TaskCreateTool) ValidateInput

func (t *TaskCreateTool) ValidateInput(ctx context.Context, input string) *ValidationResult

type TaskGetInput

type TaskGetInput struct {
	ID string `json:"id"` // Task ID
}

TaskGetInput for task get tool

type TaskGetTool

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

TaskGetTool retrieves a task by ID

func NewTaskGetTool

func NewTaskGetTool(taskDir ...string) *TaskGetTool

func (*TaskGetTool) Info

func (t *TaskGetTool) Info(ctx context.Context) (*schema.ToolInfo, error)

func (*TaskGetTool) InvokableRun

func (t *TaskGetTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*TaskGetTool) ValidateInput

func (t *TaskGetTool) ValidateInput(ctx context.Context, input string) *ValidationResult

type TaskListInput

type TaskListInput struct {
	Status string `json:"status,omitempty"` // Filter by status
	Owner  string `json:"owner,omitempty"`  // Filter by owner
}

TaskListInput for task list tool

type TaskListTool

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

TaskListTool lists all tasks

func NewTaskListTool

func NewTaskListTool(taskDir ...string) *TaskListTool

func (*TaskListTool) Info

func (t *TaskListTool) Info(ctx context.Context) (*schema.ToolInfo, error)

func (*TaskListTool) InvokableRun

func (t *TaskListTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*TaskListTool) ValidateInput

func (t *TaskListTool) ValidateInput(ctx context.Context, input string) *ValidationResult

type TaskStatus

type TaskStatus string

TaskStatus represents the status of a task

const (
	TaskStatusPending    TaskStatus = "pending"
	TaskStatusInProgress TaskStatus = "in_progress"
	TaskStatusCompleted  TaskStatus = "completed"
	TaskStatusCancelled  TaskStatus = "cancelled"
)

type TaskStore

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

TaskStore manages tasks in memory and optionally persists to disk

func GetTaskStore

func GetTaskStore(taskDir ...string) *TaskStore

GetTaskStore returns the global task store

func (*TaskStore) CreateTask

func (s *TaskStore) CreateTask(content, owner string, blockedBy []string) (*Task, error)

func (*TaskStore) DeleteTask

func (s *TaskStore) DeleteTask(id string) error

func (*TaskStore) GetTask

func (s *TaskStore) GetTask(id string) *Task

func (*TaskStore) ListTasks

func (s *TaskStore) ListTasks() []*Task

func (*TaskStore) UpdateTask

func (s *TaskStore) UpdateTask(id string, updates map[string]interface{}) (*Task, error)

type TaskUpdateInput

type TaskUpdateInput struct {
	ID      string `json:"id"`                // Task ID
	Status  string `json:"status,omitempty"`  // New status
	Owner   string `json:"owner,omitempty"`   // New owner
	Content string `json:"content,omitempty"` // New content
}

TaskUpdateInput for task update tool

type TaskUpdateTool

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

TaskUpdateTool updates a task

func NewTaskUpdateTool

func NewTaskUpdateTool(taskDir ...string) *TaskUpdateTool

func (*TaskUpdateTool) Info

func (*TaskUpdateTool) InvokableRun

func (t *TaskUpdateTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*TaskUpdateTool) ValidateInput

func (t *TaskUpdateTool) ValidateInput(ctx context.Context, input string) *ValidationResult

type TodoInput

type TodoInput struct {
	Action  string              `json:"action"`            // Action: "add", "done", "remove", "clear"
	Content string              `json:"content,omitempty"` // Todo content (for add)
	Index   int                 `json:"index,omitempty"`   // Index (for done/remove)
	Todos   []map[string]string `json:"todos,omitempty"`   // Full todo list (for clear)
}

TodoInput for todo write tool

type TodoItem

type TodoItem struct {
	Content string `json:"content"`
	Done    bool   `json:"done"`
}

TodoItem represents a single todo item

type TodoWriteTool

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

TodoWriteTool manages a simple todo list

func NewTodoWriteTool

func NewTodoWriteTool(taskDir ...string) *TodoWriteTool

func (*TodoWriteTool) Info

func (t *TodoWriteTool) Info(ctx context.Context) (*schema.ToolInfo, error)

func (*TodoWriteTool) InvokableRun

func (t *TodoWriteTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*TodoWriteTool) ValidateInput

func (t *TodoWriteTool) ValidateInput(ctx context.Context, input string) *ValidationResult

type ToolCall

type ToolCall struct {
	Name      string
	Arguments string
	Tool      BaseTool
}

ToolCall 表示一次工具调用

type ToolInterface

type ToolInterface interface {
	Info(ctx context.Context) (*schema.ToolInfo, error)
	InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)
}

ToolInterface is the interface all tools must implement

func AllTools

func AllTools() []ToolInterface

AllTools returns all available built-in tools

type ToolMeta

type ToolMeta struct {
	Name           string
	Desc           string
	IsReadOnly     bool                              // 是否只读工具,可并行执行
	MaxResultChars int                               // 最大结果字符数,超过则写入临时文件
	DefaultRisk    string                            // 默认风险级别: low, medium, high
	Creator        func(basePath string) interface{} // 创建工具实例的函数
}

ToolMeta 工具元信息

type ToolResult

type ToolResult struct {
	Name    string
	Result  string
	Error   error
	Success bool
}

ToolResult 表示工具执行结果

type ToolResultLimiter

type ToolResultLimiter interface {
	LimitResult(result string, toolName string) (string, bool)
}

ToolResultLimiter 接口,用于包装工具执行时限制结果大小

type ValidationError

type ValidationError struct {
	Message string
	Code    int
}

ValidationError 验证错误

func (*ValidationError) Error

func (e *ValidationError) Error() string

type ValidationResult

type ValidationResult struct {
	Valid     bool
	Message   string
	ErrorCode int
}

ValidationResult 验证结果

type VideoGenerationRequest

type VideoGenerationRequest struct {
	Prompt          string
	SourceURL       string
	Size            string
	DurationSeconds int
}

type VideoGenerationResult

type VideoGenerationResult struct {
	URL           string
	ProviderJobID string
}

func GenerateVideo

GenerateVideo calls an OpenAI-compatible asynchronous video endpoint. Provider adapters can be added here without changing the public RPC.

type VideoGenerationTool

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

func NewVideoGenerationTool

func NewVideoGenerationTool(model types.ModelConfig) *VideoGenerationTool

func (*VideoGenerationTool) Info

func (*VideoGenerationTool) InvokableRun

func (t *VideoGenerationTool) InvokableRun(ctx context.Context, input string, _ ...tool.Option) (string, error)

type WebFetchInput

type WebFetchInput struct {
	URL    string `json:"url"`             // URL to fetch
	Prompt string `json:"prompt"`          // What to extract from the page
	Cache  bool   `json:"cache,omitempty"` // Use cached result (default true)
}

WebFetchInput for web fetch tool

type WebFetchOutput

type WebFetchOutput struct {
	Content    string `json:"content"`         // Fetched content
	Title      string `json:"title,omitempty"` // Page title
	StatusCode int    `json:"status_code"`     // HTTP status code
	URL        string `json:"url"`             // Final URL (after redirects)
}

WebFetchOutput for web fetch result

type WebFetchTool

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

WebFetchTool fetches and analyzes web content

func NewWebFetchTool

func NewWebFetchTool() *WebFetchTool

func (*WebFetchTool) Info

func (t *WebFetchTool) Info(ctx context.Context) (*schema.ToolInfo, error)

func (*WebFetchTool) InvokableRun

func (t *WebFetchTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*WebFetchTool) ValidateInput

func (t *WebFetchTool) ValidateInput(ctx context.Context, input string) *ValidationResult

type WebSearchInput

type WebSearchInput struct {
	Query string `json:"query"`           // Search query
	Count int    `json:"count,omitempty"` // Number of results (default 10)
}

WebSearchInput for web search tool

type WebSearchOutput

type WebSearchOutput struct {
	Results []SearchResult `json:"results"`
	Query   string         `json:"query"`
}

WebSearchOutput for web search result

type WebSearchTool

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

WebSearchTool searches the web

func NewWebSearchTool

func NewWebSearchTool() *WebSearchTool

func (*WebSearchTool) Info

func (t *WebSearchTool) Info(ctx context.Context) (*schema.ToolInfo, error)

func (*WebSearchTool) InvokableRun

func (t *WebSearchTool) InvokableRun(ctx context.Context, input string, opts ...tool.Option) (string, error)

func (*WebSearchTool) ValidateInput

func (t *WebSearchTool) ValidateInput(ctx context.Context, input string) *ValidationResult

Jump to

Keyboard shortcuts

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