feat: add code run rollout policy gates

This commit is contained in:
Your Name
2026-07-02 10:47:22 +08:00
parent f1fd4cc316
commit 212e163006
3 changed files with 188 additions and 0 deletions
+23
View File
@@ -1783,6 +1783,28 @@ api.get('/status', async (_req, res, next) => {
return next();
});
function runtimeEnvFlag(value, fallback = false) {
const raw = String(value ?? '').trim().toLowerCase();
if (!raw) return fallback;
return ['1', 'true', 'yes', 'on'].includes(raw);
}
function runtimeCsvList(value) {
return String(value ?? '')
.split(',')
.map((item) => item.trim())
.filter(Boolean);
}
function runtimeCodeRunPolicyStatus() {
return {
enabled: runtimeEnvFlag(process.env.MEMIND_AGENT_CODE_RUNS_ENABLED),
userAllowlist: runtimeCsvList(process.env.MEMIND_AGENT_CODE_RUNS_USER_IDS),
taskTypeAllowlist: runtimeCsvList(process.env.MEMIND_AGENT_CODE_RUN_TASK_TYPES),
requireValidation: runtimeEnvFlag(process.env.MEMIND_AGENT_CODE_RUNS_REQUIRE_VALIDATION),
};
}
api.get('/runtime/status', async (_req, res) => {
await userAuthReady;
if (!tkmindProxy?.getRuntimeStatus) {
@@ -1798,6 +1820,7 @@ api.get('/runtime/status', async (_req, res) => {
if (toolQueue) {
status.toolRuntime = {
...(status.toolRuntime ?? {}),
codeRunPolicy: runtimeCodeRunPolicyStatus(),
queue: toolQueue,
};
}