Documentation
¶
Index ¶
- func GetAllowedDir() string
- func GetWorkspaceDir() string
- func RuntimeContextFrom(ctx context.Context) (channel, chatID string)
- func RuntimeSessionKeyFrom(ctx context.Context) string
- func SetAllowedDir(dir string)
- func SetWorkspaceDir(dir string)
- func TestMCPServer(opts MCPServerOptions) (tools []string, err error)
- func ValidateParams(schema, params map[string]interface{}) error
- func WithRuntimeContext(ctx context.Context, channel, chatID string) context.Context
- func WithRuntimeContextWithSession(ctx context.Context, channel, chatID, sessionKey string) context.Context
- type BaseTool
- type BrowserTool
- type BrowserToolOptions
- type CronService
- type CronTool
- type EditFileTool
- type ExecTool
- type ListDirTool
- type MCPConnector
- type MCPServerOptions
- type MessageCallback
- type MessageTool
- type ReadFileTool
- type Registry
- func (r *Registry) Count() int
- func (r *Registry) Execute(ctx context.Context, name string, params map[string]interface{}) (string, error)
- func (r *Registry) Get(name string) (Tool, bool)
- func (r *Registry) GetDefinitions() []map[string]interface{}
- func (r *Registry) List() []string
- func (r *Registry) Register(tool Tool) error
- type SpawnCallback
- type SpawnRequest
- type SpawnResult
- type SpawnTask
- type SpawnTool
- type TelegramDirectTool
- type TelegramFileCallback
- type TelegramFileTool
- type Tool
- type ToolCall
- type WebFetchChromeOptions
- type WebFetchOptions
- type WebFetchTool
- type WebSearchTool
- type WriteFileTool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RuntimeContextFrom ¶
RuntimeContextFrom extracts channel/chat metadata from context.
func RuntimeSessionKeyFrom ¶
RuntimeSessionKeyFrom extracts session key metadata from context.
func TestMCPServer ¶
func TestMCPServer(opts MCPServerOptions) (tools []string, err error)
TestMCPServer 测试单个 MCP 服务器连接
func ValidateParams ¶
ValidateParams 验证参数
func WithRuntimeContext ¶
WithRuntimeContext injects channel/chat metadata for tools in the current request.
Types ¶
type BaseTool ¶
type BaseTool struct {
// contains filtered or unexported fields
}
BaseTool 工具基类
func (*BaseTool) Parameters ¶
Parameters 返回参数定义
func (*BaseTool) ToOpenAISchema ¶
ToOpenAISchema 转换为 OpenAI 函数格式
type BrowserTool ¶
type BrowserTool struct {
BaseTool
// contains filtered or unexported fields
}
BrowserTool provides Playwright-style browser actions via Node runner.
func NewBrowserTool ¶
func NewBrowserTool(options BrowserToolOptions) *BrowserTool
NewBrowserTool creates browser tool.
type BrowserToolOptions ¶
type BrowserToolOptions struct {
NodePath string
ScriptPath string
TimeoutSec int
Chrome WebFetchChromeOptions
}
BrowserToolOptions browser automation options.
func BrowserOptionsFromWebFetch ¶
func BrowserOptionsFromWebFetch(fetch WebFetchOptions) BrowserToolOptions
BrowserOptionsFromWebFetch derives browser tool options from web_fetch config.
type CronService ¶
type CronService interface {
AddJob(name string, schedule cron.Schedule, payload cron.Payload) (*cron.Job, error)
RemoveJob(id string) bool
ListJobs() []*cron.Job
}
CronService 定时任务服务接口
type CronTool ¶
type CronTool struct {
BaseTool
// contains filtered or unexported fields
}
CronTool 定时任务工具
func (*CronTool) SetContext ¶
SetContext 设置当前上下文
type ExecTool ¶
ExecTool Shell 执行工具
func NewExecTool ¶
NewExecTool 创建 Shell 执行工具
func (*ExecTool) Parameters ¶
Parameters 返回参数定义
type MCPConnector ¶
type MCPConnector struct {
// contains filtered or unexported fields
}
MCPConnector 负责连接 MCP 服务器并将其工具注册为本地 Tool。
func NewMCPConnector ¶
func NewMCPConnector(servers map[string]MCPServerOptions) *MCPConnector
NewMCPConnector 创建 MCP 连接器。
func (*MCPConnector) Connect ¶
func (c *MCPConnector) Connect(ctx context.Context, registry *Registry) error
Connect 连接所有 MCP 服务器,并注册它们暴露的工具。 即使部分服务器失败,其他服务器仍会继续连接。
func (*MCPConnector) RegisteredTools ¶
func (c *MCPConnector) RegisteredTools() []string
RegisteredTools 返回已经注册到本地工具注册表中的 MCP 工具名列表。
type MCPServerOptions ¶
type MCPServerOptions struct {
Name string
Command string
Args []string
Env map[string]string
URL string
Headers map[string]string
}
MCPServerOptions 是 MCP 服务器配置(兼容 Claude Desktop / Cursor 的 mcpServers 条目)。
type MessageCallback ¶
MessageCallback 消息发送回调函数类型
type MessageTool ¶
type MessageTool struct {
BaseTool
// contains filtered or unexported fields
}
MessageTool 消息发送工具
func NewMessageTool ¶
func NewMessageTool(callback MessageCallback) *MessageTool
NewMessageTool 创建消息发送工具
func (*MessageTool) SetContext ¶
func (t *MessageTool) SetContext(channel, chatID string)
SetContext 设置当前上下文
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry 工具注册表
func (*Registry) Execute ¶
func (r *Registry) Execute(ctx context.Context, name string, params map[string]interface{}) (string, error)
Execute 执行工具
func (*Registry) GetDefinitions ¶
GetDefinitions 获取所有工具定义(OpenAI 格式)
type SpawnCallback ¶
type SpawnCallback func(ctx context.Context, request SpawnRequest) (SpawnResult, error)
SpawnCallback 子代理回调函数类型
type SpawnRequest ¶
type SpawnRequest struct {
Task string
Label string
Model string
SelectedSkills []string
EnabledSources []string
SessionKey string
NotifyParent bool
Channel string
ChatID string
ParentSessionKey string
}
SpawnRequest describes a background sub-session request.
type SpawnResult ¶
type SpawnResult struct {
SessionKey string `json:"sessionKey"`
Message string `json:"message,omitempty"`
}
SpawnResult contains sub-session execution metadata returned by callback.
type SpawnTask ¶
type SpawnTask struct {
ID string
Label string
Task string
Model string
Skills []string
Sources []string
SessionKey string
StartTime time.Time
EndTime *time.Time
Status string
Result string
Error string
}
SpawnTask 表示一个正在运行的后台任务
type SpawnTool ¶
type SpawnTool struct {
BaseTool
// contains filtered or unexported fields
}
SpawnTool 子代理工具 - 用于后台任务执行
func (*SpawnTool) ListRunningTasks ¶
ListRunningTasks 列出正在运行的任务
func (*SpawnTool) SetContext ¶
SetContext 设置当前上下文
type TelegramDirectTool ¶
type TelegramDirectTool struct {
BaseTool
// contains filtered or unexported fields
}
TelegramDirectTool Telegram 直接文件发送工具 这个工具直接调用 Telegram API,不通过 channel 架构
func NewTelegramDirectTool ¶
func NewTelegramDirectTool(token, proxy string) *TelegramDirectTool
NewTelegramDirectTool 创建 Telegram 直接文件发送工具
func (*TelegramDirectTool) Execute ¶
func (t *TelegramDirectTool) Execute(ctx context.Context, params map[string]interface{}) (string, error)
Execute 执行文件发送
func (*TelegramDirectTool) SetContext ¶
func (t *TelegramDirectTool) SetContext(channel, chatID string)
SetContext 设置当前上下文
type TelegramFileCallback ¶
TelegramFileCallback Telegram 文件发送回调函数类型
type TelegramFileTool ¶
type TelegramFileTool struct {
BaseTool
// contains filtered or unexported fields
}
TelegramFileTool Telegram 文件发送工具
func NewTelegramFileTool ¶
func NewTelegramFileTool(callback TelegramFileCallback) *TelegramFileTool
NewTelegramFileTool 创建 Telegram 文件发送工具
func (*TelegramFileTool) Execute ¶
func (t *TelegramFileTool) Execute(ctx context.Context, params map[string]interface{}) (string, error)
Execute 执行文件发送
func (*TelegramFileTool) SetContext ¶
func (t *TelegramFileTool) SetContext(channel, chatID string)
SetContext 设置当前上下文
type Tool ¶
type Tool interface {
Name() string
Description() string
Parameters() map[string]interface{}
Execute(ctx context.Context, params map[string]interface{}) (string, error)
}
Tool 工具接口
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Name string `json:"name"`
Arguments map[string]interface{} `json:"arguments"`
}
ToolCall 工具调用
func ParseToolCalls ¶
ParseToolCalls 从 JSON 解析工具调用
type WebFetchChromeOptions ¶
type WebFetchChromeOptions struct {
CDPEndpoint string
ProfileName string
UserDataDir string
Channel string
Headless bool
AutoStartCDP bool
TakeoverExisting bool
HostUserDataDir string
LaunchTimeoutMs int
}
WebFetchChromeOptions Chrome 抓取选项
type WebFetchOptions ¶
type WebFetchOptions struct {
Mode string
NodePath string
ScriptPath string
TimeoutSec int
UserAgent string
WaitUntil string
RenderWaitMs int
SmartWaitMs int
StableWaitMs int
WaitForSelector string
WaitForText string
WaitForNoText string
Chrome WebFetchChromeOptions
}
WebFetchOptions 网页抓取选项
type WebFetchTool ¶
type WebFetchTool struct {
BaseTool
// contains filtered or unexported fields
}
WebFetchTool 网页抓取工具
func NewWebFetchTool ¶
func NewWebFetchTool(options WebFetchOptions) *WebFetchTool
NewWebFetchTool 创建网页抓取工具
type WebSearchTool ¶
WebSearchTool 网页搜索工具
func NewWebSearchTool ¶
func NewWebSearchTool(apiKey string, maxResults int) *WebSearchTool
NewWebSearchTool 创建网页搜索工具