builtin

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllTools

func AllTools() []string

AllTools 返回所有内置工具列表

func AssertContains

func AssertContains(t *testing.T, str, substr string)

AssertContains 断言字符串包含子字符串

func AssertFileContent

func AssertFileContent(t *testing.T, path, expectedContent string)

AssertFileContent 断言文件内容

func AssertFileExists

func AssertFileExists(t *testing.T, path string)

AssertFileExists 断言文件存在

func AssertFileNotExists

func AssertFileNotExists(t *testing.T, path string)

AssertFileNotExists 断言文件不存在

func AssertToolError

func AssertToolError(t *testing.T, result map[string]interface{}) string

AssertToolError 断言工具执行失败

func AssertToolSuccess

func AssertToolSuccess(t *testing.T, result map[string]interface{}) map[string]interface{}

AssertToolSuccess 断言工具执行成功

func BenchmarkTool

func BenchmarkTool(b *testing.B, tool tools.Tool, input map[string]interface{})

BenchmarkTool 工具性能基准测试辅助函数

func CreateTestFiles

func CreateTestFiles(th *TestHelper) map[string]string

CreateTestFiles 创建标准测试文件

func ExecuteToolWithInput

func ExecuteToolWithInput(t *testing.T, tool tools.Tool, input map[string]interface{}) map[string]interface{}

ExecuteToolWithInput 使用指定输入执行工具

func ExecuteToolWithRealFS

func ExecuteToolWithRealFS(t *testing.T, tool tools.Tool, input map[string]interface{}) map[string]interface{}

ExecuteToolWithRealFS 使用真实文件系统执行工具

func ExecutionTools

func ExecutionTools() []string

ExecutionTools 返回执行工具列表

func FileSystemTools

func FileSystemTools() []string

FileSystemTools 返回文件系统工具列表

func GetBoolParam

func GetBoolParam(input map[string]interface{}, key string, defaultValue bool) bool

GetBoolParam 获取布尔参数的通用函数

func GetIntParam

func GetIntParam(input map[string]interface{}, key string, defaultValue int) int

GetIntParam 获取整数参数的通用函数

func GetStringParam

func GetStringParam(input map[string]interface{}, key string, defaultValue string) string

GetStringParam 获取字符串参数的通用函数

func GetStringSliceParam

func GetStringSliceParam(input map[string]interface{}, key string) []string

GetStringSliceParam 获取字符串数组参数的通用函数

func NetworkTools

func NetworkTools() []string

NetworkTools 返回网络工具列表

func NewBashOutputTool

func NewBashOutputTool(config map[string]interface{}) (tools.Tool, error)

NewBashOutputTool 创建BashOutput工具

func NewBashTool

func NewBashTool(config map[string]interface{}) (tools.Tool, error)

NewBashTool 创建Bash执行工具

func NewClaudeErrorResponse

func NewClaudeErrorResponse(err error, recommendations ...string) map[string]interface{}

NewClaudeErrorResponse 创建Claude兼容的错误响应

func NewEditTool

func NewEditTool(config map[string]interface{}) (tools.Tool, error)

NewEditTool 创建Edit工具

func NewExitPlanModeTool

func NewExitPlanModeTool(config map[string]interface{}) (tools.Tool, error)

NewExitPlanModeTool 创建ExitPlanMode工具

func NewGlobTool

func NewGlobTool(config map[string]interface{}) (tools.Tool, error)

NewGlobTool 创建Glob工具

func NewGrepTool

func NewGrepTool(config map[string]interface{}) (tools.Tool, error)

NewGrepTool 创建Grep工具

func NewHttpRequestTool

func NewHttpRequestTool(config map[string]interface{}) (tools.Tool, error)

NewHttpRequestTool 创建HTTP请求工具

func NewKillShellTool

func NewKillShellTool(config map[string]interface{}) (tools.Tool, error)

NewKillShellTool 创建KillShell工具

func NewMockToolContext

func NewMockToolContext() sandbox.Sandbox

NewMockToolContext 创建模拟工具上下文

func NewReadTool

func NewReadTool(config map[string]interface{}) (tools.Tool, error)

NewReadTool 创建文件读取工具

func NewSemanticSearchTool

func NewSemanticSearchTool(config map[string]interface{}) (tools.Tool, error)

func NewSkillTool

func NewSkillTool(config map[string]interface{}) (tools.Tool, error)

NewSkillTool 创建 SkillTool 实例

func NewTaskTool

func NewTaskTool(config map[string]interface{}) (tools.Tool, error)

NewTaskTool 创建Task工具

func NewTodoWriteTool

func NewTodoWriteTool(config map[string]interface{}) (tools.Tool, error)

NewTodoWriteTool 创建TodoWrite工具

func NewWebSearchTool

func NewWebSearchTool(config map[string]interface{}) (tools.Tool, error)

NewWebSearchTool 创建网络搜索工具

func NewWriteTool

func NewWriteTool(config map[string]interface{}) (tools.Tool, error)

NewWriteTool 创建文件写入工具

func RegisterAll

func RegisterAll(registry *tools.Registry)

RegisterAll 注册所有内置工具

func SemanticTools

func SemanticTools() []string

SemanticTools 返回语义工具列表

func SkillTools

func SkillTools() []string

SkillTools 返回技能工具列表

func SkipIfShort

func SkipIfShort(t *testing.T)

SkipIfShort 如果是短测试模式则跳过

func TaskManagementTools

func TaskManagementTools() []string

TaskManagementTools 返回任务管理工具列表

func ValidateRequired

func ValidateRequired(input map[string]interface{}, required []string) error

ValidateRequired 验证必需参数的通用函数

Types

type BashOutputTool

type BashOutputTool struct{}

BashOutputTool 后台shell输出获取工具 支持获取后台运行命令的输出和状态

func (*BashOutputTool) Description

func (t *BashOutputTool) Description() string

func (*BashOutputTool) Execute

func (t *BashOutputTool) Execute(ctx context.Context, input map[string]interface{}, tc *tools.ToolContext) (interface{}, error)

func (*BashOutputTool) InputSchema

func (t *BashOutputTool) InputSchema() map[string]interface{}

func (*BashOutputTool) Name

func (t *BashOutputTool) Name() string

func (*BashOutputTool) Prompt

func (t *BashOutputTool) Prompt() string

type BashTool

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

BashTool 增强的Bash命令执行工具 支持持久化shell会话功能

func (*BashTool) Description

func (t *BashTool) Description() string

func (*BashTool) Execute

func (t *BashTool) Execute(ctx context.Context, input map[string]interface{}, tc *tools.ToolContext) (interface{}, error)

func (*BashTool) InputSchema

func (t *BashTool) InputSchema() map[string]interface{}

func (*BashTool) Name

func (t *BashTool) Name() string

func (*BashTool) Prompt

func (t *BashTool) Prompt() string

type ConcurrentTestResult

type ConcurrentTestResult struct {
	SuccessCount int
	ErrorCount   int
	Errors       []error
	Duration     time.Duration
}

ConcurrentTestResult 并发测试结果

func RunConcurrentTest

func RunConcurrentTest(concurrency int, testFunc func() error) *ConcurrentTestResult

RunConcurrentTest 运行并发测试

type EditTool

type EditTool struct{}

EditTool 增强的文件编辑工具 支持精确的字符串替换编辑功能

func (*EditTool) Description

func (t *EditTool) Description() string

func (*EditTool) Execute

func (t *EditTool) Execute(ctx context.Context, input map[string]interface{}, tc *tools.ToolContext) (interface{}, error)

func (*EditTool) InputSchema

func (t *EditTool) InputSchema() map[string]interface{}

func (*EditTool) Name

func (t *EditTool) Name() string

func (*EditTool) Prompt

func (t *EditTool) Prompt() string

type ExitPlanModeTool

type ExitPlanModeTool struct{}

ExitPlanModeTool 规划模式退出工具 支持在规划模式完成后展示实施计划并请求用户确认

func (*ExitPlanModeTool) Description

func (t *ExitPlanModeTool) Description() string

func (*ExitPlanModeTool) Execute

func (t *ExitPlanModeTool) Execute(ctx context.Context, input map[string]interface{}, tc *tools.ToolContext) (interface{}, error)

func (*ExitPlanModeTool) InputSchema

func (t *ExitPlanModeTool) InputSchema() map[string]interface{}

func (*ExitPlanModeTool) Name

func (t *ExitPlanModeTool) Name() string

func (*ExitPlanModeTool) Prompt

func (t *ExitPlanModeTool) Prompt() string

type FileCount

type FileCount struct {
	File  string `json:"file"`
	Count int    `json:"count"`
}

type FilePlanManager

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

FilePlanManager 计划管理器实现

func NewFilePlanManager

func NewFilePlanManager(storageMgr StorageManager) *FilePlanManager

NewFilePlanManager 创建计划管理器

func (*FilePlanManager) DeletePlan

func (fpm *FilePlanManager) DeletePlan(planID string) error

DeletePlan 删除计划

func (*FilePlanManager) GetPlansByStatus

func (fpm *FilePlanManager) GetPlansByStatus(status string) ([]*PlanRecord, error)

GetPlansByStatus 按状态获取计划

func (*FilePlanManager) ListPlans

func (fpm *FilePlanManager) ListPlans() ([]*PlanRecord, error)

ListPlans 列出所有计划

func (*FilePlanManager) LoadPlan

func (fpm *FilePlanManager) LoadPlan(planID string) (*PlanRecord, error)

LoadPlan 加载计划

func (*FilePlanManager) StorePlan

func (fpm *FilePlanManager) StorePlan(plan *PlanRecord) error

StorePlan 存储计划

func (*FilePlanManager) UpdatePlanStatus

func (fpm *FilePlanManager) UpdatePlanStatus(planID string, status string) error

UpdatePlanStatus 更新计划状态

type FileStorageManager

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

FileStorageManager 基于文件的存储管理器实现

func NewFileStorageManager

func NewFileStorageManager() *FileStorageManager

NewFileStorageManager 创建基于文件的存储管理器

func (*FileStorageManager) Backup

func (fsm *FileStorageManager) Backup(backupPath string) error

Backup 备份数据

func (*FileStorageManager) DeleteData

func (fsm *FileStorageManager) DeleteData(key string) error

DeleteData 删除数据

func (*FileStorageManager) Exists

func (fsm *FileStorageManager) Exists(key string) bool

Exists 检查数据是否存在

func (*FileStorageManager) ListKeys

func (fsm *FileStorageManager) ListKeys(prefix string) ([]string, error)

ListKeys 列出所有键

func (*FileStorageManager) LoadData

func (fsm *FileStorageManager) LoadData(key string, target interface{}) error

LoadData 加载数据

func (*FileStorageManager) Restore

func (fsm *FileStorageManager) Restore(backupPath string) error

Restore 从备份恢复数据

func (*FileStorageManager) StoreData

func (fsm *FileStorageManager) StoreData(key string, data interface{}) error

StoreData 存储数据

type FileSubagentManager

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

FileSubagentManager 基于文件的子代理管理器实现

func NewFileSubagentManager

func NewFileSubagentManager() *FileSubagentManager

NewFileSubagentManager 创建基于文件的子代理管理器

func (*FileSubagentManager) CleanupSubagent

func (sm *FileSubagentManager) CleanupSubagent(taskID string) error

CleanupSubagent 清理子代理资源

func (*FileSubagentManager) GetSubagent

func (sm *FileSubagentManager) GetSubagent(taskID string) (*SubagentInstance, error)

GetSubagent 获取子代理信息

func (*FileSubagentManager) GetSubagentOutput

func (sm *FileSubagentManager) GetSubagentOutput(taskID string) (string, error)

GetSubagentOutput 获取子代理输出

func (*FileSubagentManager) ListSubagents

func (sm *FileSubagentManager) ListSubagents() ([]*SubagentInstance, error)

ListSubagents 列出所有子代理

func (*FileSubagentManager) ResumeSubagent

func (sm *FileSubagentManager) ResumeSubagent(taskID string) (*SubagentInstance, error)

ResumeSubagent 恢复子代理

func (*FileSubagentManager) StartSubagent

func (sm *FileSubagentManager) StartSubagent(ctx context.Context, config *SubagentConfig) (*SubagentInstance, error)

StartSubagent 启动子代理

func (*FileSubagentManager) StopSubagent

func (sm *FileSubagentManager) StopSubagent(taskID string) error

StopSubagent 停止子代理

type FileTaskManager

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

FileTaskManager 基于文件系统的任务管理器实现

func NewFileTaskManager

func NewFileTaskManager() *FileTaskManager

NewFileTaskManager 创建基于文件的任务管理器

func (*FileTaskManager) CleanupTask

func (tm *FileTaskManager) CleanupTask(taskID string) error

CleanupTask 清理任务相关文件

func (*FileTaskManager) GetTask

func (tm *FileTaskManager) GetTask(taskID string) (*TaskInfo, error)

GetTask 获取任务信息

func (*FileTaskManager) GetTaskOutput

func (tm *FileTaskManager) GetTaskOutput(taskID string, filter string, lines int) (string, string, error)

GetTaskOutput 获取任务输出

func (*FileTaskManager) GetTaskStatus

func (tm *FileTaskManager) GetTaskStatus(taskID string) (string, error)

GetTaskStatus 获取任务状态

func (*FileTaskManager) KillTask

func (tm *FileTaskManager) KillTask(taskID string, signal string, timeout int) error

KillTask 终止任务

func (*FileTaskManager) ListTasks

func (tm *FileTaskManager) ListTasks() ([]*TaskInfo, error)

ListTasks 列出所有任务

func (*FileTaskManager) StartTask

func (tm *FileTaskManager) StartTask(ctx context.Context, cmd string, opts *TaskOptions) (*TaskInfo, error)

StartTask 启动后台任务

type FileTodoManager

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

FileTodoManager 任务列表管理器实现

func NewFileTodoManager

func NewFileTodoManager(storageMgr StorageManager) *FileTodoManager

NewFileTodoManager 创建任务列表管理器

func (*FileTodoManager) BackupTodoLists

func (ftm *FileTodoManager) BackupTodoLists() (map[string]*TodoList, error)

BackupTodoLists 备份任务列表

func (*FileTodoManager) DeleteTodoList

func (ftm *FileTodoManager) DeleteTodoList(listName string) error

DeleteTodoList 删除任务列表

func (*FileTodoManager) ListTodoLists

func (ftm *FileTodoManager) ListTodoLists() ([]string, error)

ListTodoLists 列出所有任务列表

func (*FileTodoManager) LoadTodoList

func (ftm *FileTodoManager) LoadTodoList(listName string) (*TodoList, error)

LoadTodoList 加载任务列表

func (*FileTodoManager) RestoreTodoLists

func (ftm *FileTodoManager) RestoreTodoLists(backup map[string]*TodoList) error

RestoreTodoLists 恢复任务列表

func (*FileTodoManager) StoreTodoList

func (ftm *FileTodoManager) StoreTodoList(list *TodoList) error

StoreTodoList 存储任务列表

type GlobTool

type GlobTool struct{}

GlobTool 增强的文件搜索工具 支持模式匹配文件搜索功能

func (*GlobTool) Description

func (t *GlobTool) Description() string

func (*GlobTool) Execute

func (t *GlobTool) Execute(ctx context.Context, input map[string]interface{}, tc *tools.ToolContext) (interface{}, error)

func (*GlobTool) InputSchema

func (t *GlobTool) InputSchema() map[string]interface{}

func (*GlobTool) Name

func (t *GlobTool) Name() string

func (*GlobTool) Prompt

func (t *GlobTool) Prompt() string

type GrepMatch

type GrepMatch struct {
	File    string `json:"file"`
	Line    int    `json:"line"`
	Content string `json:"content"`
}

type GrepResult

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

数据结构

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 map[string]interface{}, tc *tools.ToolContext) (interface{}, error)

func (*GrepTool) InputSchema

func (t *GrepTool) InputSchema() map[string]interface{}

func (*GrepTool) Name

func (t *GrepTool) Name() string

func (*GrepTool) Prompt

func (t *GrepTool) Prompt() string

type HttpRequestTool

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

HttpRequestTool HTTP请求工具 设计参考: DeepAgents deepagents-cli/tools.py:http_request

func (*HttpRequestTool) Description

func (t *HttpRequestTool) Description() string

func (*HttpRequestTool) Execute

func (t *HttpRequestTool) Execute(ctx context.Context, input map[string]interface{}, tc *tools.ToolContext) (interface{}, error)

func (*HttpRequestTool) InputSchema

func (t *HttpRequestTool) InputSchema() map[string]interface{}

func (*HttpRequestTool) Name

func (t *HttpRequestTool) Name() string

func (*HttpRequestTool) Prompt

func (t *HttpRequestTool) Prompt() string

type KillShellTool

type KillShellTool struct{}

KillShellTool 后台shell终止工具 支持终止后台运行的shell进程

func (*KillShellTool) Description

func (t *KillShellTool) Description() string

func (*KillShellTool) Execute

func (t *KillShellTool) Execute(ctx context.Context, input map[string]interface{}, tc *tools.ToolContext) (interface{}, error)

func (*KillShellTool) InputSchema

func (t *KillShellTool) InputSchema() map[string]interface{}

func (*KillShellTool) Name

func (t *KillShellTool) Name() string

func (*KillShellTool) Prompt

func (t *KillShellTool) Prompt() string

type MockSandbox

type MockSandbox struct {
	sandbox.MockSandbox
}

MockSandbox 简单的沙箱模拟实现

func NewMockSandbox

func NewMockSandbox() *MockSandbox

NewMockSandbox 创建新的模拟沙箱

func (*MockSandbox) SafeExecute

func (m *MockSandbox) SafeExecute(ctx context.Context, cmd string) error

SafeExecute 模拟安全执行

type PlanManager

type PlanManager interface {
	// StorePlan 存储计划
	StorePlan(plan *PlanRecord) error

	// LoadPlan 加载计划
	LoadPlan(planID string) (*PlanRecord, error)

	// UpdatePlanStatus 更新计划状态
	UpdatePlanStatus(planID string, status string) error

	// GetPlansByStatus 按状态获取计划
	GetPlansByStatus(status string) ([]*PlanRecord, error)

	// ListPlans 列出所有计划
	ListPlans() ([]*PlanRecord, error)

	// DeletePlan 删除计划
	DeletePlan(planID string) error
}

PlanManager 计划管理器接口

var GlobalPlanManager PlanManager

func GetGlobalPlanManager

func GetGlobalPlanManager() PlanManager

GetGlobalPlanManager 获取全局计划管理器

type PlanRecord

type PlanRecord struct {
	ID                   string                 `json:"id"`
	Content              string                 `json:"content"`
	EstimatedDuration    string                 `json:"estimated_duration,omitempty"`
	Dependencies         []string               `json:"dependencies,omitempty"`
	Risks                []string               `json:"risks,omitempty"`
	SuccessCriteria      []string               `json:"success_criteria,omitempty"`
	ConfirmationRequired bool                   `json:"confirmation_required"`
	Status               string                 `json:"status"` // "pending_approval", "approved", "rejected", "completed"
	CreatedAt            time.Time              `json:"created_at"`
	UpdatedAt            time.Time              `json:"updated_at"`
	ApprovedAt           *time.Time             `json:"approved_at,omitempty"`
	AgentID              string                 `json:"agent_id"`
	SessionID            string                 `json:"session_id"`
	Metadata             map[string]interface{} `json:"metadata,omitempty"`
}

PlanRecord 计划记录

type ReadTool

type ReadTool struct{}

ReadTool 增强的文件读取工具 兼容标准Read工具功能

func (*ReadTool) Description

func (t *ReadTool) Description() string

func (*ReadTool) Execute

func (t *ReadTool) Execute(ctx context.Context, input map[string]interface{}, tc *tools.ToolContext) (interface{}, error)

func (*ReadTool) InputSchema

func (t *ReadTool) InputSchema() map[string]interface{}

func (*ReadTool) Name

func (t *ReadTool) Name() string

func (*ReadTool) Prompt

func (t *ReadTool) Prompt() string

type RealFS

type RealFS struct{}

RealFS 使用真实文件系统

func (*RealFS) Glob

func (rfs *RealFS) Glob(ctx context.Context, pattern string, opts *sandbox.GlobOptions) ([]string, error)

func (*RealFS) IsInside

func (rfs *RealFS) IsInside(path string) bool

func (*RealFS) Read

func (rfs *RealFS) Read(ctx context.Context, path string) (string, error)

func (*RealFS) Resolve

func (rfs *RealFS) Resolve(path string) string

func (*RealFS) Stat

func (rfs *RealFS) Stat(ctx context.Context, path string) (sandbox.FileInfo, error)

func (*RealFS) Temp

func (rfs *RealFS) Temp(name string) string

func (*RealFS) Write

func (rfs *RealFS) Write(ctx context.Context, path string, content string) error

type RealSandbox

type RealSandbox struct{}

RealSandbox 使用真实文件系统的沙箱(仅用于测试)

func (*RealSandbox) Dispose

func (rs *RealSandbox) Dispose() error

func (*RealSandbox) Exec

func (*RealSandbox) FS

func (rs *RealSandbox) FS() sandbox.SandboxFS

func (*RealSandbox) Kind

func (rs *RealSandbox) Kind() string

func (*RealSandbox) Unwatch

func (rs *RealSandbox) Unwatch(watchID string) error

func (*RealSandbox) Watch

func (rs *RealSandbox) Watch(paths []string, listener sandbox.FileChangeListener) (string, error)

func (*RealSandbox) WorkDir

func (rs *RealSandbox) WorkDir() string

type ResourceUsage

type ResourceUsage struct {
	CPU    float64 `json:"cpu_percent"`   // CPU使用率百分比
	Memory int64   `json:"memory_bytes"`  // 内存使用量(字节)
	DiskIO int64   `json:"disk_io_bytes"` // 磁盘IO(字节)
}

ResourceUsage 进程资源使用情况

type SemanticSearchTool

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

SemanticSearchTool 基于 SemanticMemory 的语义检索工具。 输入:

{
  "query": string,
  "top_k": number (可选, 默认使用 SemanticMemoryConfig.TopK),
  "metadata": object (可选, 如 {"user_id":"alice","project_id":"demo"})
}

输出:

[
  {"id": "...", "score": 0.87, "metadata": {...}},
  ...
]

func (*SemanticSearchTool) Description

func (t *SemanticSearchTool) Description() string

func (*SemanticSearchTool) Execute

func (t *SemanticSearchTool) Execute(ctx context.Context, input map[string]interface{}, tc *tools.ToolContext) (interface{}, error)

func (*SemanticSearchTool) InputSchema

func (t *SemanticSearchTool) InputSchema() map[string]interface{}

func (*SemanticSearchTool) Name

func (t *SemanticSearchTool) Name() string

func (*SemanticSearchTool) Prompt

func (t *SemanticSearchTool) Prompt() string

type SkillTool

type SkillTool struct{}

SkillTool 通用的 Skill 执行工具

注意:本工具不会自动注册到默认内置工具列表中,需要在 Agent 模板中显式声明, 并在 ToolContext.Services 中注入 *skills.Runtime 实例,键名为 "skills_runtime"。

func (*SkillTool) Description

func (t *SkillTool) Description() string

func (*SkillTool) Execute

func (t *SkillTool) Execute(ctx context.Context, input map[string]interface{}, tc *tools.ToolContext) (interface{}, error)

func (*SkillTool) InputSchema

func (t *SkillTool) InputSchema() map[string]interface{}

func (*SkillTool) Name

func (t *SkillTool) Name() string

func (*SkillTool) Prompt

func (t *SkillTool) Prompt() string

type StorageManager

type StorageManager interface {
	// StoreData 存储数据
	StoreData(key string, data interface{}) error

	// LoadData 加载数据
	LoadData(key string, target interface{}) error

	// DeleteData 删除数据
	DeleteData(key string) error

	// Exists 检查数据是否存在
	Exists(key string) bool

	// ListKeys 列出所有键
	ListKeys(prefix string) ([]string, error)

	// Backup 备份数据
	Backup(backupPath string) error

	// Restore 从备份恢复数据
	Restore(backupPath string) error
}

StorageManager 存储管理器接口

var GlobalStorageManager StorageManager

全局存储管理器实例

func GetGlobalStorageManager

func GetGlobalStorageManager() StorageManager

GetGlobalStorageManager 获取全局存储管理器

type SubagentConfig

type SubagentConfig struct {
	ID          string            `json:"id"`
	Type        string            `json:"type"` // "general-purpose", "Explore", "Plan", "statusline-setup"
	Prompt      string            `json:"prompt"`
	Model       string            `json:"model,omitempty"`
	WorkDir     string            `json:"work_dir,omitempty"`
	Env         map[string]string `json:"env,omitempty"`
	Timeout     time.Duration     `json:"timeout,omitempty"`
	MaxTokens   int               `json:"max_tokens,omitempty"`
	Temperature float64           `json:"temperature,omitempty"`
	Metadata    map[string]string `json:"metadata,omitempty"`
}

SubagentConfig 子代理配置

type SubagentInstance

type SubagentInstance struct {
	ID            string                 `json:"id"`
	Type          string                 `json:"type"`
	Status        string                 `json:"status"` // "starting", "running", "completed", "failed", "stopped"
	PID           int                    `json:"pid,omitempty"`
	Command       string                 `json:"command"`
	Config        *SubagentConfig        `json:"config"`
	StartTime     time.Time              `json:"start_time"`
	EndTime       *time.Time             `json:"end_time,omitempty"`
	Duration      time.Duration          `json:"duration"`
	Output        string                 `json:"output"`
	Error         string                 `json:"error,omitempty"`
	ExitCode      int                    `json:"exit_code,omitempty"`
	LastUpdate    time.Time              `json:"last_update"`
	Metadata      map[string]string      `json:"metadata,omitempty"`
	ResourceUsage *SubagentResourceUsage `json:"resource_usage,omitempty"`
}

SubagentInstance 子代理实例

type SubagentManager

type SubagentManager interface {
	// StartSubagent 启动子代理
	StartSubagent(ctx context.Context, config *SubagentConfig) (*SubagentInstance, error)

	// ResumeSubagent 恢复子代理
	ResumeSubagent(taskID string) (*SubagentInstance, error)

	// GetSubagent 获取子代理信息
	GetSubagent(taskID string) (*SubagentInstance, error)

	// StopSubagent 停止子代理
	StopSubagent(taskID string) error

	// ListSubagents 列出所有子代理
	ListSubagents() ([]*SubagentInstance, error)

	// GetSubagentOutput 获取子代理输出
	GetSubagentOutput(taskID string) (string, error)

	// CleanupSubagent 清理子代理资源
	CleanupSubagent(taskID string) error
}

SubagentManager 子代理管理器接口

var GlobalSubagentManager SubagentManager

全局子代理管理器实例

func GetGlobalSubagentManager

func GetGlobalSubagentManager() SubagentManager

GetGlobalSubagentManager 获取全局子代理管理器

type SubagentResourceUsage

type SubagentResourceUsage struct {
	MemoryMB   float64 `json:"memory_mb"`
	CPUPercent float64 `json:"cpu_percent"`
	DiskMB     float64 `json:"disk_mb"`
	NetworkMB  float64 `json:"network_mb"`
}

SubagentResourceUsage 子代理资源使用情况

type TaskDefinition

type TaskDefinition struct {
	ID          string                 `json:"id"`
	Description string                 `json:"description"`
	Subagent    string                 `json:"subagent"`
	Prompt      string                 `json:"prompt"`
	Model       string                 `json:"model,omitempty"`
	Resume      string                 `json:"resume,omitempty"`
	CreatedAt   time.Time              `json:"createdAt"`
	StartedAt   *time.Time             `json:"startedAt,omitempty"`
	CompletedAt *time.Time             `json:"completedAt,omitempty"`
	Status      string                 `json:"status"` // "created", "running", "completed", "failed"
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
}

TaskDefinition 任务定义

type TaskExecution

type TaskExecution struct {
	TaskID    string                 `json:"task_id"`
	Subagent  string                 `json:"subagent"`
	Model     string                 `json:"model"`
	Status    string                 `json:"status"`
	Result    interface{}            `json:"result,omitempty"`
	Error     string                 `json:"error,omitempty"`
	StartTime time.Time              `json:"start_time"`
	EndTime   *time.Time             `json:"end_time,omitempty"`
	Duration  time.Duration          `json:"duration"`
	Metadata  map[string]interface{} `json:"metadata,omitempty"`
}

TaskExecution 任务执行结果

type TaskInfo

type TaskInfo struct {
	ID         string            `json:"id"`
	Command    string            `json:"command"`
	PID        int               `json:"pid"`
	Status     string            `json:"status"` // "running", "completed", "failed", "killed"
	ExitCode   int               `json:"exit_code"`
	StartTime  time.Time         `json:"start_time"`
	EndTime    *time.Time        `json:"end_time,omitempty"`
	Duration   time.Duration     `json:"duration"`
	WorkDir    string            `json:"work_dir"`
	Shell      string            `json:"shell"`
	Options    *TaskOptions      `json:"options"`
	Metadata   map[string]string `json:"metadata"`
	LastUpdate time.Time         `json:"last_update"`
}

TaskInfo 任务信息

type TaskManager

type TaskManager interface {
	// StartTask 启动后台任务
	StartTask(ctx context.Context, cmd string, opts *TaskOptions) (*TaskInfo, error)

	// GetTask 获取任务信息
	GetTask(taskID string) (*TaskInfo, error)

	// GetTaskOutput 获取任务输出
	GetTaskOutput(taskID string, filter string, lines int) (string, string, error)

	// KillTask 终止任务
	KillTask(taskID string, signal string, timeout int) error

	// ListTasks 列出所有任务
	ListTasks() ([]*TaskInfo, error)

	// GetTaskStatus 获取任务状态
	GetTaskStatus(taskID string) (string, error)

	// CleanupTask 清理任务相关文件
	CleanupTask(taskID string) error
}

TaskManager 后台任务管理器接口

var GlobalTaskManager TaskManager

全局任务管理器实例

func GetGlobalTaskManager

func GetGlobalTaskManager() TaskManager

GetGlobalTaskManager 获取全局任务管理器

type TaskOptions

type TaskOptions struct {
	WorkDir       string            `json:"work_dir"`
	Env           map[string]string `json:"env"`
	Timeout       time.Duration     `json:"timeout"`
	Background    bool              `json:"background"`
	Shell         string            `json:"shell"`
	CaptureOutput bool              `json:"capture_output"`
	OutputDir     string            `json:"output_dir"`
}

TaskOptions 任务启动选项

type TaskTool

type TaskTool struct{}

TaskTool 专门代理启动工具 支持启动专门的代理来处理复杂的多步骤任务

func (*TaskTool) Description

func (t *TaskTool) Description() string

func (*TaskTool) Execute

func (t *TaskTool) Execute(ctx context.Context, input map[string]interface{}, tc *tools.ToolContext) (interface{}, error)

func (*TaskTool) InputSchema

func (t *TaskTool) InputSchema() map[string]interface{}

func (*TaskTool) Name

func (t *TaskTool) Name() string

func (*TaskTool) Prompt

func (t *TaskTool) Prompt() string

type TestHelper

type TestHelper struct {
	T       *testing.T
	TmpDir  string
	Context context.Context
	Cleanup []func() // 清理函数列表
}

TestHelper 测试辅助工具

func NewTestHelper

func NewTestHelper(t *testing.T) *TestHelper

NewTestHelper 创建测试辅助工具

func (*TestHelper) AddCleanup

func (th *TestHelper) AddCleanup(cleanup func())

AddCleanup 添加清理函数

func (*TestHelper) CleanupAll

func (th *TestHelper) CleanupAll()

CleanupAll 执行所有清理

func (*TestHelper) CreateTempDir

func (th *TestHelper) CreateTempDir(name string) string

CreateTempDir 创建临时目录

func (*TestHelper) CreateTempFile

func (th *TestHelper) CreateTempFile(name, content string) string

CreateTempFile 创建临时文件

func (*TestHelper) FileExists

func (th *TestHelper) FileExists(path string) bool

FileExists 检查文件是否存在

func (*TestHelper) GetTestDataPath

func (th *TestHelper) GetTestDataPath(name string) string

GetTestDataPath 获取测试数据文件路径

func (*TestHelper) ReadFile

func (th *TestHelper) ReadFile(path string) string

ReadFile 读取文件内容

type TodoItem

type TodoItem struct {
	ID          string                 `json:"id"`
	Content     string                 `json:"content"`
	Status      string                 `json:"status"` // "pending", "in_progress", "completed"
	ActiveForm  string                 `json:"activeForm"`
	Priority    int                    `json:"priority,omitempty"`
	CreatedAt   time.Time              `json:"createdAt"`
	UpdatedAt   time.Time              `json:"updatedAt"`
	CompletedAt *time.Time             `json:"completedAt,omitempty"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
}

TodoItem 单个任务项

type TodoList

type TodoList struct {
	ID        string                 `json:"id"`
	Name      string                 `json:"name"`
	Todos     []TodoItem             `json:"todos"`
	CreatedAt time.Time              `json:"createdAt"`
	UpdatedAt time.Time              `json:"updatedAt"`
	Metadata  map[string]interface{} `json:"metadata,omitempty"`
}

TodoList 任务列表

type TodoManager

type TodoManager interface {
	// StoreTodoList 存储任务列表
	StoreTodoList(list *TodoList) error

	// LoadTodoList 加载任务列表
	LoadTodoList(listName string) (*TodoList, error)

	// ListTodoLists 列出所有任务列表
	ListTodoLists() ([]string, error)

	// DeleteTodoList 删除任务列表
	DeleteTodoList(listName string) error

	// BackupTodoLists 备份任务列表
	BackupTodoLists() (map[string]*TodoList, error)

	// RestoreTodoLists 恢复任务列表
	RestoreTodoLists(backup map[string]*TodoList) error
}

TodoManager 任务列表管理器接口

var GlobalTodoManager TodoManager

func GetGlobalTodoManager

func GetGlobalTodoManager() TodoManager

GetGlobalTodoManager 获取全局任务列表管理器

type TodoWriteTool

type TodoWriteTool struct{}

TodoWriteTool 任务管理工具 支持创建和管理结构化任务列表

func (*TodoWriteTool) Description

func (t *TodoWriteTool) Description() string

func (*TodoWriteTool) Execute

func (t *TodoWriteTool) Execute(ctx context.Context, input map[string]interface{}, tc *tools.ToolContext) (interface{}, error)

func (*TodoWriteTool) InputSchema

func (t *TodoWriteTool) InputSchema() map[string]interface{}

func (*TodoWriteTool) Name

func (t *TodoWriteTool) Name() string

func (*TodoWriteTool) Prompt

func (t *TodoWriteTool) Prompt() string

type WebSearchTool

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

WebSearchTool 网络搜索工具 (使用 Tavily API) 设计参考: DeepAgents deepagents-cli/tools.py:web_search

func (*WebSearchTool) Description

func (t *WebSearchTool) Description() string

func (*WebSearchTool) Execute

func (t *WebSearchTool) Execute(ctx context.Context, input map[string]interface{}, tc *tools.ToolContext) (interface{}, error)

func (*WebSearchTool) InputSchema

func (t *WebSearchTool) InputSchema() map[string]interface{}

func (*WebSearchTool) Name

func (t *WebSearchTool) Name() string

func (*WebSearchTool) Prompt

func (t *WebSearchTool) Prompt() string

type WriteTool

type WriteTool struct{}

WriteTool 增强的文件写入工具 兼容标准Write工具功能

func (*WriteTool) Description

func (t *WriteTool) Description() string

func (*WriteTool) Execute

func (t *WriteTool) Execute(ctx context.Context, input map[string]interface{}, tc *tools.ToolContext) (interface{}, error)

func (*WriteTool) InputSchema

func (t *WriteTool) InputSchema() map[string]interface{}

func (*WriteTool) Name

func (t *WriteTool) Name() string

func (*WriteTool) Prompt

func (t *WriteTool) Prompt() string

Jump to

Keyboard shortcuts

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