add trustedTools config to bypass file_read/file_write confirmation
This commit is contained in:
parent
f143fde8fd
commit
1b82b59d03
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"prompt": "To discover skills, use discover_skill.sh <keyword> to search skill descriptions. Once a skill is identified, load it using load_skill.sh <skill_name>.",
|
||||
"mcpServers": {},
|
||||
"trustedTools": ["file_read", "file_write"],
|
||||
"hooks": {
|
||||
"agentSpawn": "true",
|
||||
"userPromptSubmit": "true",
|
||||
"stop": "true"
|
||||
}
|
||||
}
|
||||
|
|
@ -6,9 +6,10 @@ import (
|
|||
)
|
||||
|
||||
type Config struct {
|
||||
MCPServers map[string]ServerConfig `json:"mcpServers,omitempty"`
|
||||
Hooks map[string]string `json:"hooks,omitempty"`
|
||||
Prompt string `json:"prompt,omitempty"`
|
||||
MCPServers map[string]ServerConfig `json:"mcpServers,omitempty"`
|
||||
Hooks map[string]string `json:"hooks,omitempty"`
|
||||
Prompt string `json:"prompt,omitempty"`
|
||||
TrustedTools []string `json:"trustedTools,omitempty"`
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
|
|
|
|||
10
main.go
10
main.go
|
|
@ -279,11 +279,15 @@ func buildAgentEnv(cfg *config.Config, builtinExec *execpkg.Executor) agentEnv {
|
|||
|
||||
hooks := map[string]string{}
|
||||
agentPrompt := ""
|
||||
trustedTools := map[string]struct{}{}
|
||||
if cfg != nil {
|
||||
if cfg.Hooks != nil {
|
||||
hooks = cfg.Hooks
|
||||
}
|
||||
agentPrompt = cfg.Prompt
|
||||
for _, t := range cfg.TrustedTools {
|
||||
trustedTools[t] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
sp := systemPrompt(allTools)
|
||||
|
|
@ -313,7 +317,11 @@ func buildAgentEnv(cfg *config.Config, builtinExec *execpkg.Executor) agentEnv {
|
|||
return extractMCPText(raw), nil
|
||||
}
|
||||
if _, ok := builtinNames[name]; ok {
|
||||
return dispatchBuiltinExec(ctx, name, builtinExec, *confirmPtr, args)
|
||||
var cfn agent.ConfirmFn
|
||||
if _, trusted := trustedTools[name]; !trusted {
|
||||
cfn = *confirmPtr
|
||||
}
|
||||
return dispatchBuiltinExec(ctx, name, builtinExec, cfn, args)
|
||||
}
|
||||
return "", fmt.Errorf("unknown tool: %s", name)
|
||||
}
|
||||
|
|
|
|||
Reference in New Issue