Files
anything-llm/server/utils/helpers/agents.js
Timothy Carambat 246edc38ce Add automatic agent skill aproval via ENV Flag (#5405)
* add autoapproval env flag

* persist flag
2026-04-10 13:20:47 -07:00

36 lines
1.2 KiB
JavaScript

const chalk = require("chalk");
/**
* Checks if a skill is auto-approved by the ENV variable AGENT_AUTO_APPROVED_SKILLS.
* which is a comma-separated list of skill names. This property applies globally to all users
* so that all invocations of the skill are auto-approved without user interaction.
* @param {Object} options - The options object
* @param {string} options.skillName - The name of the skill
* @returns {boolean} True if the skill is auto-approved, false otherwise
*/
function skillIsAutoApproved({ skillName }) {
if ((!"AGENT_AUTO_APPROVED_SKILLS") in process.env) return false;
const autoApprovedSkills = String(process.env.AGENT_AUTO_APPROVED_SKILLS)
.split(",")
.map((skill) => skill.trim())
.filter((skill) => !!skill);
// If the list contains <all>, then all skills are auto-approved
// This is a special case and overrides any other items in the list.
if (autoApprovedSkills.includes("<all>")) return true;
if (!autoApprovedSkills.length || !autoApprovedSkills.includes(skillName))
return false;
console.log(
chalk.green(
`Skill ${skillName} is auto-approved by the ENV variable AGENT_AUTO_APPROVED_SKILLS.`
)
);
return true;
}
module.exports = {
skillIsAutoApproved,
};