"use strict"; const AGENT_PATH = /^(?:\/api\/ai(?:\/|$)|\/api\/settings\/accounts\/[^/]+\/agent-access\/?$|\/api\/servers\/[^/]+\/planner\/[^/]+\/send-agent\/?$)/i; function isAgentSchedule(actionType) { return actionType === "planner_next_to_agent" || actionType === "agent_prompt"; } function sendAgentDisabled(res) { return res.set("Cache-Control", "no-store").status(503).json({ error: "ADPanel Agent is disabled.", code: "agent_disabled", }); } function createAgentFeatureGate(isEnabled) { return (req, res, next) => { if (!AGENT_PATH.test(req.path) || isEnabled()) return next(); return sendAgentDisabled(res); }; } module.exports = { createAgentFeatureGate, isAgentSchedule, sendAgentDisabled };