Initial upload to Gitea
This commit is contained in:
1 parent
78193254ad
commit
8478998cae
1485 files changed
+461025
-42348
No files matched your search
@@ -0,0 +1,22 @@
|
||||
"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 };
|
||||
Reference in new issue
Block a user