fix: don’t execute incomplete streaming commands (#2245)

This commit is contained in:
Andre-Philippe Paquet
2025-06-16 22:56:58 -04:00
committed by GitHub
parent 320bf2cee1
commit 59ad32efcf
2 changed files with 16 additions and 1 deletions

View File

@@ -214,13 +214,20 @@ M.returns = {
},
}
---@type AvanteLLMToolFunc<{ path: string, command: string }>
---@type AvanteLLMToolFunc<{ path: string, command: string, streaming?: boolean }>
function M.func(opts, on_log, on_complete, session_ctx)
local is_streaming = opts.streaming or false
if is_streaming then
-- wait for stream completion as command may not be complete yet
return
end
local abs_path = Helpers.get_abs_path(opts.path)
if not Helpers.has_permission_to_access(abs_path) then return false, "No permission to access path: " .. abs_path end
if not Path:new(abs_path):exists() then return false, "Path not found: " .. abs_path end
if not opts.command then return false, "Command is required" end
if on_log then on_log("command: " .. opts.command) end
---change cwd to abs_path
---@param output string
---@param exit_code integer