feat(tools): optionality
This commit is contained in:
parent
eb138a3f13
commit
9a6b49f9ba
5 changed files with 126 additions and 41 deletions
|
|
@ -203,6 +203,15 @@
|
|||
}
|
||||
},
|
||||
"tools": {
|
||||
"core": {
|
||||
"enable_web_fetch": true,
|
||||
"enable_message": true,
|
||||
"enable_spawn": true
|
||||
},
|
||||
"hardware": {
|
||||
"enable_i2c": false,
|
||||
"enable_spi": false
|
||||
},
|
||||
"web": {
|
||||
"brave": {
|
||||
"enabled": false,
|
||||
|
|
@ -223,10 +232,19 @@
|
|||
"exec_timeout_minutes": 5
|
||||
},
|
||||
"exec": {
|
||||
"enabled": true,
|
||||
"enable_deny_patterns": false,
|
||||
"custom_deny_patterns": []
|
||||
},
|
||||
"filesystem": {
|
||||
"enable_read": true,
|
||||
"enable_write": true,
|
||||
"enable_list": true,
|
||||
"enable_edit": true,
|
||||
"enable_append": true
|
||||
},
|
||||
"skills": {
|
||||
"enabled": true,
|
||||
"registries": {
|
||||
"clawhub": {
|
||||
"enabled": true,
|
||||
|
|
|
|||
|
|
@ -48,12 +48,24 @@ func NewAgentInstance(
|
|||
|
||||
restrict := defaults.RestrictToWorkspace
|
||||
toolsRegistry := tools.NewToolRegistry()
|
||||
if cfg.Tools.Filesystem.EnableRead {
|
||||
toolsRegistry.Register(tools.NewReadFileTool(workspace, restrict))
|
||||
}
|
||||
if cfg.Tools.Filesystem.EnableWrite {
|
||||
toolsRegistry.Register(tools.NewWriteFileTool(workspace, restrict))
|
||||
}
|
||||
if cfg.Tools.Filesystem.EnableList {
|
||||
toolsRegistry.Register(tools.NewListDirTool(workspace, restrict))
|
||||
toolsRegistry.Register(tools.NewExecToolWithConfig(workspace, restrict, cfg))
|
||||
}
|
||||
if cfg.Tools.Filesystem.EnableEdit {
|
||||
toolsRegistry.Register(tools.NewEditFileTool(workspace, restrict))
|
||||
}
|
||||
if cfg.Tools.Filesystem.EnableAppend {
|
||||
toolsRegistry.Register(tools.NewAppendFileTool(workspace, restrict))
|
||||
}
|
||||
if cfg.Tools.Exec.Enabled {
|
||||
toolsRegistry.Register(tools.NewExecToolWithConfig(workspace, restrict, cfg))
|
||||
}
|
||||
|
||||
sessionsDir := filepath.Join(workspace, "sessions")
|
||||
sessionsManager := session.NewSessionManager(sessionsDir)
|
||||
|
|
|
|||
|
|
@ -109,13 +109,20 @@ func registerSharedTools(
|
|||
}); searchTool != nil {
|
||||
agent.Tools.Register(searchTool)
|
||||
}
|
||||
if cfg.Tools.Core.EnableWebFetch {
|
||||
agent.Tools.Register(tools.NewWebFetchTool(50000))
|
||||
}
|
||||
|
||||
// Hardware tools (I2C, SPI) - Linux only, returns error on other platforms
|
||||
if cfg.Tools.Hardware.EnableI2C {
|
||||
agent.Tools.Register(tools.NewI2CTool())
|
||||
}
|
||||
if cfg.Tools.Hardware.EnableSPI {
|
||||
agent.Tools.Register(tools.NewSPITool())
|
||||
}
|
||||
|
||||
// Message tool
|
||||
if cfg.Tools.Core.EnableMessage {
|
||||
messageTool := tools.NewMessageTool()
|
||||
messageTool.SetSendCallback(func(channel, chatID, content string) error {
|
||||
msgBus.PublishOutbound(bus.OutboundMessage{
|
||||
|
|
@ -126,8 +133,10 @@ func registerSharedTools(
|
|||
return nil
|
||||
})
|
||||
agent.Tools.Register(messageTool)
|
||||
}
|
||||
|
||||
// Skill discovery and installation tools
|
||||
if cfg.Tools.Skills.Enabled {
|
||||
registryMgr := skills.NewRegistryManagerFromConfig(skills.RegistryConfig{
|
||||
MaxConcurrentSearches: cfg.Tools.Skills.MaxConcurrentSearches,
|
||||
ClawHub: skills.ClawHubConfig(cfg.Tools.Skills.Registries.ClawHub),
|
||||
|
|
@ -138,8 +147,10 @@ func registerSharedTools(
|
|||
)
|
||||
agent.Tools.Register(tools.NewFindSkillsTool(registryMgr, searchCache))
|
||||
agent.Tools.Register(tools.NewInstallSkillTool(registryMgr, agent.Workspace))
|
||||
}
|
||||
|
||||
// Spawn tool with allowlist checker
|
||||
if cfg.Tools.Core.EnableSpawn {
|
||||
subagentManager := tools.NewSubagentManager(provider, agent.Model, agent.Workspace, msgBus)
|
||||
subagentManager.SetLLMOptions(agent.MaxTokens, agent.Temperature)
|
||||
spawnTool := tools.NewSpawnTool(subagentManager)
|
||||
|
|
@ -148,6 +159,7 @@ func registerSharedTools(
|
|||
return registry.CanSpawnSubagent(currentAgentID, targetAgentID)
|
||||
})
|
||||
agent.Tools.Register(spawnTool)
|
||||
}
|
||||
|
||||
// Update context builder with the complete tools registry
|
||||
agent.ContextBuilder.SetToolsRegistry(agent.Tools)
|
||||
|
|
|
|||
|
|
@ -456,10 +456,31 @@ type WebToolsConfig struct {
|
|||
}
|
||||
|
||||
type CronToolsConfig struct {
|
||||
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
|
||||
}
|
||||
|
||||
type HardwareToolsConfig struct {
|
||||
EnableI2C bool `json:"enable_i2c" env:"PICOCLAW_TOOLS_HW_ENABLE_I2C"`
|
||||
EnableSPI bool `json:"enable_spi" env:"PICOCLAW_TOOLS_HW_ENABLE_SPI"`
|
||||
}
|
||||
|
||||
type CoreToolsConfig struct {
|
||||
EnableWebFetch bool `json:"enable_web_fetch" env:"PICOCLAW_TOOLS_CORE_ENABLE_WEB_FETCH"`
|
||||
EnableMessage bool `json:"enable_message" env:"PICOCLAW_TOOLS_CORE_ENABLE_MESSAGE"`
|
||||
EnableSpawn bool `json:"enable_spawn" env:"PICOCLAW_TOOLS_CORE_ENABLE_SPAWN"`
|
||||
}
|
||||
|
||||
type FilesystemConfig struct {
|
||||
EnableRead bool `json:"enable_read" env:"PICOCLAW_TOOLS_FS_ENABLE_READ"`
|
||||
EnableWrite bool `json:"enable_write" env:"PICOCLAW_TOOLS_FS_ENABLE_WRITE"`
|
||||
EnableList bool `json:"enable_list" env:"PICOCLAW_TOOLS_FS_ENABLE_LIST"`
|
||||
EnableEdit bool `json:"enable_edit" env:"PICOCLAW_TOOLS_FS_ENABLE_EDIT"`
|
||||
EnableAppend bool `json:"enable_append" env:"PICOCLAW_TOOLS_FS_ENABLE_APPEND"`
|
||||
}
|
||||
|
||||
type ExecConfig struct {
|
||||
Enabled bool `json:"enabled" env:"PICOCLAW_TOOLS_EXEC_ENABLED"`
|
||||
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"`
|
||||
}
|
||||
|
|
@ -469,9 +490,13 @@ type ToolsConfig struct {
|
|||
Cron CronToolsConfig `json:"cron"`
|
||||
Exec ExecConfig `json:"exec"`
|
||||
Skills SkillsToolsConfig `json:"skills"`
|
||||
Filesystem FilesystemConfig `json:"filesystem"`
|
||||
Hardware HardwareToolsConfig `json:"hardware"`
|
||||
Core CoreToolsConfig `json:"core"`
|
||||
}
|
||||
|
||||
type SkillsToolsConfig struct {
|
||||
Enabled bool `json:"enabled" env:"PICOCLAW_TOOLS_SKILLS_ENABLED"`
|
||||
Registries SkillsRegistriesConfig `json:"registries"`
|
||||
MaxConcurrentSearches int `json:"max_concurrent_searches" env:"PICOCLAW_SKILLS_MAX_CONCURRENT_SEARCHES"`
|
||||
SearchCache SearchCacheConfig `json:"search_cache"`
|
||||
|
|
|
|||
|
|
@ -276,6 +276,15 @@ func DefaultConfig() *Config {
|
|||
Port: 18790,
|
||||
},
|
||||
Tools: ToolsConfig{
|
||||
Core: CoreToolsConfig{
|
||||
EnableWebFetch: true,
|
||||
EnableMessage: true,
|
||||
EnableSpawn: true,
|
||||
},
|
||||
Hardware: HardwareToolsConfig{
|
||||
EnableI2C: true,
|
||||
EnableSPI: true,
|
||||
},
|
||||
Web: WebToolsConfig{
|
||||
Brave: BraveConfig{
|
||||
Enabled: false,
|
||||
|
|
@ -296,9 +305,18 @@ func DefaultConfig() *Config {
|
|||
ExecTimeoutMinutes: 5,
|
||||
},
|
||||
Exec: ExecConfig{
|
||||
Enabled: true,
|
||||
EnableDenyPatterns: true,
|
||||
},
|
||||
Filesystem: FilesystemConfig{
|
||||
EnableRead: true,
|
||||
EnableWrite: true,
|
||||
EnableList: true,
|
||||
EnableEdit: true,
|
||||
EnableAppend: true,
|
||||
},
|
||||
Skills: SkillsToolsConfig{
|
||||
Enabled: true,
|
||||
Registries: SkillsRegistriesConfig{
|
||||
ClawHub: ClawHubRegistryConfig{
|
||||
Enabled: true,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue