Documentation
¶
Index ¶
- func BuildSubagentSystemPrompt(params *SubagentSystemPromptParams) string
- func GenerateChildSessionKey(agentID string) string
- func GenerateRunID() string
- func MarshalParams(params map[string]interface{}) (string, error)
- func ToSchema(tool Tool) map[string]interface{}
- func UnmarshalParams(data string) (map[string]interface{}, error)
- func ValidateParameters(params map[string]interface{}, schema map[string]interface{}) error
- type BaseTool
- func (t *BaseTool) Description() string
- func (t *BaseTool) Execute(ctx context.Context, params map[string]interface{}) (string, error)
- func (t *BaseTool) ExecuteWithStreaming(ctx context.Context, params map[string]interface{}, onUpdate func(ToolResult)) (ToolResult, error)
- func (t *BaseTool) Name() string
- func (t *BaseTool) Parameters() map[string]interface{}
- type BrowserCDPTool
- func (b *BrowserCDPTool) BrowserClose(ctx context.Context, params map[string]interface{}) (string, error)
- func (b *BrowserCDPTool) BrowserCreateTab(ctx context.Context, params map[string]interface{}) (string, error)
- func (b *BrowserCDPTool) BrowserEmulateDevice(ctx context.Context, params map[string]interface{}) (string, error)
- func (b *BrowserCDPTool) BrowserExtractStructuredData(ctx context.Context, params map[string]interface{}) (string, error)
- func (b *BrowserCDPTool) BrowserGetAllCookies(ctx context.Context, params map[string]interface{}) (string, error)
- func (b *BrowserCDPTool) BrowserGetMetrics(ctx context.Context, params map[string]interface{}) (string, error)
- func (b *BrowserCDPTool) BrowserPrintToPDF(ctx context.Context, params map[string]interface{}) (string, error)
- func (b *BrowserCDPTool) BrowserSetViewport(ctx context.Context, params map[string]interface{}) (string, error)
- func (b *BrowserCDPTool) GetCDPTools() []Tool
- type BrowserSessionManager
- type BrowserTool
- func (b *BrowserTool) BrowserClick(ctx context.Context, params map[string]interface{}) (string, error)
- func (b *BrowserTool) BrowserExecuteScript(ctx context.Context, params map[string]interface{}) (string, error)
- func (b *BrowserTool) BrowserFillInput(ctx context.Context, params map[string]interface{}) (string, error)
- func (b *BrowserTool) BrowserGetText(ctx context.Context, params map[string]interface{}) (string, error)
- func (b *BrowserTool) BrowserNavigate(ctx context.Context, params map[string]interface{}) (string, error)
- func (b *BrowserTool) BrowserScreenshot(ctx context.Context, params map[string]interface{}) (string, error)
- func (b *BrowserTool) Close() error
- func (b *BrowserTool) GetTools() []Tool
- type ContentBlock
- type DeliveryContext
- type FileSystemTool
- func (t *FileSystemTool) EditFile(ctx context.Context, params map[string]interface{}) (string, error)
- func (t *FileSystemTool) GetTools() []Tool
- func (t *FileSystemTool) ListDir(ctx context.Context, params map[string]interface{}) (string, error)
- func (t *FileSystemTool) ReadConfig(ctx context.Context, params map[string]interface{}) (string, error)
- func (t *FileSystemTool) ReadFile(ctx context.Context, params map[string]interface{}) (string, error)
- func (t *FileSystemTool) UpdateConfig(ctx context.Context, params map[string]interface{}) (string, error)
- func (t *FileSystemTool) WriteFile(ctx context.Context, params map[string]interface{}) (string, error)
- type ImageContent
- type MemoryAddTool
- type MemoryTool
- type MessageTool
- type Registry
- func (r *Registry) Clear()
- 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) Has(name string) bool
- func (r *Registry) List() []Tool
- func (r *Registry) Register(tool Tool) error
- func (r *Registry) Unregister(name string)
- type ShellTool
- type SmartSearch
- type SpawnTool
- type SubagentManager
- type SubagentRegistryInterface
- type SubagentRunOutcome
- type SubagentRunParams
- type SubagentSpawnResult
- type SubagentSpawnTool
- func (t *SubagentSpawnTool) Description() string
- func (t *SubagentSpawnTool) Execute(ctx context.Context, params map[string]interface{}) (string, error)
- func (t *SubagentSpawnTool) Name() string
- func (t *SubagentSpawnTool) Parameters() map[string]interface{}
- func (t *SubagentSpawnTool) SetAgentConfigGetter(getter func(agentID string) *config.AgentConfig)
- func (t *SubagentSpawnTool) SetAgentIDGetter(getter func(sessionKey string) string)
- func (t *SubagentSpawnTool) SetDefaultConfigGetter(getter func() *config.AgentDefaults)
- func (t *SubagentSpawnTool) SetOnSpawn(fn func(spawnParams *SubagentSpawnResult) error)
- type SubagentSpawnToolParams
- type SubagentSystemPromptParams
- type TextContent
- type Tool
- type ToolCall
- type ToolResult
- type ValidationError
- type WebTool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildSubagentSystemPrompt ¶
func BuildSubagentSystemPrompt(params *SubagentSystemPromptParams) string
BuildSubagentSystemPrompt 构建分身系统提示词
func GenerateChildSessionKey ¶
GenerateChildSessionKey 生成子会话密钥
func MarshalParams ¶
MarshalParams 序列化参数为 JSON
func UnmarshalParams ¶
UnmarshalParams 反序列化参数
func ValidateParameters ¶
ValidateParameters 验证参数
Types ¶
type BaseTool ¶
type BaseTool struct {
// contains filtered or unexported fields
}
BaseTool 基础工具
func NewBaseTool ¶
func NewBaseTool(name, description string, parameters map[string]interface{}, executeFunc func(ctx context.Context, params map[string]interface{}) (string, error)) *BaseTool
NewBaseTool 创建基础工具
func NewUseSkillTool ¶
func NewUseSkillTool() *BaseTool
NewUseSkillTool 创建使用技能的工具 这个工具用于让 LLM 选择要使用的技能,然后触发第二阶段的完整内容加载
func (*BaseTool) ExecuteWithStreaming ¶
func (t *BaseTool) ExecuteWithStreaming(ctx context.Context, params map[string]interface{}, onUpdate func(ToolResult)) (ToolResult, error)
ExecuteWithStreaming executes the tool with streaming support (new agent compatibility)
func (*BaseTool) Parameters ¶
Parameters 返回参数定义
type BrowserCDPTool ¶
type BrowserCDPTool struct {
*BrowserTool
}
BrowserCDPTool Enhanced browser automation tool with advanced CDP features
func NewBrowserCDPTool ¶
func NewBrowserCDPTool(headless bool, timeout int) *BrowserCDPTool
NewBrowserCDPTool Create enhanced CDP browser tool
func (*BrowserCDPTool) BrowserClose ¶
func (b *BrowserCDPTool) BrowserClose(ctx context.Context, params map[string]interface{}) (string, error)
BrowserClose Close current tab
func (*BrowserCDPTool) BrowserCreateTab ¶
func (b *BrowserCDPTool) BrowserCreateTab(ctx context.Context, params map[string]interface{}) (string, error)
BrowserCreateTab Create a new tab
func (*BrowserCDPTool) BrowserEmulateDevice ¶
func (b *BrowserCDPTool) BrowserEmulateDevice(ctx context.Context, params map[string]interface{}) (string, error)
BrowserEmulateDevice Emulate a specific device (mobile, tablet, desktop)
func (*BrowserCDPTool) BrowserExtractStructuredData ¶
func (b *BrowserCDPTool) BrowserExtractStructuredData(ctx context.Context, params map[string]interface{}) (string, error)
BrowserExtractStructuredData Extract structured data from page using schema.org, JSON-LD, or custom selectors
func (*BrowserCDPTool) BrowserGetAllCookies ¶
func (b *BrowserCDPTool) BrowserGetAllCookies(ctx context.Context, params map[string]interface{}) (string, error)
BrowserGetAllCookies Get all cookies for the current page
func (*BrowserCDPTool) BrowserGetMetrics ¶
func (b *BrowserCDPTool) BrowserGetMetrics(ctx context.Context, params map[string]interface{}) (string, error)
BrowserGetMetrics Get performance metrics for the current page
func (*BrowserCDPTool) BrowserPrintToPDF ¶
func (b *BrowserCDPTool) BrowserPrintToPDF(ctx context.Context, params map[string]interface{}) (string, error)
BrowserPrintToPDF Generate PDF of current page
func (*BrowserCDPTool) BrowserSetViewport ¶
func (b *BrowserCDPTool) BrowserSetViewport(ctx context.Context, params map[string]interface{}) (string, error)
BrowserSetViewport Set custom viewport size
func (*BrowserCDPTool) GetCDPTools ¶
func (b *BrowserCDPTool) GetCDPTools() []Tool
GetCDPTools Get all CDP-enhanced browser tools
type BrowserSessionManager ¶
type BrowserSessionManager struct {
// contains filtered or unexported fields
}
BrowserSessionManager 浏览器会话管理器 (使用 Chrome DevTools Protocol)
func GetBrowserSession ¶
func GetBrowserSession() *BrowserSessionManager
GetBrowserSession 获取浏览器会话管理器(单例)
func (*BrowserSessionManager) GetClient ¶
func (b *BrowserSessionManager) GetClient() (*cdp.Client, error)
GetClient 获取 CDP 客户端
func (*BrowserSessionManager) IsReady ¶
func (b *BrowserSessionManager) IsReady() bool
IsReady 检查会话是否就绪
type BrowserTool ¶
type BrowserTool struct {
// contains filtered or unexported fields
}
BrowserTool Browser tool using Chrome DevTools Protocol
func NewBrowserTool ¶
func NewBrowserTool(headless bool, timeout int) *BrowserTool
NewBrowserTool Create browser tool
func (*BrowserTool) BrowserClick ¶
func (b *BrowserTool) BrowserClick(ctx context.Context, params map[string]interface{}) (string, error)
BrowserClick Click element on page
func (*BrowserTool) BrowserExecuteScript ¶
func (b *BrowserTool) BrowserExecuteScript(ctx context.Context, params map[string]interface{}) (string, error)
BrowserExecuteScript Execute JavaScript in browser
func (*BrowserTool) BrowserFillInput ¶
func (b *BrowserTool) BrowserFillInput(ctx context.Context, params map[string]interface{}) (string, error)
BrowserFillInput Fill input field
func (*BrowserTool) BrowserGetText ¶
func (b *BrowserTool) BrowserGetText(ctx context.Context, params map[string]interface{}) (string, error)
BrowserGetText Get page text content
func (*BrowserTool) BrowserNavigate ¶
func (b *BrowserTool) BrowserNavigate(ctx context.Context, params map[string]interface{}) (string, error)
BrowserNavigate Navigate browser to URL
func (*BrowserTool) BrowserScreenshot ¶
func (b *BrowserTool) BrowserScreenshot(ctx context.Context, params map[string]interface{}) (string, error)
BrowserScreenshot Take screenshot of page
func (*BrowserTool) Close ¶
func (b *BrowserTool) Close() error
Close Close browser tool and cleanup resources
func (*BrowserTool) GetTools ¶
func (b *BrowserTool) GetTools() []Tool
GetTools Get all browser tools
type ContentBlock ¶
type ContentBlock interface {
ContentType() string
}
ContentBlock represents a block of content in a message
type DeliveryContext ¶
type DeliveryContext struct {
Channel string `json:"channel,omitempty"`
AccountID string `json:"account_id,omitempty"`
To string `json:"to,omitempty"`
ThreadID string `json:"thread_id,omitempty"`
}
DeliveryContext 传递上下文
type FileSystemTool ¶
type FileSystemTool struct {
// contains filtered or unexported fields
}
FileSystemTool 文件系统工具
func NewFileSystemTool ¶
func NewFileSystemTool(allowedPaths, deniedPaths []string, workspace string) *FileSystemTool
NewFileSystemTool 创建文件系统工具
func (*FileSystemTool) EditFile ¶
func (t *FileSystemTool) EditFile(ctx context.Context, params map[string]interface{}) (string, error)
EditFile 编辑文件(精确字符串替换)
func (*FileSystemTool) ListDir ¶
func (t *FileSystemTool) ListDir(ctx context.Context, params map[string]interface{}) (string, error)
ListDir 列出目录
func (*FileSystemTool) ReadConfig ¶
func (t *FileSystemTool) ReadConfig(ctx context.Context, params map[string]interface{}) (string, error)
ReadConfig 读取配置文件
func (*FileSystemTool) ReadFile ¶
func (t *FileSystemTool) ReadFile(ctx context.Context, params map[string]interface{}) (string, error)
ReadFile 读取文件
func (*FileSystemTool) UpdateConfig ¶
func (t *FileSystemTool) UpdateConfig(ctx context.Context, params map[string]interface{}) (string, error)
UpdateConfig 更新配置文件
type ImageContent ¶
type ImageContent struct {
URL string `json:"url,omitempty"`
Data string `json:"data,omitempty"` // base64
MimeType string `json:"mimeType,omitempty"`
}
ImageContent represents image content
func (ImageContent) ContentType ¶
func (i ImageContent) ContentType() string
type MemoryAddTool ¶
type MemoryAddTool struct {
// contains filtered or unexported fields
}
MemoryAddTool memory 添加工具
func NewMemoryAddTool ¶
func NewMemoryAddTool(searchManager memory.MemorySearchManager) *MemoryAddTool
NewMemoryAddTool 创建 memory 添加工具
func (*MemoryAddTool) Parameters ¶
func (t *MemoryAddTool) Parameters() map[string]interface{}
Parameters 返回参数定义
type MemoryTool ¶
type MemoryTool struct {
// contains filtered or unexported fields
}
MemoryTool memory 搜索工具
func NewMemoryTool ¶
func NewMemoryTool(searchManager memory.MemorySearchManager) *MemoryTool
NewMemoryTool 创建 memory 搜索工具
func (*MemoryTool) Parameters ¶
func (t *MemoryTool) Parameters() map[string]interface{}
Parameters 返回参数定义
type MessageTool ¶
type MessageTool struct {
// contains filtered or unexported fields
}
MessageTool 消息工具
func (*MessageTool) SendMessage ¶
func (t *MessageTool) SendMessage(ctx context.Context, params map[string]interface{}) (string, error)
SendMessage 发送消息
func (*MessageTool) SetCurrent ¶
func (t *MessageTool) SetCurrent(channel, chatID string)
SetCurrent 设置当前通道和聊天
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 ShellTool ¶
type ShellTool struct {
// contains filtered or unexported fields
}
ShellTool Shell 工具
func NewShellTool ¶
func NewShellTool( enabled bool, allowedCmds, deniedCmds []string, timeout int, workingDir string, sandboxConfig config.SandboxConfig, ) *ShellTool
NewShellTool 创建 Shell 工具
type SmartSearch ¶
type SmartSearch struct {
// contains filtered or unexported fields
}
SmartSearch Smart search tool supporting web search and browser fallback
func NewSmartSearch ¶
func NewSmartSearch(webTool *WebTool, webEnabled bool, timeout int) *SmartSearch
NewSmartSearch Create smart search tool
func (*SmartSearch) SmartSearchResult ¶
func (s *SmartSearch) SmartSearchResult(ctx context.Context, params map[string]interface{}) (string, error)
SmartSearchResult Smart search
type SpawnTool ¶
type SpawnTool struct {
// contains filtered or unexported fields
}
SpawnTool 子代理工具
func (*SpawnTool) SetCurrent ¶
SetCurrent 设置当前通道和聊天
type SubagentManager ¶
type SubagentManager interface {
Spawn(ctx context.Context, task, label, originChannel, originChatID string) (string, error)
}
SubagentManager 子代理管理器接口(避免循环导入)
type SubagentRegistryInterface ¶
type SubagentRegistryInterface interface {
RegisterRun(params *SubagentRunParams) error
}
SubagentRegistryInterface 分身注册表接口
type SubagentRunOutcome ¶
type SubagentRunOutcome struct {
Status string `json:"status"` // ok, error, timeout, unknown
Error string `json:"error,omitempty"`
}
SubagentRunOutcome 分身运行结果
type SubagentRunParams ¶
type SubagentRunParams struct {
RunID string
ChildSessionKey string
RequesterSessionKey string
RequesterOrigin *DeliveryContext
RequesterDisplayKey string
Task string
Cleanup string
Label string
ArchiveAfterMinutes int
}
SubagentRunParams 分身运行参数
type SubagentSpawnResult ¶
type SubagentSpawnResult struct {
Status string `json:"status"` // accepted, forbidden, error
ChildSessionKey string `json:"child_session_key,omitempty"`
RunID string `json:"run_id,omitempty"`
Error string `json:"error,omitempty"`
ModelApplied bool `json:"model_applied,omitempty"`
Warning string `json:"warning,omitempty"`
}
SubagentSpawnResult 分身生成结果
type SubagentSpawnTool ¶
type SubagentSpawnTool struct {
// contains filtered or unexported fields
}
SubagentSpawnTool 分身生成工具
func NewSubagentSpawnTool ¶
func NewSubagentSpawnTool(registry SubagentRegistryInterface) *SubagentSpawnTool
NewSubagentSpawnTool 创建分身生成工具
func (*SubagentSpawnTool) Description ¶
func (t *SubagentSpawnTool) Description() string
Description 返回工具描述
func (*SubagentSpawnTool) Execute ¶
func (t *SubagentSpawnTool) Execute(ctx context.Context, params map[string]interface{}) (string, error)
Execute 执行工具
func (*SubagentSpawnTool) Parameters ¶
func (t *SubagentSpawnTool) Parameters() map[string]interface{}
Parameters 返回工具参数定义
func (*SubagentSpawnTool) SetAgentConfigGetter ¶
func (t *SubagentSpawnTool) SetAgentConfigGetter(getter func(agentID string) *config.AgentConfig)
SetAgentConfigGetter 设置 Agent 配置获取器
func (*SubagentSpawnTool) SetAgentIDGetter ¶
func (t *SubagentSpawnTool) SetAgentIDGetter(getter func(sessionKey string) string)
SetAgentIDGetter 设置 Agent ID 获取器
func (*SubagentSpawnTool) SetDefaultConfigGetter ¶
func (t *SubagentSpawnTool) SetDefaultConfigGetter(getter func() *config.AgentDefaults)
SetDefaultConfigGetter 设置默认配置获取器
func (*SubagentSpawnTool) SetOnSpawn ¶
func (t *SubagentSpawnTool) SetOnSpawn(fn func(spawnParams *SubagentSpawnResult) error)
SetOnSpawn 设置分身生成回调
type SubagentSpawnToolParams ¶
type SubagentSpawnToolParams struct {
Task string `json:"task"` // 任务描述(必填)
Label string `json:"label,omitempty"` // 可选标签
AgentID string `json:"agent_id,omitempty"` // 目标 Agent ID
Model string `json:"model,omitempty"` // 模型覆盖
Thinking string `json:"thinking,omitempty"` // 思考级别
RunTimeoutSeconds int `json:"run_timeout_seconds,omitempty"` // 超时时间
Cleanup string `json:"cleanup,omitempty"` // 清理策略
}
SubagentSpawnToolParams 分身生成工具参数
type SubagentSystemPromptParams ¶
type SubagentSystemPromptParams struct {
RequesterSessionKey string
RequesterOrigin *DeliveryContext
ChildSessionKey string
Label string
Task string
}
SubagentSystemPromptParams 系统提示词参数
type TextContent ¶
type TextContent struct {
Text string `json:"text"`
}
TextContent represents text content
func (TextContent) ContentType ¶
func (t TextContent) ContentType() string
type Tool ¶
type Tool interface {
// Name 工具名称
Name() string
// Description 工具描述
Description() string
// Parameters JSON Schema 参数定义
Parameters() map[string]interface{}
// Execute 执行工具
Execute(ctx context.Context, params map[string]interface{}) (string, error)
}
Tool 工具接口
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Name string `json:"name"`
Params map[string]interface{} `json:"params"`
Response string `json:"response,omitempty"`
Error string `json:"error,omitempty"`
}
ToolCall 工具调用
type ToolResult ¶
type ToolResult struct {
Content []ContentBlock `json:"content"`
Details map[string]any `json:"details"`
Error error `json:"error,omitempty"`
}
ToolResult represents the result of a tool execution
type ValidationError ¶
ValidationError 参数验证错误
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string