* Fix fmt

This commit is contained in:
lxowalle 2026-02-27 03:31:09 +08:00
parent 2b9e74007f
commit cadf39c9ef
7 changed files with 33 additions and 23 deletions

View file

@ -452,7 +452,7 @@ type PerplexityConfig struct {
} }
type WebToolsConfig struct { type WebToolsConfig struct {
Enabled bool `json:"enabled" env:"PICOCLAW_TOOLS_WEB_ENABLED"` Enabled bool `json:"enabled" env:"PICOCLAW_TOOLS_WEB_ENABLED"`
Brave BraveConfig `json:"brave"` Brave BraveConfig `json:"brave"`
Tavily TavilyConfig `json:"tavily"` Tavily TavilyConfig `json:"tavily"`
DuckDuckGo DuckDuckGoConfig `json:"duckduckgo"` DuckDuckGo DuckDuckGoConfig `json:"duckduckgo"`
@ -463,7 +463,7 @@ type WebToolsConfig struct {
} }
type CronToolConfig struct { type CronToolConfig struct {
Enabled bool `json:"enabled" env:"PICOCLAW_TOOLS_CRON_ENABLED"` Enabled bool `json:"enabled" env:"PICOCLAW_TOOLS_CRON_ENABLED"`
ExecTimeoutMinutes int `json:"exec_timeout_minutes" env:"PICOCLAW_TOOLS_CRON_EXEC_TIMEOUT_MINUTES"` // 0 means no timeout ExecTimeoutMinutes int `json:"exec_timeout_minutes" env:"PICOCLAW_TOOLS_CRON_EXEC_TIMEOUT_MINUTES"` // 0 means no timeout
} }
@ -472,7 +472,7 @@ type ToolConfig struct {
} }
type ExecConfig struct { type ExecConfig struct {
Enabled bool `json:"enabled" env:"PICOCLAW_TOOLS_EXEC_ENABLED"` Enabled bool `json:"enabled" env:"PICOCLAW_TOOLS_EXEC_ENABLED"`
EnableDenyPatterns bool `json:"enable_deny_patterns" env:"PICOCLAW_TOOLS_EXEC_ENABLE_DENY_PATTERNS"` 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"` CustomDenyPatterns []string `json:"custom_deny_patterns" env:"PICOCLAW_TOOLS_EXEC_CUSTOM_DENY_PATTERNS"`
} }
@ -485,17 +485,17 @@ type ToolsConfig struct {
Cron CronToolConfig `json:"cron"` Cron CronToolConfig `json:"cron"`
// File tools // File tools
ReadFile ToolConfig `json:"read_file" env:"PICOCLAW_TOOLS_READ_FILE_ENABLED"` ReadFile ToolConfig `json:"read_file" env:"PICOCLAW_TOOLS_READ_FILE_ENABLED"`
WriteFile ToolConfig `json:"write_file" env:"PICOCLAW_TOOLS_WRITE_FILE_ENABLED"` WriteFile ToolConfig `json:"write_file" env:"PICOCLAW_TOOLS_WRITE_FILE_ENABLED"`
EditFile ToolConfig `json:"edit_file" env:"PICOCLAW_TOOLS_EDIT_FILE_ENABLED"` EditFile ToolConfig `json:"edit_file" env:"PICOCLAW_TOOLS_EDIT_FILE_ENABLED"`
AppendFile ToolConfig `json:"append_file" env:"PICOCLAW_TOOLS_APPEND_FILE_ENABLED"` AppendFile ToolConfig `json:"append_file" env:"PICOCLAW_TOOLS_APPEND_FILE_ENABLED"`
ListDir ToolConfig `json:"list_dir" env:"PICOCLAW_TOOLS_LIST_DIR_ENABLED"` ListDir ToolConfig `json:"list_dir" env:"PICOCLAW_TOOLS_LIST_DIR_ENABLED"`
// Exec tool // Exec tool
Exec ExecConfig `json:"exec"` Exec ExecConfig `json:"exec"`
// Skills tools // Skills tools
FindSkills ToolConfig `json:"find_skills" env:"PICOCLAW_TOOLS_FIND_SKILLS_ENABLED"` FindSkills ToolConfig `json:"find_skills" env:"PICOCLAW_TOOLS_FIND_SKILLS_ENABLED"`
InstallSkill ToolConfig `json:"install_skill" env:"PICOCLAW_TOOLS_INSTALL_SKILL_ENABLED"` InstallSkill ToolConfig `json:"install_skill" env:"PICOCLAW_TOOLS_INSTALL_SKILL_ENABLED"`
// Subagent tools // Subagent tools

View file

@ -137,7 +137,9 @@ func (t *CronTool) addJob(args map[string]any) *common.ToolResult {
t.mu.RUnlock() t.mu.RUnlock()
if channel == "" || chatID == "" { if channel == "" || chatID == "" {
return common.ErrorResult("no session context (channel/chat_id not set). Use this tool in an active conversation.") return common.ErrorResult(
"no session context (channel/chat_id not set). Use this tool in an active conversation.",
)
} }
message, ok := args["message"].(string) message, ok := args["message"].(string)

View file

@ -85,7 +85,9 @@ func (t *I2CTool) scan(args map[string]any) *common.ToolResult {
devPath := fmt.Sprintf("/dev/i2c-%s", bus) devPath := fmt.Sprintf("/dev/i2c-%s", bus)
fd, err := syscall.Open(devPath, syscall.O_RDWR, 0) fd, err := syscall.Open(devPath, syscall.O_RDWR, 0)
if err != nil { if err != nil {
return common.ErrorResult(fmt.Sprintf("failed to open %s: %v (check permissions and i2c-dev module)", devPath, err)) return common.ErrorResult(
fmt.Sprintf("failed to open %s: %v (check permissions and i2c-dev module)", devPath, err),
)
} }
defer syscall.Close(fd) defer syscall.Close(fd)

View file

@ -40,7 +40,9 @@ type spiTransfer struct {
func configureSPI(devPath string, mode uint8, bits uint8, speed uint32) (int, *common.ToolResult) { func configureSPI(devPath string, mode uint8, bits uint8, speed uint32) (int, *common.ToolResult) {
fd, err := syscall.Open(devPath, syscall.O_RDWR, 0) fd, err := syscall.Open(devPath, syscall.O_RDWR, 0)
if err != nil { if err != nil {
return -1, common.ErrorResult(fmt.Sprintf("failed to open %s: %v (check permissions and spidev module)", devPath, err)) return -1, common.ErrorResult(
fmt.Sprintf("failed to open %s: %v (check permissions and spidev module)", devPath, err),
)
} }
// Set SPI mode // Set SPI mode

View file

@ -4,14 +4,16 @@ import (
"github.com/sipeed/picoclaw/pkg/tools/common" "github.com/sipeed/picoclaw/pkg/tools/common"
) )
type Tool = common.Tool type (
type ToolResult = common.ToolResult Tool = common.Tool
type ContextualTool = common.ContextualTool ToolResult = common.ToolResult
type AsyncTool = common.AsyncTool ContextualTool = common.ContextualTool
type AsyncCallback = common.AsyncCallback AsyncTool = common.AsyncTool
type FileSystem = common.FileSystem AsyncCallback = common.AsyncCallback
type HostFs = common.HostFs FileSystem = common.FileSystem
type SandboxFs = common.SandboxFs HostFs = common.HostFs
SandboxFs = common.SandboxFs
)
func NewToolResult(forLLM string) *ToolResult { func NewToolResult(forLLM string) *ToolResult {
return common.NewToolResult(forLLM) return common.NewToolResult(forLLM)

View file

@ -3,12 +3,13 @@ package web_fetch
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"github.com/sipeed/picoclaw/pkg/tools/common"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"strings" "strings"
"testing" "testing"
"time" "time"
"github.com/sipeed/picoclaw/pkg/tools/common"
) )
// TestWebTool_WebFetch_Success verifies successful URL fetching // TestWebTool_WebFetch_Success verifies successful URL fetching

View file

@ -3,15 +3,16 @@ package write_file
import ( import (
"context" "context"
"io" "io"
"github.com/sipeed/picoclaw/pkg/tools/list_dir"
"github.com/sipeed/picoclaw/pkg/tools/read_file"
"github.com/sipeed/picoclaw/pkg/tools/common"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/sipeed/picoclaw/pkg/tools/common"
"github.com/sipeed/picoclaw/pkg/tools/list_dir"
"github.com/sipeed/picoclaw/pkg/tools/read_file"
) )
// TestFilesystemTool_ReadFile_Success verifies successful file reading // TestFilesystemTool_ReadFile_Success verifies successful file reading