From e316ac74c16c2fd629879679d17af553e1ce3369 Mon Sep 17 00:00:00 2001 From: lxowalle Date: Wed, 4 Mar 2026 18:11:54 +0800 Subject: [PATCH] enable list_dir tool, delete unused code, add env for ToolConfig --- config/config.example.json | 2 +- pkg/config/config.go | 42 +++++++++++++++++--------------------- pkg/config/defaults.go | 8 +------- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/config/config.example.json b/config/config.example.json index 34ea6fdbb..9f0dd91f9 100644 --- a/config/config.example.json +++ b/config/config.example.json @@ -381,7 +381,7 @@ "enabled": true }, "list_dir": { - "enabled": false + "enabled": true }, "message": { "enabled": true diff --git a/pkg/config/config.go b/pkg/config/config.go index 0b29653f7..0c51349d0 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -562,12 +562,12 @@ type GLMSearchConfig struct { } type WebToolsConfig struct { - ToolConfig - Brave BraveConfig `json:"brave"` - Tavily TavilyConfig `json:"tavily"` - DuckDuckGo DuckDuckGoConfig `json:"duckduckgo"` - Perplexity PerplexityConfig `json:"perplexity"` - GLMSearch GLMSearchConfig `json:"glm_search"` + ToolConfig ` env:"PICOCLAW_TOOLS_WEB_"` + Brave BraveConfig ` json:"brave"` + Tavily TavilyConfig ` json:"tavily"` + DuckDuckGo DuckDuckGoConfig ` json:"duckduckgo"` + Perplexity PerplexityConfig ` json:"perplexity"` + GLMSearch GLMSearchConfig ` json:"glm_search"` // Proxy is an optional proxy URL for web tools (http/https/socks5/socks5h). // For authenticated proxies, prefer HTTP_PROXY/HTTPS_PROXY env vars instead of embedding credentials in config. Proxy string `json:"proxy,omitempty" env:"PICOCLAW_TOOLS_WEB_PROXY"` @@ -575,28 +575,28 @@ type WebToolsConfig struct { } type CronToolsConfig struct { - ToolConfig - ExecTimeoutMinutes int `json:"exec_timeout_minutes" env:"PICOCLAW_TOOLS_CRON_EXEC_TIMEOUT_MINUTES"` // 0 means no timeout + ToolConfig ` env:"PICOCLAW_TOOLS_CRON_"` + ExecTimeoutMinutes int `env:"PICOCLAW_TOOLS_CRON_EXEC_TIMEOUT_MINUTES" json:"exec_timeout_minutes"` // 0 means no timeout } type ExecConfig struct { - ToolConfig - EnableDenyPatterns bool `json:"enable_deny_patterns" env:"PICOCLAW_TOOLS_EXEC_ENABLE_DENY_PATTERNS"` - CustomDenyPatterns []string `json:"custom_deny_patterns" env:"PICOCLAW_TOOLS_EXEC_CUSTOM_DENY_PATTERNS"` - CustomAllowPatterns []string `json:"custom_allow_patterns" env:"PICOCLAW_TOOLS_EXEC_CUSTOM_ALLOW_PATTERNS"` + ToolConfig ` env:"PICOCLAW_TOOLS_EXEC_"` + EnableDenyPatterns bool `env:"PICOCLAW_TOOLS_EXEC_ENABLE_DENY_PATTERNS" json:"enable_deny_patterns"` + CustomDenyPatterns []string `env:"PICOCLAW_TOOLS_EXEC_CUSTOM_DENY_PATTERNS" json:"custom_deny_patterns"` + CustomAllowPatterns []string `env:"PICOCLAW_TOOLS_EXEC_CUSTOM_ALLOW_PATTERNS" json:"custom_allow_patterns"` } type SkillsToolsConfig struct { - ToolConfig - Registries SkillsRegistriesConfig `json:"registries"` - MaxConcurrentSearches int `json:"max_concurrent_searches" env:"PICOCLAW_SKILLS_MAX_CONCURRENT_SEARCHES"` - SearchCache SearchCacheConfig `json:"search_cache"` + ToolConfig ` env:"PICOCLAW_TOOLS_SKILLS_"` + Registries SkillsRegistriesConfig ` json:"registries"` + MaxConcurrentSearches int `env:"PICOCLAW_TOOLS_SKILLS_MAX_CONCURRENT_SEARCHES" json:"max_concurrent_searches"` + SearchCache SearchCacheConfig ` json:"search_cache"` } type MediaCleanupConfig struct { - ToolConfig - MaxAge int `json:"max_age_minutes" env:"PICOCLAW_MEDIA_CLEANUP_MAX_AGE"` - Interval int `json:"interval_minutes" env:"PICOCLAW_MEDIA_CLEANUP_INTERVAL"` + ToolConfig ` env:"PICOCLAW_MEDIA_CLEANUP_"` + MaxAge int `env:"PICOCLAW_MEDIA_CLEANUP_MAX_AGE" json:"max_age_minutes"` + Interval int `env:"PICOCLAW_MEDIA_CLEANUP_INTERVAL" json:"interval_minutes"` } type ToolsConfig struct { @@ -609,7 +609,6 @@ type ToolsConfig struct { MediaCleanup MediaCleanupConfig `json:"media_cleanup"` MCP MCPConfig `json:"mcp"` AppendFile ToolConfig `json:"append_file"` - CronTool ToolConfig `json:"cron_tool"` EditFile ToolConfig `json:"edit_file"` ExecTool ToolConfig `json:"exec_tool"` FindSkills ToolConfig `json:"find_skills"` @@ -622,7 +621,6 @@ type ToolsConfig struct { SPI ToolConfig `json:"spi"` Subagent ToolConfig `json:"subagent"` WebFetch ToolConfig `json:"web_fetch"` - WebSearch ToolConfig `json:"web_search"` WriteFile ToolConfig `json:"write_file"` } @@ -893,8 +891,6 @@ func (t *ToolsConfig) IsToolEnabled(name string) bool { return t.Subagent.Enabled case "web_fetch": return t.WebFetch.Enabled - case "web_search": - return t.WebSearch.Enabled case "write_file": return t.WriteFile.Enabled default: diff --git a/pkg/config/defaults.go b/pkg/config/defaults.go index 91e2849bd..a2e024705 100644 --- a/pkg/config/defaults.go +++ b/pkg/config/defaults.go @@ -391,9 +391,6 @@ func DefaultConfig() *Config { AppendFile: ToolConfig{ Enabled: true, }, - CronTool: ToolConfig{ - Enabled: true, - }, EditFile: ToolConfig{ Enabled: true, }, @@ -410,7 +407,7 @@ func DefaultConfig() *Config { Enabled: true, }, ListDir: ToolConfig{ - Enabled: false, + Enabled: true, }, Message: ToolConfig{ Enabled: true, @@ -430,9 +427,6 @@ func DefaultConfig() *Config { WebFetch: ToolConfig{ Enabled: true, }, - WebSearch: ToolConfig{ - Enabled: true, - }, WriteFile: ToolConfig{ Enabled: true, },