From 76d263aba3b94ae1f10b0b7409d19500e49c96b7 Mon Sep 17 00:00:00 2001 From: candywater Date: Sun, 22 Feb 2026 03:38:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20fix=20merge=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/picoclaw/main.go | 6 +++--- pkg/agent/loop.go | 2 +- pkg/config/config.go | 2 +- pkg/config/defaults.go | 1 + pkg/tools/shell.go | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/picoclaw/main.go b/cmd/picoclaw/main.go index df0db7d67..4276da09d 100644 --- a/cmd/picoclaw/main.go +++ b/cmd/picoclaw/main.go @@ -536,7 +536,7 @@ func gatewayCmd() { // Setup cron tool and service execTimeout := time.Duration(cfg.Tools.Cron.ExecTimeoutMinutes) * time.Minute - cronService := setupCronTool(agentLoop, msgBus, cfg.WorkspacePath(), cfg.Agents.Defaults.RestrictToWorkspace, execTimeout, cfg.Agents.Defaults.AllowPatterns) + cronService := setupCronTool(agentLoop, msgBus, cfg.WorkspacePath(), cfg.Agents.Defaults.RestrictToWorkspace, execTimeout, cfg) heartbeatService := heartbeat.NewHeartbeatService( cfg.WorkspacePath(), @@ -961,14 +961,14 @@ func getConfigPath() string { return filepath.Join(home, ".picoclaw", "config.json") } -func setupCronTool(agentLoop *agent.AgentLoop, msgBus *bus.MessageBus, workspace string, restrict bool, execTimeout time.Duration, allowPatterns []string) *cron.CronService { +func setupCronTool(agentLoop *agent.AgentLoop, msgBus *bus.MessageBus, workspace string, restrict bool, execTimeout time.Duration, config *config.Config) *cron.CronService { cronStorePath := filepath.Join(workspace, "cron", "jobs.json") // Create cron service cronService := cron.NewCronService(cronStorePath, nil) // Create and register CronTool - cronTool := tools.NewCronTool(cronService, agentLoop, msgBus, workspace, restrict, execTimeout, allowPatterns...) + cronTool := tools.NewCronTool(cronService, agentLoop, msgBus, workspace, restrict, execTimeout, config) agentLoop.RegisterTool(cronTool) // Set the onJob handler diff --git a/pkg/agent/loop.go b/pkg/agent/loop.go index 7a95e59f1..188cc1fb3 100644 --- a/pkg/agent/loop.go +++ b/pkg/agent/loop.go @@ -65,7 +65,7 @@ func createToolRegistry(workspace string, restrict bool, cfg *config.Config, msg registry.Register(tools.NewAppendFileTool(workspace, restrict)) // Shell execution - registry.Register(tools.NewExecTool(workspace, restrict, cfg.Agents.Defaults.AllowPatterns...)) + registry.Register(tools.NewExecToolWithConfig(workspace, restrict, cfg)) if searchTool := tools.NewWebSearchTool(tools.WebSearchToolOptions{ BraveAPIKey: cfg.Tools.Web.Brave.APIKey, diff --git a/pkg/config/config.go b/pkg/config/config.go index 6a2691cae..6e1d3c489 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -169,7 +169,7 @@ type SessionConfig struct { type AgentDefaults struct { Workspace string `json:"workspace" env:"PICOCLAW_AGENTS_DEFAULTS_WORKSPACE"` RestrictToWorkspace bool `json:"restrict_to_workspace" env:"PICOCLAW_AGENTS_DEFAULTS_RESTRICT_TO_WORKSPACE"` - AllowPatterns []string `json:"allow_patterns" env:"PICOCLAW_AGENTS_DEFAULTS_ALLOW_PATTERNS" envSeparator:","` + AllowPatterns []string `json:"allow_patterns" env:"PICOCLAW_AGENTS_DEFAULTS_ALLOW_PATTERNS" envSeparator:","` Provider string `json:"provider" env:"PICOCLAW_AGENTS_DEFAULTS_PROVIDER"` Model string `json:"model" env:"PICOCLAW_AGENTS_DEFAULTS_MODEL"` ModelFallbacks []string `json:"model_fallbacks,omitempty"` diff --git a/pkg/config/defaults.go b/pkg/config/defaults.go index 7654326e7..4f2b2c2eb 100644 --- a/pkg/config/defaults.go +++ b/pkg/config/defaults.go @@ -12,6 +12,7 @@ func DefaultConfig() *Config { Defaults: AgentDefaults{ Workspace: "~/.picoclaw/workspace", RestrictToWorkspace: true, + AllowPatterns: []string{}, Provider: "", Model: "glm-4.7", MaxTokens: 8192, diff --git a/pkg/tools/shell.go b/pkg/tools/shell.go index b0b188132..17ce529b6 100644 --- a/pkg/tools/shell.go +++ b/pkg/tools/shell.go @@ -102,7 +102,7 @@ func NewExecToolWithConfig(workingDir string, restrict bool, config *config.Conf denyPatterns = append(denyPatterns, defaultDenyPatterns...) } - var allowPatterns []string = config.AgentDefaults.AllowPatterns + var allowPatterns []string = config.Agents.Defaults.AllowPatterns var allowRegex []*regexp.Regexp if len(allowPatterns) > 0 { allowRegex = make([]*regexp.Regexp, 0, len(allowPatterns))