feat(tools): opt-in shell tool without interpreter: allowlist per chain element, no expansions/redirections, workspace-only, timeout, output limit, scrubbed env
This commit is contained in:
parent
1e32997504
commit
406a523d54
5 changed files with 464 additions and 0 deletions
|
|
@ -63,6 +63,14 @@ func run(cfgPath string, log *slog.Logger) error {
|
|||
reg.Register(tools.FileWrite{Workspace: ws})
|
||||
reg.Register(tools.FileList{Workspace: ws})
|
||||
}
|
||||
if sc := cfg.Tools.Shell; sc.Enabled {
|
||||
sh, err := tools.NewShell(cfg.Workspace, sc.AllowedCommands, time.Duration(sc.TimeoutSec)*time.Second, sc.MaxOutputBytes)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
reg.Register(sh)
|
||||
log.Warn("shell tool enabled", "allowed", sc.AllowedCommands)
|
||||
}
|
||||
prov := llm.NewOpenAI(cfg.LLM.BaseURL, cfg.LLM.APIKey, cfg.LLM.Model, cfg.LLM.Temperature, time.Duration(cfg.LLM.TimeoutSec)*time.Second)
|
||||
ag := &agent.Agent{LLM: prov, Tools: reg, Store: st, SystemPrompt: cfg.Agent.SystemPrompt,
|
||||
MaxIterations: cfg.Agent.MaxIterations, HistoryLimit: cfg.Agent.HistoryLimit}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue