builtin

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterAll

func RegisterAll(reg *tool.Registry, cfg RegisterConfig)

RegisterAll 注册所有内置工具

Types

type AgentTool

type AgentTool struct {
	CurrentProvider func() provider.Provider // 动态获取当前 provider
	CurrentModel    func() string            // 动态获取当前 model
	Tools           *tool.Registry
	Permission      tool.PermissionChecker
	Tracker         *cost.Tracker
	MaxTokens       int
	SendMsg         func(interface{})          // TUI 通知回调
	SubAgentReg     *agentPkg.SubAgentRegistry // 子 agent 注册表
}

AgentTool 派生子 Agent 工具 Provider/Model 使用 getter 动态读取当前运行时(/resume 后跟随主 Agent 切换)

func (*AgentTool) Description

func (t *AgentTool) Description() string

func (*AgentTool) Execute

func (t *AgentTool) Execute(ctx context.Context, input json.RawMessage) (*tool.Result, error)

func (*AgentTool) InputSchema

func (t *AgentTool) InputSchema() map[string]any

func (*AgentTool) IsReadOnly

func (t *AgentTool) IsReadOnly() bool

func (*AgentTool) Name

func (t *AgentTool) Name() string

type AskUserTool

type AskUserTool struct {
	// AskFunc 由 TUI 注入的提问回调
	// 参数:问题文本,返回:用户回答
	AskFunc func(ctx context.Context, question string) (string, error)
}

AskUserTool 向用户提问工具

func (*AskUserTool) Description

func (t *AskUserTool) Description() string

func (*AskUserTool) Execute

func (t *AskUserTool) Execute(ctx context.Context, input json.RawMessage) (*tool.Result, error)

func (*AskUserTool) InputSchema

func (t *AskUserTool) InputSchema() map[string]any

func (*AskUserTool) IsReadOnly

func (t *AskUserTool) IsReadOnly() bool

func (*AskUserTool) Name

func (t *AskUserTool) Name() string

type BashTool

type BashTool struct{}

BashTool Shell 命令执行工具

func (*BashTool) Description

func (t *BashTool) Description() string

func (*BashTool) Execute

func (t *BashTool) Execute(ctx context.Context, input json.RawMessage) (*tool.Result, error)

func (*BashTool) InputSchema

func (t *BashTool) InputSchema() map[string]any

func (*BashTool) IsReadOnly

func (t *BashTool) IsReadOnly() bool

func (*BashTool) Name

func (t *BashTool) Name() string

type EditTool

type EditTool struct {
	// ConfirmFunc Diff 确认回调,返回 true 则写入,false 则取消
	// 为 nil 时直接写入(向后兼容)
	ConfirmFunc func(ctx context.Context, path string, diffText string) (bool, error)
}

EditTool 文件编辑工具(字符串替换)

func (*EditTool) Description

func (t *EditTool) Description() string

func (*EditTool) Execute

func (t *EditTool) Execute(ctx context.Context, input json.RawMessage) (*tool.Result, error)

func (*EditTool) InputSchema

func (t *EditTool) InputSchema() map[string]any

func (*EditTool) IsReadOnly

func (t *EditTool) IsReadOnly() bool

func (*EditTool) Name

func (t *EditTool) Name() string

type GlobTool

type GlobTool struct{}

GlobTool 文件模式匹配工具

func (*GlobTool) Description

func (t *GlobTool) Description() string

func (*GlobTool) Execute

func (t *GlobTool) Execute(_ context.Context, input json.RawMessage) (*tool.Result, error)

func (*GlobTool) InputSchema

func (t *GlobTool) InputSchema() map[string]any

func (*GlobTool) IsReadOnly

func (t *GlobTool) IsReadOnly() bool

func (*GlobTool) Name

func (t *GlobTool) Name() string

type GrepTool

type GrepTool struct{}

GrepTool 文件内容搜索工具

func (*GrepTool) Description

func (t *GrepTool) Description() string

func (*GrepTool) Execute

func (t *GrepTool) Execute(ctx context.Context, input json.RawMessage) (*tool.Result, error)

func (*GrepTool) InputSchema

func (t *GrepTool) InputSchema() map[string]any

func (*GrepTool) IsReadOnly

func (t *GrepTool) IsReadOnly() bool

func (*GrepTool) Name

func (t *GrepTool) Name() string

type ReadTool

type ReadTool struct{}

ReadTool 文件读取工具

func (*ReadTool) Description

func (t *ReadTool) Description() string

func (*ReadTool) Execute

func (t *ReadTool) Execute(_ context.Context, input json.RawMessage) (*tool.Result, error)

func (*ReadTool) InputSchema

func (t *ReadTool) InputSchema() map[string]any

func (*ReadTool) IsReadOnly

func (t *ReadTool) IsReadOnly() bool

func (*ReadTool) Name

func (t *ReadTool) Name() string

type RegisterConfig

type RegisterConfig struct {
	AskFunc     func(ctx context.Context, question string) (string, error)
	ConfirmFunc func(ctx context.Context, path string, diffText string) (bool, error)

	// SubAgent 相关依赖(Provider/Model 用 getter 动态读取,/resume 后自动跟随)
	CurrentProvider func() provider.Provider
	CurrentModel    func() string
	Permission      tool.PermissionChecker
	Tracker         *cost.Tracker
	MaxTokens       int
	SendMsg         func(interface{})
	SubAgentReg     *agentPkg.SubAgentRegistry
}

RegisterConfig 内置工具注册配置

type SendMessageTool

type SendMessageTool struct {
	SubAgentReg *agentPkg.SubAgentRegistry
}

SendMessageTool 向子 Agent 发送消息

func (*SendMessageTool) Description

func (t *SendMessageTool) Description() string

func (*SendMessageTool) Execute

func (t *SendMessageTool) Execute(_ context.Context, input json.RawMessage) (*tool.Result, error)

func (*SendMessageTool) InputSchema

func (t *SendMessageTool) InputSchema() map[string]any

func (*SendMessageTool) IsReadOnly

func (t *SendMessageTool) IsReadOnly() bool

func (*SendMessageTool) Name

func (t *SendMessageTool) Name() string

type Task

type Task struct {
	ID          int    `json:"id"`
	Title       string `json:"title"`
	Status      string `json:"status"` // pending / in_progress / completed / stopped
	Description string `json:"description,omitempty"`
}

Task 任务数据

type TaskStore

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

TaskStore 内存任务存储

type TaskTool

type TaskTool struct{}

TaskTool 任务管理工具

func (*TaskTool) Description

func (t *TaskTool) Description() string

func (*TaskTool) Execute

func (t *TaskTool) Execute(_ context.Context, input json.RawMessage) (*tool.Result, error)

func (*TaskTool) InputSchema

func (t *TaskTool) InputSchema() map[string]any

func (*TaskTool) IsReadOnly

func (t *TaskTool) IsReadOnly() bool

func (*TaskTool) Name

func (t *TaskTool) Name() string

type WebFetchTool

type WebFetchTool struct{}

WebFetchTool 网页抓取工具

func (*WebFetchTool) Description

func (t *WebFetchTool) Description() string

func (*WebFetchTool) Execute

func (t *WebFetchTool) Execute(ctx context.Context, input json.RawMessage) (*tool.Result, error)

func (*WebFetchTool) InputSchema

func (t *WebFetchTool) InputSchema() map[string]any

func (*WebFetchTool) IsReadOnly

func (t *WebFetchTool) IsReadOnly() bool

func (*WebFetchTool) Name

func (t *WebFetchTool) Name() string

type WebSearchTool

type WebSearchTool struct{}

WebSearchTool 网页搜索工具(DuckDuckGo HTML)

func (*WebSearchTool) Description

func (t *WebSearchTool) Description() string

func (*WebSearchTool) Execute

func (t *WebSearchTool) Execute(ctx context.Context, input json.RawMessage) (*tool.Result, error)

func (*WebSearchTool) InputSchema

func (t *WebSearchTool) InputSchema() map[string]any

func (*WebSearchTool) IsReadOnly

func (t *WebSearchTool) IsReadOnly() bool

func (*WebSearchTool) Name

func (t *WebSearchTool) Name() string

type WriteTool

type WriteTool struct{}

WriteTool 文件写入工具

func (*WriteTool) Description

func (t *WriteTool) Description() string

func (*WriteTool) Execute

func (t *WriteTool) Execute(_ context.Context, input json.RawMessage) (*tool.Result, error)

func (*WriteTool) InputSchema

func (t *WriteTool) InputSchema() map[string]any

func (*WriteTool) IsReadOnly

func (t *WriteTool) IsReadOnly() bool

func (*WriteTool) Name

func (t *WriteTool) Name() string

Jump to

Keyboard shortcuts

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