Documentation
¶
Index ¶
- Variables
- func AgentActorGetStatus(pid *actor.PID, timeout time.Duration) (*types.AgentStatus, error)
- func AgentActorTell(pid *actor.PID, msg actor.Message)
- func FormatStats(stats *PromptStats) string
- func RegisterAllPresets(registry *TemplateRegistry)
- func RegisterPreset(registry *TemplateRegistry, preset *PromptTemplatePreset)
- func StreamCollect(reader *stream.Reader[*session.Event]) ([]*session.Event, error)
- func StreamFilter(reader *stream.Reader[*session.Event], predicate func(*session.Event) bool) *stream.Reader[*session.Event]
- func StreamFirst(reader *stream.Reader[*session.Event]) (*session.Event, error)
- func StreamLast(reader *stream.Reader[*session.Event]) (*session.Event, error)
- type Agent
- func (a *Agent) Chat(ctx context.Context, text string) (*types.CompleteResult, error)
- func (a *Agent) ChatWithContent(ctx context.Context, blocks []types.ContentBlock) (*types.CompleteResult, error)
- func (a *Agent) Close() error
- func (a *Agent) ControlTool(callID, action, note string) error
- func (a *Agent) EnterPlanMode(planID, planFilePath, reason string)
- func (a *Agent) ExecuteToolDirect(ctx context.Context, toolName string, input map[string]any) (any, error)
- func (a *Agent) ExecuteToolsDirect(ctx context.Context, calls []ToolCall) []ToolCallResult
- func (a *Agent) ExecutionPlan() *ExecutionPlanManager
- func (a *Agent) ExitPlanMode()
- func (a *Agent) GetEventBus() *events.EventBus
- func (a *Agent) GetIterationCount() int
- func (a *Agent) GetPermissionMode() permission.Mode
- func (a *Agent) GetPlanModeState() *PlanModeState
- func (a *Agent) GetSessionState(ctx context.Context) *types.SessionState
- func (a *Agent) GetSystemPrompt() string
- func (a *Agent) GetToolSnapshot(callID string) types.ToolCallSnapshot
- func (a *Agent) GetWorkDir() string
- func (a *Agent) HasPendingPermission(callID string) bool
- func (a *Agent) ID() string
- func (a *Agent) IsInPlanMode() bool
- func (a *Agent) IsResumedSession() bool
- func (a *Agent) ListRunningToolSnapshots() []types.ToolCallSnapshot
- func (a *Agent) ProcessRecovery(ctx context.Context, message string, workDir string, metadata map[string]any) (string, bool)
- func (a *Agent) RespondToIterationLimit(continueExecution bool)
- func (a *Agent) RespondToPermissionRequest(callID string, approved bool) error
- func (a *Agent) Send(ctx context.Context, text string) error
- func (a *Agent) SendWithContent(ctx context.Context, blocks []types.ContentBlock) error
- func (a *Agent) SetMaxIterations(max int)
- func (a *Agent) SetPermissionMode(mode permission.Mode)
- func (a *Agent) Status() *types.AgentStatus
- func (a *Agent) Stream(ctx context.Context, message string, opts ...Option) *stream.Reader[*session.Event]
- func (a *Agent) Subscribe(channels []types.AgentChannel, opts *types.SubscribeOptions) <-chan types.AgentEventEnvelope
- func (a *Agent) Unsubscribe(ch <-chan types.AgentEventEnvelope)
- type AgentActor
- type AgentActorFactory
- type AgentActorStats
- type AvoidOverEngineeringModule
- type BasePromptModule
- type BatchToolCallMsg
- type BatchToolResultMsg
- type CapabilitiesModule
- type ChatMsg
- type ChatResultMsg
- type CodeReferenceModule
- type CollaborationModule
- type CompressOptions
- type CompressResult
- type CompressionLevel
- type CompressionMode
- type ConcisenessModule
- type ContextWindowModule
- type CustomInstructionsModule
- type Dependencies
- type DirectToolCallMsg
- type DirectToolResultMsg
- type EnhancedPromptCompressor
- type EnvironmentInfo
- type EnvironmentModule
- type ErrorMsg
- type ExecutionPlanConfig
- type ExecutionPlanManager
- func (m *ExecutionPlanManager) ApprovePlan(approvedBy string) error
- func (m *ExecutionPlanManager) CancelPlan(reason string)
- func (m *ExecutionPlanManager) ClearPlan()
- func (m *ExecutionPlanManager) ExecutePlan(ctx context.Context) error
- func (m *ExecutionPlanManager) ExecutePlanDirect(ctx context.Context, plan *executionplan.ExecutionPlan) error
- func (m *ExecutionPlanManager) FormatCurrentPlan() string
- func (m *ExecutionPlanManager) GeneratePlan(ctx context.Context, request string, opts *ExecutionPlanConfig) (*executionplan.ExecutionPlan, error)
- func (m *ExecutionPlanManager) GetCurrentPlan() *executionplan.ExecutionPlan
- func (m *ExecutionPlanManager) GetPlanSummary() *executionplan.PlanSummary
- func (m *ExecutionPlanManager) RejectPlan(reason string) error
- func (m *ExecutionPlanManager) ResumePlan(ctx context.Context) error
- func (m *ExecutionPlanManager) SetCallbacks(onGenerated func(*executionplan.ExecutionPlan), ...)
- func (m *ExecutionPlanManager) ValidateCurrentPlan() []error
- type FallbackStats
- type GetStatusMsg
- type GitRepoInfo
- type GitSafetyModule
- type LLMPromptCompressor
- func (c *LLMPromptCompressor) Compress(ctx context.Context, prompt string, targetLength int, ...) (string, error)
- func (c *LLMPromptCompressor) CompressSection(ctx context.Context, section string, targetLength int) (string, error)
- func (c *LLMPromptCompressor) EstimateCompressionRatio(level int) float64
- type LimitationsModule
- type ModelFallback
- type ModelFallbackManager
- func (m *ModelFallbackManager) Complete(ctx context.Context, messages []types.Message, opts *provider.StreamOptions) (*provider.CompleteResponse, error)
- func (m *ModelFallbackManager) DisableModel(provider, model string) error
- func (m *ModelFallbackManager) EnableModel(provider, model string) error
- func (m *ModelFallbackManager) GetCurrentProvider() provider.Provider
- func (m *ModelFallbackManager) GetStats() *FallbackStats
- func (m *ModelFallbackManager) ListModels() []map[string]any
- func (m *ModelFallbackManager) ResetStats()
- func (m *ModelFallbackManager) Stream(ctx context.Context, messages []types.Message, opts *provider.StreamOptions) (<-chan provider.StreamChunk, error)
- type Option
- type PerformanceModule
- type PlanConstraints
- type PlanModeManager
- func (m *PlanModeManager) EnterPlanMode(planID, planFilePath, reason string)
- func (m *PlanModeManager) ExitPlanMode()
- func (m *PlanModeManager) GetState() *PlanModeState
- func (m *PlanModeManager) IsActive() bool
- func (m *PlanModeManager) ValidateToolCall(toolName string, input map[string]any) (bool, string)
- type PlanModeState
- type PlanningWithoutTimelinesModule
- type ProfessionalObjectivityModule
- type PromptBuilder
- type PromptCompressor
- type PromptContext
- type PromptModule
- type PromptOptimizer
- type PromptStats
- type PromptTemplatePreset
- type RemoteAgent
- func (r *RemoteAgent) Chat(ctx context.Context, text string) (*types.CompleteResult, error)
- func (r *RemoteAgent) Close() error
- func (r *RemoteAgent) ExecuteToolDirect(ctx context.Context, toolName string, input map[string]any) (any, error)
- func (r *RemoteAgent) GetEventBus() *events.EventBus
- func (r *RemoteAgent) GetIterationCount() int
- func (r *RemoteAgent) GetMetadata() map[string]any
- func (r *RemoteAgent) GetPermissionMode() permission.Mode
- func (r *RemoteAgent) GetSystemPrompt() string
- func (r *RemoteAgent) HasPendingPermission(callID string) bool
- func (r *RemoteAgent) ID() string
- func (r *RemoteAgent) PushEvent(envelope types.AgentEventEnvelope) error
- func (r *RemoteAgent) RespondToIterationLimit(continueExecution bool)
- func (r *RemoteAgent) RespondToPermissionRequest(callID string, approved bool) error
- func (r *RemoteAgent) Send(ctx context.Context, text string) error
- func (r *RemoteAgent) SetMaxIterations(max int)
- func (r *RemoteAgent) SetMetadata(key string, value any)
- func (r *RemoteAgent) SetPermissionMode(mode permission.Mode)
- func (r *RemoteAgent) Status() *types.AgentStatus
- func (r *RemoteAgent) Subscribe(channels []types.AgentChannel, opts *types.SubscribeOptions) <-chan types.AgentEventEnvelope
- func (r *RemoteAgent) Unsubscribe(ch <-chan types.AgentEventEnvelope)
- type RoomCollaborationInfo
- type SandboxInfo
- type SandboxModule
- type ScoredSection
- type SecurityModule
- type SendMsg
- type StopMsg
- type StreamEventMsg
- type StreamMsg
- type StreamingAgent
- type SubAgentExecutorImpl
- type SubAgentExecutorWrapper
- type SubAgentHandle
- type SubAgentManager
- func (m *SubAgentManager) Cancel(taskID string) error
- func (m *SubAgentManager) Execute(ctx context.Context, req *types.SubAgentRequest) (*types.SubAgentResult, error)
- func (m *SubAgentManager) ExecuteAsync(ctx context.Context, req *types.SubAgentRequest) (string, <-chan *types.SubAgentProgressEvent, error)
- func (m *SubAgentManager) GetSpec(name string) (*types.SubAgentSpec, error)
- func (m *SubAgentManager) GetStatus(taskID string) (*SubAgentHandle, error)
- func (m *SubAgentManager) ListRunning() []*SubAgentHandle
- func (m *SubAgentManager) ListSpecs() []*types.SubAgentSpec
- func (m *SubAgentManager) RegisterSpec(spec *types.SubAgentSpec)
- type SubAgentManagerFactory
- type TemplateNotFoundError
- type TemplateRegistry
- type TodoReminderModule
- type ToolCall
- type ToolCallDeniedError
- type ToolCallMsg
- type ToolCallResult
- type ToolManager
- func (tm *ToolManager) ActivateTool(name string) error
- func (tm *ToolManager) ActivateTools(names []string) (activated []string, failed map[string]error)
- func (tm *ToolManager) AddTool(tool tools.Tool, source string, deferred bool) error
- func (tm *ToolManager) AddToolEntry(entry search.ToolIndexEntry) error
- func (tm *ToolManager) DeactivateTool(name string) error
- func (tm *ToolManager) GetActiveTool(name string) (tools.Tool, bool)
- func (tm *ToolManager) GetActiveTools() map[string]tools.Tool
- func (tm *ToolManager) GetIndex() *search.ToolIndex
- func (tm *ToolManager) Initialize(toolNames []string, activeByDefault bool) error
- func (tm *ToolManager) IsCoreTool(name string) bool
- func (tm *ToolManager) RemoveTool(name string) error
- func (tm *ToolManager) SearchTools(query string, topK int) []search.ToolSearchResult
- func (tm *ToolManager) Stats() map[string]any
- type ToolResultMsg
- type ToolsManualModule
- type WorkflowContextInfo
- type WorkflowModule
Constants ¶
This section is empty.
Variables ¶
var ( // CodeAssistantPreset 代码助手预设 CodeAssistantPreset = &PromptTemplatePreset{ ID: "code-assistant", Name: "Code Assistant", Description: "Professional code assistant for software development tasks", Template: &types.AgentTemplateDefinition{ ID: "code-assistant", SystemPrompt: `You are a professional code assistant. Your role is to help users with software development tasks including: - Writing, reviewing, and refactoring code - Debugging and fixing issues - Explaining code and technical concepts - Suggesting best practices and optimizations - Helping with architecture and design decisions Always provide clear, well-documented code with proper error handling.`, Tools: []any{"Read", "Write", "Bash", "TodoWrite"}, Runtime: &types.AgentTemplateRuntime{ Todo: &types.TodoConfig{ Enabled: true, ReminderOnStart: true, }, }, }, Modules: []string{ "base", "capabilities", "environment", "sandbox", "tools_manual", "todo_reminder", "code_reference", }, } // ResearchAssistantPreset 研究助手预设 ResearchAssistantPreset = &PromptTemplatePreset{ ID: "research-assistant", Name: "Research Assistant", Description: "Research assistant for gathering and analyzing information", Template: &types.AgentTemplateDefinition{ ID: "research-assistant", SystemPrompt: `You are a research assistant. Your role is to help users: - Gather information from various sources - Analyze and synthesize findings - Provide well-researched answers - Cite sources and verify facts - Organize research materials Always be thorough, accurate, and cite your sources when possible.`, Tools: []any{"Read", "WebSearch", "TodoWrite"}, Runtime: &types.AgentTemplateRuntime{ Todo: &types.TodoConfig{ Enabled: true, ReminderOnStart: true, }, }, }, Modules: []string{ "base", "capabilities", "environment", "tools_manual", "todo_reminder", }, } // DataAnalystPreset 数据分析师预设 DataAnalystPreset = &PromptTemplatePreset{ ID: "data-analyst", Name: "Data Analyst", Description: "Data analyst for analyzing and visualizing data", Template: &types.AgentTemplateDefinition{ ID: "data-analyst", SystemPrompt: `You are a data analyst. Your role is to help users: - Analyze datasets and identify patterns - Create visualizations and reports - Perform statistical analysis - Clean and transform data - Provide data-driven insights Always explain your methodology and validate your findings.`, Tools: []any{"Read", "Write", "Bash"}, Runtime: &types.AgentTemplateRuntime{ Todo: &types.TodoConfig{ Enabled: true, ReminderOnStart: true, }, }, }, Modules: []string{ "base", "capabilities", "environment", "sandbox", "tools_manual", "todo_reminder", "performance", }, } // DevOpsEngineerPreset DevOps 工程师预设 DevOpsEngineerPreset = &PromptTemplatePreset{ ID: "devops-engineer", Name: "DevOps Engineer", Description: "DevOps engineer for infrastructure and deployment tasks", Template: &types.AgentTemplateDefinition{ ID: "devops-engineer", SystemPrompt: `You are a DevOps engineer. Your role is to help users: - Manage infrastructure and deployments - Write and optimize CI/CD pipelines - Configure and troubleshoot systems - Implement monitoring and logging - Ensure security and compliance Always follow best practices for security, reliability, and scalability.`, Tools: []any{"Read", "Write", "Bash"}, Runtime: &types.AgentTemplateRuntime{ Todo: &types.TodoConfig{ Enabled: true, ReminderOnStart: true, }, }, }, Modules: []string{ "base", "capabilities", "environment", "sandbox", "tools_manual", "todo_reminder", "security", }, } // TechnicalWriterPreset 技术文档编写者预设 TechnicalWriterPreset = &PromptTemplatePreset{ ID: "technical-writer", Name: "Technical Writer", Description: "Technical writer for creating documentation", Template: &types.AgentTemplateDefinition{ ID: "technical-writer", SystemPrompt: `You are a technical writer. Your role is to help users: - Write clear and comprehensive documentation - Create tutorials and guides - Document APIs and code - Maintain documentation consistency - Make technical content accessible Always write in clear, concise language appropriate for the target audience.`, Tools: []any{"Read", "Write"}, Runtime: &types.AgentTemplateRuntime{ Todo: &types.TodoConfig{ Enabled: true, ReminderOnStart: true, }, }, }, Modules: []string{ "base", "capabilities", "environment", "tools_manual", "todo_reminder", "code_reference", }, } // ProjectManagerPreset 项目经理预设 ProjectManagerPreset = &PromptTemplatePreset{ ID: "project-manager", Name: "Project Manager", Description: "Project manager for planning and coordinating tasks", Template: &types.AgentTemplateDefinition{ ID: "project-manager", SystemPrompt: `You are a project manager. Your role is to help users: - Plan and organize projects - Break down complex tasks - Track progress and milestones - Coordinate team activities - Identify risks and dependencies Always maintain clear communication and keep tasks well-organized.`, Tools: []any{"TodoWrite", "Read", "Write"}, Runtime: &types.AgentTemplateRuntime{ Todo: &types.TodoConfig{ Enabled: true, ReminderOnStart: true, RemindIntervalSteps: 3, }, }, }, Modules: []string{ "base", "capabilities", "environment", "tools_manual", "todo_reminder", }, } // SecurityAuditorPreset 安全审计员预设 SecurityAuditorPreset = &PromptTemplatePreset{ ID: "security-auditor", Name: "Security Auditor", Description: "Security auditor for code and system security review", Template: &types.AgentTemplateDefinition{ ID: "security-auditor", SystemPrompt: `You are a security auditor. Your role is to help users: - Review code for security vulnerabilities - Identify potential security risks - Suggest security improvements - Check for compliance with security standards - Perform security assessments Always prioritize security and follow the principle of least privilege.`, Tools: []any{"Read", "Write"}, Runtime: &types.AgentTemplateRuntime{ Todo: &types.TodoConfig{ Enabled: true, ReminderOnStart: true, }, }, }, Modules: []string{ "base", "capabilities", "environment", "tools_manual", "todo_reminder", "security", "code_reference", }, } // GeneralAssistantPreset 通用助手预设 GeneralAssistantPreset = &PromptTemplatePreset{ ID: "general-assistant", Name: "General Assistant", Description: "General-purpose assistant for various tasks", Template: &types.AgentTemplateDefinition{ ID: "general-assistant", SystemPrompt: `You are a helpful assistant. Help users with their tasks efficiently and accurately.`, Tools: []any{"Read", "Write", "TodoWrite"}, Runtime: &types.AgentTemplateRuntime{ Todo: &types.TodoConfig{ Enabled: true, ReminderOnStart: false, }, }, }, Modules: []string{ "base", "environment", "tools_manual", }, } // ExploreAgentPreset 代码探索 Agent 预设 ExploreAgentPreset = &PromptTemplatePreset{ ID: "explore", Name: "Explore Agent", Description: "Fast agent for codebase exploration and analysis", Template: &types.AgentTemplateDefinition{ ID: "explore", SystemPrompt: `You are an exploration agent specialized for codebase analysis. ## Your Capabilities 1. Search for files by patterns (Glob) 2. Search code for keywords (Grep) 3. Read and analyze files (Read) 4. Fetch web documentation (WebFetch, WebSearch) ## Thoroughness Levels When called, you may receive a thoroughness parameter: - quick: Single location search, basic pattern matching - medium: Multiple locations, related files exploration - very_thorough: Comprehensive analysis across all naming conventions ## Output Format Return findings with: - File paths and line numbers (e.g., pkg/agent/agent.go:156) - Code snippets when relevant - Summary of findings - Key insights and patterns discovered ## Guidelines - Focus on exploration, not implementation - Be thorough but efficient - Report both findings and non-findings - Suggest areas for further investigation`, Tools: []any{"Read", "Glob", "Grep", "WebFetch", "WebSearch"}, Runtime: &types.AgentTemplateRuntime{ Todo: &types.TodoConfig{ Enabled: false, ReminderOnStart: false, }, }, }, Modules: []string{ "base", "environment", "code_reference", }, } // PlanAgentPreset 规划 Agent 预设 PlanAgentPreset = &PromptTemplatePreset{ ID: "plan", Name: "Plan Agent", Description: "Agent for detailed implementation planning and design", Template: &types.AgentTemplateDefinition{ ID: "plan", SystemPrompt: `You are a planning agent specialized for implementation design. ## Your Role 1. Analyze requirements and constraints 2. Design implementation approaches 3. Identify risks and dependencies 4. Create actionable implementation steps ## Planning Process 1. Understand the goal thoroughly 2. Explore existing patterns in codebase 3. Identify affected files and components 4. Design the solution architecture 5. Break down into implementation steps ## Output Format Return a detailed plan with: - Recommended approach with rationale - Critical files to modify (with paths and line numbers) - Implementation steps (ordered) - Potential risks and mitigations - Success criteria and testing strategy ## Guidelines - Ask clarifying questions when needed - Consider multiple approaches before recommending - Be specific about file changes required - Include rollback considerations - Focus on maintainability and simplicity`, Tools: []any{"Read", "Glob", "Grep", "WebFetch", "WebSearch", "AskUserQuestion"}, Runtime: &types.AgentTemplateRuntime{ Todo: &types.TodoConfig{ Enabled: true, ReminderOnStart: true, }, }, }, Modules: []string{ "base", "environment", "tools_manual", "todo_reminder", "code_reference", }, } )
预定义的 Prompt 模板
var AllPresets = []*PromptTemplatePreset{ CodeAssistantPreset, ResearchAssistantPreset, DataAnalystPreset, DevOpsEngineerPreset, TechnicalWriterPreset, ProjectManagerPreset, SecurityAuditorPreset, GeneralAssistantPreset, ExploreAgentPreset, PlanAgentPreset, }
AllPresets 所有预设模板
Functions ¶
func AgentActorGetStatus ¶ added in v0.19.0
AgentActorGetStatus 获取 Agent 状态
func AgentActorTell ¶ added in v0.19.0
AgentActorTell 向 Agent Actor 发送消息(不等待响应)
func RegisterAllPresets ¶ added in v0.17.0
func RegisterAllPresets(registry *TemplateRegistry)
RegisterAllPresets 注册所有预设到模板注册表
func RegisterPreset ¶ added in v0.17.0
func RegisterPreset(registry *TemplateRegistry, preset *PromptTemplatePreset)
RegisterPreset 注册预设到模板注册表
func StreamCollect ¶
StreamCollect 辅助函数 - 收集所有事件 用于向后兼容,将流式接口转换为批量结果
使用示例:
events, err := StreamCollect(agent.Stream(ctx, "Hello"))
if err != nil {
return err
}
for _, event := range events {
fmt.Println(event)
}
func StreamFilter ¶
func StreamFilter(reader *stream.Reader[*session.Event], predicate func(*session.Event) bool) *stream.Reader[*session.Event]
StreamFilter 辅助函数 - 过滤事件
func StreamFirst ¶
StreamFirst 辅助函数 - 获取第一个事件
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent AI代理
func Create ¶
func Create(ctx context.Context, config *types.AgentConfig, deps *Dependencies) (*Agent, error)
Create 创建新Agent
func (*Agent) ChatWithContent ¶ added in v0.34.0
func (a *Agent) ChatWithContent(ctx context.Context, blocks []types.ContentBlock) (*types.CompleteResult, error)
ChatWithContent 同步对话(阻塞式),支持多模态内容
func (*Agent) ControlTool ¶ added in v0.16.0
ControlTool 执行对运行中工具的控制
func (*Agent) EnterPlanMode ¶ added in v0.25.0
EnterPlanMode 让 Agent 进入 Plan 模式
func (*Agent) ExecuteToolDirect ¶ added in v0.17.0
func (a *Agent) ExecuteToolDirect(ctx context.Context, toolName string, input map[string]any) (any, error)
ExecuteToolDirect 直接执行工具(程序化工具调用) 这个方法允许 Agent 或外部代码直接调用工具,绕过 LLM 决策 主要用于程序化工具编排场景
func (*Agent) ExecuteToolsDirect ¶ added in v0.17.0
func (a *Agent) ExecuteToolsDirect(ctx context.Context, calls []ToolCall) []ToolCallResult
ExecuteToolsDirect 批量直接执行工具(顺序执行)
func (*Agent) ExecutionPlan ¶ added in v0.31.0
func (a *Agent) ExecutionPlan() *ExecutionPlanManager
ExecutionPlan 返回执行计划管理器 首次调用时延迟初始化
func (*Agent) ExitPlanMode ¶ added in v0.25.0
func (a *Agent) ExitPlanMode()
ExitPlanMode 让 Agent 退出 Plan 模式
func (*Agent) GetEventBus ¶ added in v0.32.0
GetEventBus 获取 EventBus(用于 Dashboard 聚合)
func (*Agent) GetIterationCount ¶ added in v0.31.0
GetIterationCount 获取当前迭代次数
func (*Agent) GetPermissionMode ¶ added in v0.31.0
func (a *Agent) GetPermissionMode() permission.Mode
GetPermissionMode 获取当前权限模式
func (*Agent) GetPlanModeState ¶ added in v0.25.0
func (a *Agent) GetPlanModeState() *PlanModeState
GetPlanModeState 获取 Plan 模式状态
func (*Agent) GetSessionState ¶ added in v0.25.0
func (a *Agent) GetSessionState(ctx context.Context) *types.SessionState
GetSessionState 获取会话状态信息 返回当前会话的状态,用于判断是否需要恢复
func (*Agent) GetSystemPrompt ¶ added in v0.16.0
GetSystemPrompt 获取当前的 System Prompt
func (*Agent) GetToolSnapshot ¶ added in v0.16.0
func (a *Agent) GetToolSnapshot(callID string) types.ToolCallSnapshot
GetToolSnapshot 获取指定调用的实时快照
func (*Agent) HasPendingPermission ¶ added in v0.31.0
HasPendingPermission 检查是否有待处理的权限请求
func (*Agent) IsInPlanMode ¶ added in v0.25.0
IsInPlanMode 检查 Agent 是否处于 Plan 模式
func (*Agent) IsResumedSession ¶ added in v0.25.0
IsResumedSession 检查当前是否是恢复的会话
func (*Agent) ListRunningToolSnapshots ¶ added in v0.16.0
func (a *Agent) ListRunningToolSnapshots() []types.ToolCallSnapshot
ListRunningToolSnapshots 列出运行中的工具调用
func (*Agent) ProcessRecovery ¶ added in v0.25.0
func (a *Agent) ProcessRecovery(ctx context.Context, message string, workDir string, metadata map[string]any) (string, bool)
ProcessRecovery 处理会话恢复 如果注册了 RecoveryHook,则调用它来决定是否需要恢复以及如何恢复
func (*Agent) RespondToIterationLimit ¶ added in v0.31.0
RespondToIterationLimit 响应迭代限制事件 continueExecution: true 表示继续执行,false 表示停止
func (*Agent) RespondToPermissionRequest ¶ added in v0.31.0
RespondToPermissionRequest 响应权限请求 approved: true 表示批准,false 表示拒绝
func (*Agent) SendWithContent ¶ added in v0.34.0
SendWithContent 发送多模态消息
func (*Agent) SetMaxIterations ¶ added in v0.31.0
SetMaxIterations 设置最大迭代次数 用于防止 AI 进入无限循环消耗 token 默认值为 50,设置为 0 表示使用默认值
func (*Agent) SetPermissionMode ¶ added in v0.31.0
func (a *Agent) SetPermissionMode(mode permission.Mode)
SetPermissionMode 设置权限模式 ModeAutoApprove: 自动批准所有工具调用(YOLO 模式) ModeSmartApprove: 智能审批(低风险自动,高风险需审批) ModeAlwaysAsk: 所有工具都需要审批
func (*Agent) Stream ¶
func (a *Agent) Stream(ctx context.Context, message string, opts ...Option) *stream.Reader[*session.Event]
Stream 实现流式执行接口 返回 stream.Reader,支持: - 流式生成事件 - 客户端控制的取消 - 与 LLM 流式 API 无缝集成 - 多消费者支持(Copy, Merge, Transform)
func (*Agent) Subscribe ¶
func (a *Agent) Subscribe(channels []types.AgentChannel, opts *types.SubscribeOptions) <-chan types.AgentEventEnvelope
Subscribe 订阅事件
func (*Agent) Unsubscribe ¶
func (a *Agent) Unsubscribe(ch <-chan types.AgentEventEnvelope)
Unsubscribe 取消事件订阅
type AgentActor ¶ added in v0.19.0
type AgentActor struct {
// contains filtered or unexported fields
}
AgentActor 将 Agent 包装为 Actor 这是适配器模式的实现,不修改原有 Agent 代码
func NewAgentActor ¶ added in v0.19.0
func NewAgentActor(agent *Agent) *AgentActor
NewAgentActor 创建 Agent Actor 适配器
func (*AgentActor) Agent ¶ added in v0.19.0
func (a *AgentActor) Agent() *Agent
Agent 获取底层 Agent(用于调试)
func (*AgentActor) Receive ¶ added in v0.19.0
func (a *AgentActor) Receive(ctx *actor.Context, msg actor.Message)
Receive 处理接收到的消息(Actor 核心方法)
func (*AgentActor) Stats ¶ added in v0.19.0
func (a *AgentActor) Stats() *AgentActorStats
Stats 获取统计信息
type AgentActorFactory ¶ added in v0.19.0
type AgentActorFactory struct {
// contains filtered or unexported fields
}
AgentActorFactory Agent Actor 工厂
func NewAgentActorFactory ¶ added in v0.19.0
func NewAgentActorFactory(deps *Dependencies) *AgentActorFactory
NewAgentActorFactory 创建 Agent Actor 工厂
func (*AgentActorFactory) Create ¶ added in v0.19.0
func (f *AgentActorFactory) Create(ctx context.Context, config *types.AgentConfig) (*AgentActor, error)
Create 创建 Agent Actor
func (*AgentActorFactory) CreateAndSpawn ¶ added in v0.19.0
func (f *AgentActorFactory) CreateAndSpawn( ctx context.Context, system *actor.System, config *types.AgentConfig, name string, ) (*actor.PID, error)
CreateAndSpawn 创建并在 Actor 系统中启动 Agent
type AgentActorStats ¶ added in v0.19.0
type AgentActorStats struct {
MessagesReceived int64
MessagesHandled int64
Errors int64
AverageLatency time.Duration
LastMessageAt time.Time
}
AgentActorStats Actor 统计信息
type AvoidOverEngineeringModule ¶ added in v0.18.0
type AvoidOverEngineeringModule struct{}
AvoidOverEngineeringModule 避免过度工程化模块
func (*AvoidOverEngineeringModule) Build ¶ added in v0.18.0
func (m *AvoidOverEngineeringModule) Build(ctx *PromptContext) (string, error)
func (*AvoidOverEngineeringModule) Condition ¶ added in v0.18.0
func (m *AvoidOverEngineeringModule) Condition(ctx *PromptContext) bool
func (*AvoidOverEngineeringModule) Name ¶ added in v0.18.0
func (m *AvoidOverEngineeringModule) Name() string
func (*AvoidOverEngineeringModule) Priority ¶ added in v0.18.0
func (m *AvoidOverEngineeringModule) Priority() int
type BasePromptModule ¶ added in v0.17.0
type BasePromptModule struct{}
BasePromptModule 基础 Prompt(来自模板)
func (*BasePromptModule) Build ¶ added in v0.17.0
func (m *BasePromptModule) Build(ctx *PromptContext) (string, error)
func (*BasePromptModule) Condition ¶ added in v0.17.0
func (m *BasePromptModule) Condition(ctx *PromptContext) bool
func (*BasePromptModule) Name ¶ added in v0.17.0
func (m *BasePromptModule) Name() string
func (*BasePromptModule) Priority ¶ added in v0.17.0
func (m *BasePromptModule) Priority() int
type BatchToolCallMsg ¶ added in v0.19.0
type BatchToolCallMsg struct {
Calls []ToolCall
Ctx context.Context
ReplyTo chan *BatchToolResultMsg
}
BatchToolCallMsg 批量工具调用请求
func (*BatchToolCallMsg) Kind ¶ added in v0.19.0
func (m *BatchToolCallMsg) Kind() string
type BatchToolResultMsg ¶ added in v0.19.0
type BatchToolResultMsg struct {
Results []ToolCallResult
}
BatchToolResultMsg 批量工具调用结果
func (*BatchToolResultMsg) Kind ¶ added in v0.19.0
func (m *BatchToolResultMsg) Kind() string
type CapabilitiesModule ¶ added in v0.17.0
type CapabilitiesModule struct{}
CapabilitiesModule Agent 能力说明模块
func (*CapabilitiesModule) Build ¶ added in v0.17.0
func (m *CapabilitiesModule) Build(ctx *PromptContext) (string, error)
func (*CapabilitiesModule) Condition ¶ added in v0.17.0
func (m *CapabilitiesModule) Condition(ctx *PromptContext) bool
func (*CapabilitiesModule) Name ¶ added in v0.17.0
func (m *CapabilitiesModule) Name() string
func (*CapabilitiesModule) Priority ¶ added in v0.17.0
func (m *CapabilitiesModule) Priority() int
type ChatMsg ¶ added in v0.19.0
type ChatMsg struct {
Text string
Ctx context.Context
ReplyTo chan *ChatResultMsg // 用于接收响应
}
ChatMsg 同步对话请求
type ChatResultMsg ¶ added in v0.19.0
type ChatResultMsg struct {
Result *types.CompleteResult
Error error
}
ChatResultMsg 对话结果消息
func AgentActorChat ¶ added in v0.19.0
AgentActorChat 向 Agent Actor 发送对话请求并等待响应
func (*ChatResultMsg) Kind ¶ added in v0.19.0
func (m *ChatResultMsg) Kind() string
type CodeReferenceModule ¶ added in v0.17.0
type CodeReferenceModule struct{}
CodeReferenceModule 代码引用规范模块
func (*CodeReferenceModule) Build ¶ added in v0.17.0
func (m *CodeReferenceModule) Build(ctx *PromptContext) (string, error)
func (*CodeReferenceModule) Condition ¶ added in v0.17.0
func (m *CodeReferenceModule) Condition(ctx *PromptContext) bool
func (*CodeReferenceModule) Name ¶ added in v0.17.0
func (m *CodeReferenceModule) Name() string
func (*CodeReferenceModule) Priority ¶ added in v0.17.0
func (m *CodeReferenceModule) Priority() int
type CollaborationModule ¶ added in v0.17.0
type CollaborationModule struct {
RoomInfo *RoomCollaborationInfo
}
CollaborationModule 多 Agent 协作模块
func (*CollaborationModule) Build ¶ added in v0.17.0
func (m *CollaborationModule) Build(ctx *PromptContext) (string, error)
func (*CollaborationModule) Condition ¶ added in v0.17.0
func (m *CollaborationModule) Condition(ctx *PromptContext) bool
func (*CollaborationModule) Name ¶ added in v0.17.0
func (m *CollaborationModule) Name() string
func (*CollaborationModule) Priority ¶ added in v0.17.0
func (m *CollaborationModule) Priority() int
type CompressOptions ¶ added in v0.17.0
type CompressOptions struct {
TargetLength int // 目标长度(字符数)
TargetTokens int // 目标 Token 数
Mode CompressionMode // 压缩模式
Level CompressionLevel // 压缩级别
PreserveSections []string // 必须保留的段落标题
}
CompressOptions 压缩选项
type CompressResult ¶ added in v0.17.0
type CompressResult struct {
Compressed string // 压缩后的内容
OriginalLength int // 原始长度
CompressedLength int // 压缩后长度
OriginalTokens int // 原始 Token 数
CompressedTokens int // 压缩后 Token 数
CompressionRatio float64 // 压缩率
TokensSaved int // 节省的 Token 数
Mode string // 使用的模式
}
CompressResult 压缩结果
type CompressionLevel ¶ added in v0.17.0
type CompressionLevel int
CompressionLevel 压缩级别
const ( CompressionLevelLight CompressionLevel = 1 // 轻度压缩(保留 60-70%) CompressionLevelModerate CompressionLevel = 2 // 中度压缩(保留 40-50%) CompressionLevelAggressive CompressionLevel = 3 // 激进压缩(保留 20-30%) )
type CompressionMode ¶ added in v0.17.0
type CompressionMode string
CompressionMode 压缩模式
const ( CompressionModeSimple CompressionMode = "simple" // 基于规则的快速压缩 CompressionModeLLM CompressionMode = "llm" // LLM 驱动的智能压缩 CompressionModeHybrid CompressionMode = "hybrid" // 混合模式(先规则后 LLM) )
type ConcisenessModule ¶ added in v0.18.0
type ConcisenessModule struct{}
ConcisenessModule 简洁性模块 强调简洁、高效的沟通风格
func (*ConcisenessModule) Build ¶ added in v0.18.0
func (m *ConcisenessModule) Build(ctx *PromptContext) (string, error)
func (*ConcisenessModule) Condition ¶ added in v0.18.0
func (m *ConcisenessModule) Condition(ctx *PromptContext) bool
func (*ConcisenessModule) Name ¶ added in v0.18.0
func (m *ConcisenessModule) Name() string
func (*ConcisenessModule) Priority ¶ added in v0.18.0
func (m *ConcisenessModule) Priority() int
type ContextWindowModule ¶ added in v0.17.0
ContextWindowModule 上下文窗口管理模块
func (*ContextWindowModule) Build ¶ added in v0.17.0
func (m *ContextWindowModule) Build(ctx *PromptContext) (string, error)
func (*ContextWindowModule) Condition ¶ added in v0.17.0
func (m *ContextWindowModule) Condition(ctx *PromptContext) bool
func (*ContextWindowModule) Name ¶ added in v0.17.0
func (m *ContextWindowModule) Name() string
func (*ContextWindowModule) Priority ¶ added in v0.17.0
func (m *ContextWindowModule) Priority() int
type CustomInstructionsModule ¶ added in v0.17.0
type CustomInstructionsModule struct {
Instructions string
}
CustomInstructionsModule 用户自定义指令模块
func (*CustomInstructionsModule) Build ¶ added in v0.17.0
func (m *CustomInstructionsModule) Build(ctx *PromptContext) (string, error)
func (*CustomInstructionsModule) Condition ¶ added in v0.17.0
func (m *CustomInstructionsModule) Condition(ctx *PromptContext) bool
func (*CustomInstructionsModule) Name ¶ added in v0.17.0
func (m *CustomInstructionsModule) Name() string
func (*CustomInstructionsModule) Priority ¶ added in v0.17.0
func (m *CustomInstructionsModule) Priority() int
type Dependencies ¶
type Dependencies struct {
Store store.Store
SandboxFactory *sandbox.Factory
ToolRegistry *tools.Registry
ProviderFactory provider.Factory
// Router 为可选依赖,如果为 nil,则沿用旧的静态 ModelConfig 行为。
Router router.Router
TemplateRegistry *TemplateRegistry
// PromptCompressor 可选的 Prompt 压缩器
// 如果配置了且模板启用了压缩,将用于压缩 System Prompt
PromptCompressor *EnhancedPromptCompressor
// RecoveryHook 可选的会话恢复钩子
// 应用层可以注册此钩子来实现自定义的会话恢复逻辑
RecoveryHook types.RecoveryHook
// VectorStoreFactory 向量存储工厂(用于 RAG 和语义记忆)
VectorStoreFactory *factory.StoreFactory
// EmbedderFactory 嵌入模型工厂(用于 RAG 和语义记忆)
EmbedderFactory *factory.EmbedderFactory
}
Dependencies Agent依赖
type DirectToolCallMsg ¶ added in v0.19.0
type DirectToolCallMsg struct {
ToolName string
Input map[string]any
Ctx context.Context
ReplyTo chan *DirectToolResultMsg
}
DirectToolCallMsg 直接工具调用请求
func (*DirectToolCallMsg) Kind ¶ added in v0.19.0
func (m *DirectToolCallMsg) Kind() string
type DirectToolResultMsg ¶ added in v0.19.0
DirectToolResultMsg 直接工具调用结果
func AgentActorCallTool ¶ added in v0.19.0
func AgentActorCallTool(pid *actor.PID, toolName string, input map[string]any, timeout time.Duration) (*DirectToolResultMsg, error)
AgentActorCallTool 向 Agent Actor 发送工具调用请求并等待响应
func (*DirectToolResultMsg) Kind ¶ added in v0.19.0
func (m *DirectToolResultMsg) Kind() string
type EnhancedPromptCompressor ¶ added in v0.17.0
type EnhancedPromptCompressor struct {
// contains filtered or unexported fields
}
EnhancedPromptCompressor 增强的 Prompt 压缩器 集成 Token 计数、段落分析和多模式压缩
func NewEnhancedPromptCompressor ¶ added in v0.17.0
func NewEnhancedPromptCompressor(prov provider.Provider, language string) *EnhancedPromptCompressor
NewEnhancedPromptCompressor 创建增强压缩器
func (*EnhancedPromptCompressor) Compress ¶ added in v0.17.0
func (c *EnhancedPromptCompressor) Compress(ctx context.Context, prompt string, opts *CompressOptions) (*CompressResult, error)
Compress 压缩 Prompt
func (*EnhancedPromptCompressor) EstimateTokens ¶ added in v0.17.0
EstimateTokens 估算 Token 数
type EnvironmentInfo ¶ added in v0.17.0
type EnvironmentInfo struct {
WorkingDir string
Platform string
OSVersion string
Date time.Time
GitRepo *GitRepoInfo
}
EnvironmentInfo 环境信息
type EnvironmentModule ¶ added in v0.17.0
type EnvironmentModule struct{}
EnvironmentModule 环境信息模块
func (*EnvironmentModule) Build ¶ added in v0.17.0
func (m *EnvironmentModule) Build(ctx *PromptContext) (string, error)
func (*EnvironmentModule) Condition ¶ added in v0.17.0
func (m *EnvironmentModule) Condition(ctx *PromptContext) bool
func (*EnvironmentModule) Name ¶ added in v0.17.0
func (m *EnvironmentModule) Name() string
func (*EnvironmentModule) Priority ¶ added in v0.17.0
func (m *EnvironmentModule) Priority() int
type ExecutionPlanConfig ¶ added in v0.31.0
type ExecutionPlanConfig struct {
// Enabled 是否启用执行计划功能
Enabled bool
// RequireApproval 是否需要用户审批
RequireApproval bool
// AutoApprove 是否自动审批
AutoApprove bool
// StopOnError 出错时是否停止
StopOnError bool
// AllowParallel 是否允许并行执行
AllowParallel bool
// MaxParallelSteps 最大并行步骤数
MaxParallelSteps int
}
ExecutionPlanConfig 执行计划配置
type ExecutionPlanManager ¶ added in v0.31.0
type ExecutionPlanManager struct {
// contains filtered or unexported fields
}
ExecutionPlanManager 执行计划管理器 封装了 Agent 的执行计划功能
func NewExecutionPlanManager ¶ added in v0.31.0
func NewExecutionPlanManager(agent *Agent) *ExecutionPlanManager
NewExecutionPlanManager 创建执行计划管理器
func (*ExecutionPlanManager) ApprovePlan ¶ added in v0.31.0
func (m *ExecutionPlanManager) ApprovePlan(approvedBy string) error
ApprovePlan 审批执行计划
func (*ExecutionPlanManager) CancelPlan ¶ added in v0.31.0
func (m *ExecutionPlanManager) CancelPlan(reason string)
CancelPlan 取消当前计划
func (*ExecutionPlanManager) ClearPlan ¶ added in v0.31.0
func (m *ExecutionPlanManager) ClearPlan()
ClearPlan 清除当前计划
func (*ExecutionPlanManager) ExecutePlan ¶ added in v0.31.0
func (m *ExecutionPlanManager) ExecutePlan(ctx context.Context) error
ExecutePlan 执行当前计划
func (*ExecutionPlanManager) ExecutePlanDirect ¶ added in v0.31.0
func (m *ExecutionPlanManager) ExecutePlanDirect(ctx context.Context, plan *executionplan.ExecutionPlan) error
ExecutePlanDirect 直接执行指定计划(不设置为当前计划)
func (*ExecutionPlanManager) FormatCurrentPlan ¶ added in v0.31.0
func (m *ExecutionPlanManager) FormatCurrentPlan() string
FormatCurrentPlan 格式化当前计划为可读文本
func (*ExecutionPlanManager) GeneratePlan ¶ added in v0.31.0
func (m *ExecutionPlanManager) GeneratePlan(ctx context.Context, request string, opts *ExecutionPlanConfig) (*executionplan.ExecutionPlan, error)
GeneratePlan 生成执行计划
func (*ExecutionPlanManager) GetCurrentPlan ¶ added in v0.31.0
func (m *ExecutionPlanManager) GetCurrentPlan() *executionplan.ExecutionPlan
GetCurrentPlan 获取当前执行计划
func (*ExecutionPlanManager) GetPlanSummary ¶ added in v0.31.0
func (m *ExecutionPlanManager) GetPlanSummary() *executionplan.PlanSummary
GetPlanSummary 获取当前计划摘要
func (*ExecutionPlanManager) RejectPlan ¶ added in v0.31.0
func (m *ExecutionPlanManager) RejectPlan(reason string) error
RejectPlan 拒绝执行计划
func (*ExecutionPlanManager) ResumePlan ¶ added in v0.31.0
func (m *ExecutionPlanManager) ResumePlan(ctx context.Context) error
ResumePlan 恢复执行当前计划
func (*ExecutionPlanManager) SetCallbacks ¶ added in v0.31.0
func (m *ExecutionPlanManager) SetCallbacks( onGenerated func(*executionplan.ExecutionPlan), onApproved func(*executionplan.ExecutionPlan), onRejected func(*executionplan.ExecutionPlan, string), onCompleted func(*executionplan.ExecutionPlan), )
SetCallbacks 设置回调函数
func (*ExecutionPlanManager) ValidateCurrentPlan ¶ added in v0.31.0
func (m *ExecutionPlanManager) ValidateCurrentPlan() []error
ValidateCurrentPlan 验证当前计划
type FallbackStats ¶ added in v0.13.0
type FallbackStats struct {
TotalRequests int64
SuccessRequests int64
FailedRequests int64
FallbackCount int64
ModelUsageCount map[string]int64
LastFallbackTime time.Time
}
FallbackStats 降级统计信息
type GetStatusMsg ¶ added in v0.19.0
type GetStatusMsg struct {
ReplyTo chan *types.AgentStatus
}
GetStatusMsg 获取状态请求
func (*GetStatusMsg) Kind ¶ added in v0.19.0
func (m *GetStatusMsg) Kind() string
type GitRepoInfo ¶ added in v0.17.0
type GitRepoInfo struct {
IsRepo bool
CurrentBranch string
MainBranch string
Status string
RecentCommits []string
}
GitRepoInfo Git 仓库信息
type GitSafetyModule ¶ added in v0.18.0
type GitSafetyModule struct{}
GitSafetyModule Git 安全协议模块
func (*GitSafetyModule) Build ¶ added in v0.18.0
func (m *GitSafetyModule) Build(ctx *PromptContext) (string, error)
func (*GitSafetyModule) Condition ¶ added in v0.18.0
func (m *GitSafetyModule) Condition(ctx *PromptContext) bool
func (*GitSafetyModule) Name ¶ added in v0.18.0
func (m *GitSafetyModule) Name() string
func (*GitSafetyModule) Priority ¶ added in v0.18.0
func (m *GitSafetyModule) Priority() int
type LLMPromptCompressor ¶ added in v0.17.0
type LLMPromptCompressor struct {
// contains filtered or unexported fields
}
LLMPromptCompressor LLM 驱动的 Prompt 压缩器
func NewLLMPromptCompressor ¶ added in v0.17.0
func NewLLMPromptCompressor(prov provider.Provider, model string, language string) *LLMPromptCompressor
NewLLMPromptCompressor 创建 LLM Prompt 压缩器
func (*LLMPromptCompressor) Compress ¶ added in v0.17.0
func (c *LLMPromptCompressor) Compress(ctx context.Context, prompt string, targetLength int, preserveSections []string, level int) (string, error)
Compress 压缩 Prompt
func (*LLMPromptCompressor) CompressSection ¶ added in v0.17.0
func (c *LLMPromptCompressor) CompressSection(ctx context.Context, section string, targetLength int) (string, error)
CompressSection 压缩单个段落
func (*LLMPromptCompressor) EstimateCompressionRatio ¶ added in v0.17.0
func (c *LLMPromptCompressor) EstimateCompressionRatio(level int) float64
EstimateCompressionRatio 估算压缩率
type LimitationsModule ¶ added in v0.17.0
type LimitationsModule struct{}
LimitationsModule 限制说明模块
func (*LimitationsModule) Build ¶ added in v0.17.0
func (m *LimitationsModule) Build(ctx *PromptContext) (string, error)
func (*LimitationsModule) Condition ¶ added in v0.17.0
func (m *LimitationsModule) Condition(ctx *PromptContext) bool
func (*LimitationsModule) Name ¶ added in v0.17.0
func (m *LimitationsModule) Name() string
func (*LimitationsModule) Priority ¶ added in v0.17.0
func (m *LimitationsModule) Priority() int
type ModelFallback ¶ added in v0.13.0
type ModelFallback struct {
// Config 模型配置
Config *types.ModelConfig
// MaxRetries 最大重试次数
MaxRetries int
// Enabled 是否启用此模型
Enabled bool
// Priority 优先级(数字越小优先级越高)
Priority int
// contains filtered or unexported fields
}
ModelFallback 模型降级配置
type ModelFallbackManager ¶ added in v0.13.0
type ModelFallbackManager struct {
// contains filtered or unexported fields
}
ModelFallbackManager 模型降级管理器
func NewModelFallbackManager ¶ added in v0.13.0
func NewModelFallbackManager(fallbacks []*ModelFallback, deps *Dependencies) (*ModelFallbackManager, error)
NewModelFallbackManager 创建模型降级管理器
func (*ModelFallbackManager) Complete ¶ added in v0.13.0
func (m *ModelFallbackManager) Complete( ctx context.Context, messages []types.Message, opts *provider.StreamOptions, ) (*provider.CompleteResponse, error)
Complete 执行非流式请求,支持自动降级
func (*ModelFallbackManager) DisableModel ¶ added in v0.13.0
func (m *ModelFallbackManager) DisableModel(provider, model string) error
DisableModel 禁用指定模型
func (*ModelFallbackManager) EnableModel ¶ added in v0.13.0
func (m *ModelFallbackManager) EnableModel(provider, model string) error
EnableModel 启用指定模型
func (*ModelFallbackManager) GetCurrentProvider ¶ added in v0.13.0
func (m *ModelFallbackManager) GetCurrentProvider() provider.Provider
GetCurrentProvider 获取当前使用的 Provider
func (*ModelFallbackManager) GetStats ¶ added in v0.13.0
func (m *ModelFallbackManager) GetStats() *FallbackStats
GetStats 获取统计信息
func (*ModelFallbackManager) ListModels ¶ added in v0.13.0
func (m *ModelFallbackManager) ListModels() []map[string]any
ListModels 列出所有模型及其状态
func (*ModelFallbackManager) ResetStats ¶ added in v0.13.0
func (m *ModelFallbackManager) ResetStats()
ResetStats 重置统计信息
func (*ModelFallbackManager) Stream ¶ added in v0.13.0
func (m *ModelFallbackManager) Stream( ctx context.Context, messages []types.Message, opts *provider.StreamOptions, ) (<-chan provider.StreamChunk, error)
Stream 执行流式请求,支持自动降级
type PerformanceModule ¶ added in v0.17.0
type PerformanceModule struct{}
PerformanceModule 性能优化模块
func (*PerformanceModule) Build ¶ added in v0.17.0
func (m *PerformanceModule) Build(ctx *PromptContext) (string, error)
func (*PerformanceModule) Condition ¶ added in v0.17.0
func (m *PerformanceModule) Condition(ctx *PromptContext) bool
func (*PerformanceModule) Name ¶ added in v0.17.0
func (m *PerformanceModule) Name() string
func (*PerformanceModule) Priority ¶ added in v0.17.0
func (m *PerformanceModule) Priority() int
type PlanConstraints ¶ added in v0.25.0
type PlanConstraints struct {
ReadOnly bool // 只读模式
AllowedWritePaths []string // 允许写入的路径(仅计划文件)
DisabledTools []string // 禁用的工具
RequireApproval bool // 退出时需要用户批准
}
PlanConstraints Plan 模式约束
type PlanModeManager ¶ added in v0.25.0
type PlanModeManager struct {
// contains filtered or unexported fields
}
PlanModeManager Plan 模式管理器 管理 Agent 的 Plan 模式状态和工具约束
func NewPlanModeManager ¶ added in v0.25.0
func NewPlanModeManager() *PlanModeManager
NewPlanModeManager 创建 Plan 模式管理器
func (*PlanModeManager) EnterPlanMode ¶ added in v0.25.0
func (m *PlanModeManager) EnterPlanMode(planID, planFilePath, reason string)
EnterPlanMode 进入 Plan 模式
func (*PlanModeManager) ExitPlanMode ¶ added in v0.25.0
func (m *PlanModeManager) ExitPlanMode()
ExitPlanMode 退出 Plan 模式
func (*PlanModeManager) GetState ¶ added in v0.25.0
func (m *PlanModeManager) GetState() *PlanModeState
GetState 获取当前状态
func (*PlanModeManager) IsActive ¶ added in v0.25.0
func (m *PlanModeManager) IsActive() bool
IsActive 检查是否处于 Plan 模式
func (*PlanModeManager) ValidateToolCall ¶ added in v0.25.0
ValidateToolCall 验证工具调用是否允许 返回 (allowed, reason)
type PlanModeState ¶ added in v0.25.0
type PlanModeState struct {
Active bool // 是否处于 Plan 模式
PlanID string // 当前计划 ID
PlanFilePath string // 计划文件路径
AllowedTools map[string]bool // 允许的工具白名单
Reason string // 进入 Plan 模式的原因
Constraints *PlanConstraints // 约束配置
}
PlanModeState Plan 模式状态
type PlanningWithoutTimelinesModule ¶ added in v0.18.0
type PlanningWithoutTimelinesModule struct{}
PlanningWithoutTimelinesModule 无时间线规划模块
func (*PlanningWithoutTimelinesModule) Build ¶ added in v0.18.0
func (m *PlanningWithoutTimelinesModule) Build(ctx *PromptContext) (string, error)
func (*PlanningWithoutTimelinesModule) Condition ¶ added in v0.18.0
func (m *PlanningWithoutTimelinesModule) Condition(ctx *PromptContext) bool
func (*PlanningWithoutTimelinesModule) Name ¶ added in v0.18.0
func (m *PlanningWithoutTimelinesModule) Name() string
func (*PlanningWithoutTimelinesModule) Priority ¶ added in v0.18.0
func (m *PlanningWithoutTimelinesModule) Priority() int
type ProfessionalObjectivityModule ¶ added in v0.18.0
type ProfessionalObjectivityModule struct{}
ProfessionalObjectivityModule 专业客观性模块
func (*ProfessionalObjectivityModule) Build ¶ added in v0.18.0
func (m *ProfessionalObjectivityModule) Build(ctx *PromptContext) (string, error)
func (*ProfessionalObjectivityModule) Condition ¶ added in v0.18.0
func (m *ProfessionalObjectivityModule) Condition(ctx *PromptContext) bool
func (*ProfessionalObjectivityModule) Name ¶ added in v0.18.0
func (m *ProfessionalObjectivityModule) Name() string
func (*ProfessionalObjectivityModule) Priority ¶ added in v0.18.0
func (m *ProfessionalObjectivityModule) Priority() int
type PromptBuilder ¶ added in v0.17.0
type PromptBuilder struct {
// contains filtered or unexported fields
}
PromptBuilder System Prompt 构建器
func NewPromptBuilder ¶ added in v0.17.0
func NewPromptBuilder() *PromptBuilder
NewPromptBuilder 创建构建器
func NewPromptBuilderWithCompression ¶ added in v0.17.0
func NewPromptBuilderWithCompression(compressor *EnhancedPromptCompressor) *PromptBuilder
NewPromptBuilderWithCompression 创建带压缩功能的构建器
func (*PromptBuilder) AddModule ¶ added in v0.17.0
func (pb *PromptBuilder) AddModule(module PromptModule)
AddModule 添加模块
func (*PromptBuilder) Build ¶ added in v0.17.0
func (pb *PromptBuilder) Build(ctx *PromptContext) (string, error)
Build 构建完整的 System Prompt
func (*PromptBuilder) SetCompressor ¶ added in v0.17.0
func (pb *PromptBuilder) SetCompressor(compressor *EnhancedPromptCompressor)
SetCompressor 设置压缩器
type PromptCompressor ¶ added in v0.17.0
PromptCompressor Prompt 压缩器(使用 LLM 进行智能压缩)
func (*PromptCompressor) Compress ¶ added in v0.17.0
func (pc *PromptCompressor) Compress(prompt string) string
Compress 压缩 Prompt(简化版,实际可以使用 LLM)
type PromptContext ¶ added in v0.17.0
type PromptContext struct {
Agent *Agent
Template *types.AgentTemplateDefinition
Environment *EnvironmentInfo
Sandbox *SandboxInfo
Tools map[string]tools.Tool
Metadata map[string]any
}
PromptContext 构建上下文
type PromptModule ¶ added in v0.17.0
type PromptModule interface {
Name() string
Build(ctx *PromptContext) (string, error)
Priority() int // 模块优先级,决定注入顺序
Condition(ctx *PromptContext) bool // 是否应该注入此模块
}
PromptModule 表示一个可组合的 prompt 模块
type PromptOptimizer ¶ added in v0.17.0
type PromptOptimizer struct {
MaxLength int // 最大长度(字符数)
RemoveDuplicates bool // 移除重复内容
CompactFormat bool // 紧凑格式
}
PromptOptimizer Prompt 优化器
func (*PromptOptimizer) Optimize ¶ added in v0.17.0
func (po *PromptOptimizer) Optimize(prompt string) string
Optimize 优化 System Prompt
type PromptStats ¶ added in v0.17.0
type PromptStats struct {
TotalLength int
LineCount int
SectionCount int
ModuleCount int
EstimatedTokens int
}
PromptStats Prompt 统计信息
func AnalyzePrompt ¶ added in v0.17.0
func AnalyzePrompt(prompt string) *PromptStats
AnalyzePrompt 分析 Prompt 统计信息
type PromptTemplatePreset ¶ added in v0.17.0
type PromptTemplatePreset struct {
ID string
Name string
Description string
Template *types.AgentTemplateDefinition
Modules []string // 推荐的模块列表
}
PromptTemplatePreset Prompt 模板预设
func GetPreset ¶ added in v0.17.0
func GetPreset(id string) *PromptTemplatePreset
GetPreset 根据 ID 获取预设
type RemoteAgent ¶ added in v0.32.0
type RemoteAgent struct {
// contains filtered or unexported fields
}
RemoteAgent 是远程 Agent 的本地代理 它实现了 Agent 接口的核心方法,但不执行实际的 LLM 调用 而是接收来自远程进程的事件并转发到本地 EventBus
func NewRemoteAgent ¶ added in v0.32.0
func NewRemoteAgent(id, templateID string, metadata map[string]any) *RemoteAgent
NewRemoteAgent 创建一个新的 RemoteAgent 实例
func (*RemoteAgent) Chat ¶ added in v0.32.0
func (r *RemoteAgent) Chat(ctx context.Context, text string) (*types.CompleteResult, error)
Chat 不支持 - RemoteAgent 不执行实际的 LLM 调用
func (*RemoteAgent) Close ¶ added in v0.32.0
func (r *RemoteAgent) Close() error
Close 关闭 RemoteAgent
func (*RemoteAgent) ExecuteToolDirect ¶ added in v0.32.0
func (r *RemoteAgent) ExecuteToolDirect(ctx context.Context, toolName string, input map[string]any) (any, error)
ExecuteToolDirect 不支持 - RemoteAgent 不执行工具
func (*RemoteAgent) GetEventBus ¶ added in v0.32.0
func (r *RemoteAgent) GetEventBus() *events.EventBus
GetEventBus 返回 EventBus 实例
func (*RemoteAgent) GetIterationCount ¶ added in v0.32.0
func (r *RemoteAgent) GetIterationCount() int
GetIterationCount 返回 0 - 迭代计数在远程端
func (*RemoteAgent) GetMetadata ¶ added in v0.32.0
func (r *RemoteAgent) GetMetadata() map[string]any
GetMetadata 返回元数据
func (*RemoteAgent) GetPermissionMode ¶ added in v0.32.0
func (r *RemoteAgent) GetPermissionMode() permission.Mode
GetPermissionMode 返回默认模式
func (*RemoteAgent) GetSystemPrompt ¶ added in v0.32.0
func (r *RemoteAgent) GetSystemPrompt() string
GetSystemPrompt 返回空字符串 - 系统提示词在远程端
func (*RemoteAgent) HasPendingPermission ¶ added in v0.32.0
func (r *RemoteAgent) HasPendingPermission(callID string) bool
HasPendingPermission 不支持 - 权限管理在远程端
func (*RemoteAgent) PushEvent ¶ added in v0.32.0
func (r *RemoteAgent) PushEvent(envelope types.AgentEventEnvelope) error
PushEvent 接收远程事件并推送到本地 EventBus 这是 RemoteAgent 的核心方法,用于接收来自远程进程的事件
func (*RemoteAgent) RespondToIterationLimit ¶ added in v0.32.0
func (r *RemoteAgent) RespondToIterationLimit(continueExecution bool)
RespondToIterationLimit 不支持 - 迭代管理在远程端
func (*RemoteAgent) RespondToPermissionRequest ¶ added in v0.32.0
func (r *RemoteAgent) RespondToPermissionRequest(callID string, approved bool) error
RespondToPermissionRequest 不支持 - 权限管理在远程端
func (*RemoteAgent) Send ¶ added in v0.32.0
func (r *RemoteAgent) Send(ctx context.Context, text string) error
Send 不支持 - RemoteAgent 不执行实际的 LLM 调用
func (*RemoteAgent) SetMaxIterations ¶ added in v0.32.0
func (r *RemoteAgent) SetMaxIterations(max int)
SetMaxIterations 不支持 - 配置在远程端
func (*RemoteAgent) SetMetadata ¶ added in v0.32.0
func (r *RemoteAgent) SetMetadata(key string, value any)
SetMetadata 设置元数据
func (*RemoteAgent) SetPermissionMode ¶ added in v0.32.0
func (r *RemoteAgent) SetPermissionMode(mode permission.Mode)
SetPermissionMode 不支持 - 权限模式在远程端
func (*RemoteAgent) Status ¶ added in v0.32.0
func (r *RemoteAgent) Status() *types.AgentStatus
Status 返回 Agent 状态
func (*RemoteAgent) Subscribe ¶ added in v0.32.0
func (r *RemoteAgent) Subscribe(channels []types.AgentChannel, opts *types.SubscribeOptions) <-chan types.AgentEventEnvelope
Subscribe 订阅指定通道的事件
func (*RemoteAgent) Unsubscribe ¶ added in v0.32.0
func (r *RemoteAgent) Unsubscribe(ch <-chan types.AgentEventEnvelope)
Unsubscribe 取消订阅
type RoomCollaborationInfo ¶ added in v0.17.0
type SandboxInfo ¶ added in v0.17.0
type SandboxInfo struct {
Kind types.SandboxKind
WorkDir string
AllowPaths []string
}
SandboxInfo 沙箱信息
type SandboxModule ¶ added in v0.17.0
type SandboxModule struct{}
SandboxModule 沙箱信息模块
func (*SandboxModule) Build ¶ added in v0.17.0
func (m *SandboxModule) Build(ctx *PromptContext) (string, error)
func (*SandboxModule) Condition ¶ added in v0.17.0
func (m *SandboxModule) Condition(ctx *PromptContext) bool
func (*SandboxModule) Name ¶ added in v0.17.0
func (m *SandboxModule) Name() string
func (*SandboxModule) Priority ¶ added in v0.17.0
func (m *SandboxModule) Priority() int
type ScoredSection ¶ added in v0.17.0
ScoredSection 带评分的段落
type SecurityModule ¶ added in v0.17.0
type SecurityModule struct{}
SecurityModule 安全策略模块
func (*SecurityModule) Build ¶ added in v0.17.0
func (m *SecurityModule) Build(ctx *PromptContext) (string, error)
func (*SecurityModule) Condition ¶ added in v0.17.0
func (m *SecurityModule) Condition(ctx *PromptContext) bool
func (*SecurityModule) Name ¶ added in v0.17.0
func (m *SecurityModule) Name() string
func (*SecurityModule) Priority ¶ added in v0.17.0
func (m *SecurityModule) Priority() int
type StreamEventMsg ¶ added in v0.19.0
type StreamEventMsg struct {
Type string // "text", "tool_start", "tool_end", "done", "error"
Content any
Error error
}
StreamEventMsg 流式事件消息
func (*StreamEventMsg) Kind ¶ added in v0.19.0
func (m *StreamEventMsg) Kind() string
type StreamMsg ¶ added in v0.19.0
type StreamMsg struct {
Text string
Ctx context.Context
EventCh chan *StreamEventMsg // 事件流通道
}
StreamMsg 流式对话请求
type StreamingAgent ¶
type StreamingAgent interface {
// Stream 流式执行,返回事件流
// 相比 Chat 方法的优势:
// 1. 内存高效 - 按需生成事件,无需完整加载到内存
// 2. 背压控制 - 客户端可控制消费速度
// 3. 实时响应 - 可以立即处理每个事件,而不是等待所有事件
// 4. 多消费者 - 支持 Copy 复制流给多个消费者
Stream(ctx context.Context, message string, opts ...Option) *stream.Reader[*session.Event]
}
StreamingAgent 扩展接口 - 支持流式执行 参考 Google ADK-Go 的 Agent.Run() 设计,使用 stream.Reader
使用示例:
reader := agent.Stream(ctx, "Hello")
for {
event, err := reader.Recv()
if err == io.EOF { break }
if err != nil {
log.Printf("Error: %v", err)
break
}
fmt.Printf("Event: %+v\n", event)
}
type SubAgentExecutorImpl ¶ added in v0.25.0
type SubAgentExecutorImpl struct {
// contains filtered or unexported fields
}
SubAgentExecutorImpl 子 Agent 执行器实现 实现 types.SubAgentExecutor 接口
func NewSubAgentExecutor ¶ added in v0.25.0
func NewSubAgentExecutor(manager *SubAgentManager, agentType string) (*SubAgentExecutorImpl, error)
NewSubAgentExecutor 创建子 Agent 执行器
func (*SubAgentExecutorImpl) Execute ¶ added in v0.25.0
func (e *SubAgentExecutorImpl) Execute(ctx context.Context, req *types.SubAgentRequest) (*types.SubAgentResult, error)
Execute 执行子 Agent 任务
func (*SubAgentExecutorImpl) GetSpec ¶ added in v0.25.0
func (e *SubAgentExecutorImpl) GetSpec() *types.SubAgentSpec
GetSpec 获取子 Agent 规格
type SubAgentExecutorWrapper ¶ added in v0.25.0
type SubAgentExecutorWrapper struct {
// contains filtered or unexported fields
}
SubAgentExecutorWrapper 包装 SubAgentManager 为单个执行器
func NewSubAgentExecutorWrapper ¶ added in v0.25.0
func NewSubAgentExecutorWrapper(manager *SubAgentManager, agentType string) (*SubAgentExecutorWrapper, error)
NewSubAgentExecutorWrapper 创建执行器包装
func (*SubAgentExecutorWrapper) Execute ¶ added in v0.25.0
func (w *SubAgentExecutorWrapper) Execute(ctx context.Context, req *types.SubAgentRequest) (*types.SubAgentResult, error)
Execute 执行子 Agent 任务
func (*SubAgentExecutorWrapper) GetSpec ¶ added in v0.25.0
func (w *SubAgentExecutorWrapper) GetSpec() *types.SubAgentSpec
GetSpec 获取子 Agent 规格
type SubAgentHandle ¶ added in v0.25.0
type SubAgentHandle struct {
ID string
AgentType string
Agent *Agent
Request *types.SubAgentRequest
StartTime time.Time
Status string // "running", "completed", "failed", "canceled"
Result *types.SubAgentResult
CancelFunc context.CancelFunc
ProgressChan chan *types.SubAgentProgressEvent
ParentAgentID string
}
SubAgentHandle 子 Agent 句柄
type SubAgentManager ¶ added in v0.25.0
type SubAgentManager struct {
// contains filtered or unexported fields
}
SubAgentManager 子 Agent 管理器 负责创建、执行和管理子 Agent 的生命周期
func InitializeTaskExecutor ¶ added in v0.25.0
func InitializeTaskExecutor(deps *Dependencies) *SubAgentManager
InitializeTaskExecutor 初始化 Task 执行器 应用层在启动时调用此函数,将 SubAgentManager 注入到 Task 工具
func NewSubAgentManager ¶ added in v0.25.0
func NewSubAgentManager(deps *Dependencies) *SubAgentManager
NewSubAgentManager 创建子 Agent 管理器
func (*SubAgentManager) Cancel ¶ added in v0.25.0
func (m *SubAgentManager) Cancel(taskID string) error
Cancel 取消子 Agent 任务
func (*SubAgentManager) Execute ¶ added in v0.25.0
func (m *SubAgentManager) Execute(ctx context.Context, req *types.SubAgentRequest) (*types.SubAgentResult, error)
Execute 执行子 Agent 任务
func (*SubAgentManager) ExecuteAsync ¶ added in v0.25.0
func (m *SubAgentManager) ExecuteAsync(ctx context.Context, req *types.SubAgentRequest) (string, <-chan *types.SubAgentProgressEvent, error)
ExecuteAsync 异步执行子 Agent 任务
func (*SubAgentManager) GetSpec ¶ added in v0.25.0
func (m *SubAgentManager) GetSpec(name string) (*types.SubAgentSpec, error)
GetSpec 获取子 Agent 规格
func (*SubAgentManager) GetStatus ¶ added in v0.25.0
func (m *SubAgentManager) GetStatus(taskID string) (*SubAgentHandle, error)
GetStatus 获取子 Agent 任务状态
func (*SubAgentManager) ListRunning ¶ added in v0.25.0
func (m *SubAgentManager) ListRunning() []*SubAgentHandle
ListRunning 列出运行中的子 Agent
func (*SubAgentManager) ListSpecs ¶ added in v0.25.0
func (m *SubAgentManager) ListSpecs() []*types.SubAgentSpec
ListSpecs 列出所有子 Agent 规格
func (*SubAgentManager) RegisterSpec ¶ added in v0.25.0
func (m *SubAgentManager) RegisterSpec(spec *types.SubAgentSpec)
RegisterSpec 注册子 Agent 规格
type SubAgentManagerFactory ¶ added in v0.25.0
type SubAgentManagerFactory struct {
// contains filtered or unexported fields
}
SubAgentManagerFactory 将 SubAgentManager 适配为 SubAgentExecutorFactory 这个适配器允许 Task 工具使用真正的子 Agent 执行
func NewSubAgentManagerFactory ¶ added in v0.25.0
func NewSubAgentManagerFactory(manager *SubAgentManager) *SubAgentManagerFactory
NewSubAgentManagerFactory 创建工厂适配器
func (*SubAgentManagerFactory) Create ¶ added in v0.25.0
func (f *SubAgentManagerFactory) Create(agentType string) (types.SubAgentExecutor, error)
Create 创建指定类型的子 Agent 执行器
func (*SubAgentManagerFactory) ListTypes ¶ added in v0.25.0
func (f *SubAgentManagerFactory) ListTypes() []string
ListTypes 列出支持的子 Agent 类型
type TemplateNotFoundError ¶
type TemplateNotFoundError struct {
ID string
}
TemplateNotFoundError 模板未找到错误
func (*TemplateNotFoundError) Error ¶
func (e *TemplateNotFoundError) Error() string
type TemplateRegistry ¶
type TemplateRegistry struct {
// contains filtered or unexported fields
}
TemplateRegistry 模板注册表
func (*TemplateRegistry) Get ¶
func (tr *TemplateRegistry) Get(id string) (*types.AgentTemplateDefinition, error)
Get 获取模板
func (*TemplateRegistry) List ¶
func (tr *TemplateRegistry) List() []*types.AgentTemplateDefinition
List 列出所有模板
func (*TemplateRegistry) Register ¶
func (tr *TemplateRegistry) Register(template *types.AgentTemplateDefinition)
Register 注册模板
type TodoReminderModule ¶ added in v0.17.0
type TodoReminderModule struct {
Config *types.TodoConfig
}
TodoReminderModule Todo 提醒模块
func (*TodoReminderModule) Build ¶ added in v0.17.0
func (m *TodoReminderModule) Build(ctx *PromptContext) (string, error)
func (*TodoReminderModule) Condition ¶ added in v0.17.0
func (m *TodoReminderModule) Condition(ctx *PromptContext) bool
func (*TodoReminderModule) Name ¶ added in v0.17.0
func (m *TodoReminderModule) Name() string
func (*TodoReminderModule) Priority ¶ added in v0.17.0
func (m *TodoReminderModule) Priority() int
type ToolCallDeniedError ¶ added in v0.25.0
ToolCallDeniedError 工具调用被拒绝错误
func (*ToolCallDeniedError) Error ¶ added in v0.25.0
func (e *ToolCallDeniedError) Error() string
type ToolCallMsg ¶ added in v0.19.0
type ToolCallMsg struct {
ToolUse *types.ToolUseBlock
Ctx context.Context
}
ToolCallMsg 工具调用请求
func (*ToolCallMsg) Kind ¶ added in v0.19.0
func (m *ToolCallMsg) Kind() string
type ToolCallResult ¶ added in v0.17.0
type ToolCallResult struct {
Name string `json:"name"`
Success bool `json:"success"`
Result any `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
ToolCallResult 工具调用结果
type ToolManager ¶ added in v0.17.0
type ToolManager struct {
// contains filtered or unexported fields
}
ToolManager 工具管理器 支持动态工具激活和工具搜索
func NewToolManager ¶ added in v0.17.0
func NewToolManager(registry *tools.Registry) *ToolManager
NewToolManager 创建工具管理器
func (*ToolManager) ActivateTool ¶ added in v0.17.0
func (tm *ToolManager) ActivateTool(name string) error
ActivateTool 激活延迟工具
func (*ToolManager) ActivateTools ¶ added in v0.17.0
func (tm *ToolManager) ActivateTools(names []string) (activated []string, failed map[string]error)
ActivateTools 批量激活工具
func (*ToolManager) AddToolEntry ¶ added in v0.17.0
func (tm *ToolManager) AddToolEntry(entry search.ToolIndexEntry) error
AddToolEntry 添加工具条目(用于 MCP 延迟加载)
func (*ToolManager) DeactivateTool ¶ added in v0.17.0
func (tm *ToolManager) DeactivateTool(name string) error
DeactivateTool 停用工具(移回延迟状态)
func (*ToolManager) GetActiveTool ¶ added in v0.17.0
func (tm *ToolManager) GetActiveTool(name string) (tools.Tool, bool)
GetActiveTool 获取单个活跃工具
func (*ToolManager) GetActiveTools ¶ added in v0.17.0
func (tm *ToolManager) GetActiveTools() map[string]tools.Tool
GetActiveTools 获取所有活跃工具
func (*ToolManager) GetIndex ¶ added in v0.17.0
func (tm *ToolManager) GetIndex() *search.ToolIndex
GetIndex 获取工具索引
func (*ToolManager) Initialize ¶ added in v0.17.0
func (tm *ToolManager) Initialize(toolNames []string, activeByDefault bool) error
Initialize 初始化工具管理器 将所有工具添加到索引,并根据配置决定哪些工具活跃
func (*ToolManager) IsCoreTool ¶ added in v0.17.0
func (tm *ToolManager) IsCoreTool(name string) bool
IsCoreTools 检查是否是核心工具
func (*ToolManager) RemoveTool ¶ added in v0.17.0
func (tm *ToolManager) RemoveTool(name string) error
RemoveTool 移除工具
func (*ToolManager) SearchTools ¶ added in v0.17.0
func (tm *ToolManager) SearchTools(query string, topK int) []search.ToolSearchResult
SearchTools 搜索工具
func (*ToolManager) Stats ¶ added in v0.17.0
func (tm *ToolManager) Stats() map[string]any
Stats 返回统计信息
type ToolResultMsg ¶ added in v0.19.0
ToolResultMsg 工具调用结果
func (*ToolResultMsg) Kind ¶ added in v0.19.0
func (m *ToolResultMsg) Kind() string
type ToolsManualModule ¶ added in v0.17.0
type ToolsManualModule struct {
Config *types.ToolsManualConfig
}
ToolsManualModule 工具手册模块
func (*ToolsManualModule) Build ¶ added in v0.17.0
func (m *ToolsManualModule) Build(ctx *PromptContext) (string, error)
func (*ToolsManualModule) Condition ¶ added in v0.17.0
func (m *ToolsManualModule) Condition(ctx *PromptContext) bool
func (*ToolsManualModule) Name ¶ added in v0.17.0
func (m *ToolsManualModule) Name() string
func (*ToolsManualModule) Priority ¶ added in v0.17.0
func (m *ToolsManualModule) Priority() int
type WorkflowContextInfo ¶ added in v0.17.0
type WorkflowModule ¶ added in v0.17.0
type WorkflowModule struct {
WorkflowInfo *WorkflowContextInfo
}
WorkflowModule 工作流上下文模块
func (*WorkflowModule) Build ¶ added in v0.17.0
func (m *WorkflowModule) Build(ctx *PromptContext) (string, error)
func (*WorkflowModule) Condition ¶ added in v0.17.0
func (m *WorkflowModule) Condition(ctx *PromptContext) bool
func (*WorkflowModule) Name ¶ added in v0.17.0
func (m *WorkflowModule) Name() string
func (*WorkflowModule) Priority ¶ added in v0.17.0
func (m *WorkflowModule) Priority() int