feat: Add auto_approve_tool_permissions config allowing the confirm dialogs to be disabled in agentic mode (#2110)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
@@ -23,12 +23,29 @@ end
|
||||
---@param callback fun(yes: boolean, reason?: string)
|
||||
---@param confirm_opts? { focus?: boolean }
|
||||
---@param session_ctx? table
|
||||
---@param tool_name? string -- Optional tool name to check against tool_permissions config
|
||||
---@return avante.ui.Confirm | nil
|
||||
function M.confirm(message, callback, confirm_opts, session_ctx)
|
||||
function M.confirm(message, callback, confirm_opts, session_ctx, tool_name)
|
||||
if session_ctx and session_ctx.always_yes then
|
||||
callback(true)
|
||||
return
|
||||
end
|
||||
|
||||
-- Check behaviour.auto_approve_tool_permissions config for auto-approval
|
||||
local Config = require("avante.config")
|
||||
local auto_approve = Config.behaviour.auto_approve_tool_permissions
|
||||
|
||||
-- If auto_approve is true, auto-approve all tools
|
||||
if auto_approve == true then
|
||||
callback(true)
|
||||
return
|
||||
end
|
||||
|
||||
-- If auto_approve is a table (array of tool names), check if this tool is in the list
|
||||
if type(auto_approve) == "table" and vim.tbl_contains(auto_approve, tool_name) then
|
||||
callback(true)
|
||||
return
|
||||
end
|
||||
local Confirm = require("avante.ui.confirm")
|
||||
local sidebar = require("avante").get()
|
||||
if not sidebar or not sidebar.input_container or not sidebar.input_container.winid then
|
||||
|
||||
Reference in New Issue
Block a user