Isolate Cursor executor to admin-configured whitelist channel for H5 and WeChat.
Memind CI / Test, build, and release guards (push) Failing after 4m22s

Non-allowlisted users stay on the existing Goose/DeepSeek path; only memindadm whitelist users enter the TKMind Cursor channel on selected intents and channels.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-08-28 15:27:10 +08:00
parent 02fdcdedc5
commit 416bf7a29a
13 changed files with 339 additions and 42 deletions
+22
View File
@@ -4,11 +4,18 @@ const POLICY_SOURCE_DEFAULT = 'default';
const POLICY_SOURCE_ADMIN_DB = 'admin-db';
const DEFAULT_INTENT_ALLOWLIST = Object.freeze(['page.generate']);
const DEFAULT_CHANNEL_ALLOWLIST = Object.freeze(['h5', 'wechat_mp']);
export const CURSOR_EXECUTOR_CHANNEL = Object.freeze({
H5: 'h5',
WECHAT_MP: 'wechat_mp',
});
function defaultConfigShape() {
return {
enabled: false,
userAllowlist: [],
channelAllowlist: [...DEFAULT_CHANNEL_ALLOWLIST],
intentAllowlist: [...DEFAULT_INTENT_ALLOWLIST],
fallbackToDeepseek: true,
meta: {
@@ -58,6 +65,10 @@ function mergePatch(currentConfig, patch = {}) {
const next = cloneConfig(currentConfig);
if ('enabled' in patch) next.enabled = normalizeBoolean(patch.enabled, false);
if ('userAllowlist' in patch) next.userAllowlist = normalizeStringList(patch.userAllowlist);
if ('channelAllowlist' in patch) {
const channels = normalizeStringList(patch.channelAllowlist);
next.channelAllowlist = channels.length ? channels : [...DEFAULT_CHANNEL_ALLOWLIST];
}
if ('intentAllowlist' in patch) {
const intents = normalizeStringList(patch.intentAllowlist);
next.intentAllowlist = intents.length ? intents : [...DEFAULT_INTENT_ALLOWLIST];
@@ -73,15 +84,26 @@ function mergePatch(currentConfig, patch = {}) {
function flattenPolicy(config, source) {
const intentAllowlist = normalizeStringList(config.intentAllowlist);
const channelAllowlist = normalizeStringList(config.channelAllowlist);
return {
source,
enabled: Boolean(config.enabled),
userAllowlist: normalizeStringList(config.userAllowlist),
channelAllowlist: channelAllowlist.length ? channelAllowlist : [...DEFAULT_CHANNEL_ALLOWLIST],
intentAllowlist: intentAllowlist.length ? intentAllowlist : [...DEFAULT_INTENT_ALLOWLIST],
fallbackToDeepseek: config.fallbackToDeepseek !== false,
};
}
export function isChannelAllowedByCursorPolicy(channel, policy) {
const allowlist = normalizeStringList(policy?.channelAllowlist ?? DEFAULT_CHANNEL_ALLOWLIST)
.map((item) => item.toLowerCase());
if (allowlist.length === 0) return false;
const normalized = String(channel ?? '').trim().toLowerCase();
if (!normalized) return false;
return allowlist.includes(normalized);
}
export function isUserAllowedByWechatCursorPolicy(user, policy) {
if (!policy?.enabled) return false;
const allowlist = normalizeStringList(policy.userAllowlist).map((item) => item.toLowerCase());