Add per-feature Cursor channel toggles for admin and runtime.
Memind CI / Test, build, and release guards (push) Has been cancelled
Memind CI / Test, build, and release guards (push) Has been cancelled
Expose page/data/scheduled-task/chat-bridge switches in the智趣体验通道 config so Tang can roll out Cursor paths independently with DeepSeek fallback. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
CURSOR_CHANNEL_FEATURES,
|
||||
CURSOR_TASK_KIND,
|
||||
defaultCursorChannelFeatures,
|
||||
intentAllowlistFromFeatures,
|
||||
isCursorFeatureEnabled,
|
||||
isCursorTaskKindEnabled,
|
||||
normalizeCursorChannelFeatures,
|
||||
} from './cursor-channel-features.mjs';
|
||||
|
||||
test('normalizeCursorChannelFeatures derives page.generate from legacy intent allowlist', () => {
|
||||
const features = normalizeCursorChannelFeatures(null, {
|
||||
intentAllowlist: ['page.generate'],
|
||||
});
|
||||
assert.equal(features.pageGenerate.enabled, true);
|
||||
assert.equal(features.pageData.enabled, false);
|
||||
});
|
||||
|
||||
test('isCursorTaskKindEnabled respects per-feature toggles', () => {
|
||||
const policy = {
|
||||
enabled: true,
|
||||
features: {
|
||||
...defaultCursorChannelFeatures(),
|
||||
pageGenerate: { enabled: true },
|
||||
pageData: { enabled: false },
|
||||
},
|
||||
};
|
||||
assert.equal(isCursorTaskKindEnabled(policy, CURSOR_TASK_KIND.PAGE_GENERATION), true);
|
||||
assert.equal(isCursorTaskKindEnabled(policy, CURSOR_TASK_KIND.PAGE_DATA), false);
|
||||
});
|
||||
|
||||
test('intentAllowlistFromFeatures keeps wechat compatibility', () => {
|
||||
const intents = intentAllowlistFromFeatures({
|
||||
[CURSOR_CHANNEL_FEATURES.PAGE_GENERATE]: { enabled: true },
|
||||
[CURSOR_CHANNEL_FEATURES.PAGE_DATA]: { enabled: true },
|
||||
});
|
||||
assert.deepEqual(intents, ['page.generate']);
|
||||
});
|
||||
|
||||
test('isCursorFeatureEnabled requires master enabled flag', () => {
|
||||
const policy = {
|
||||
enabled: false,
|
||||
features: defaultCursorChannelFeatures(),
|
||||
};
|
||||
policy.features.pageGenerate.enabled = true;
|
||||
assert.equal(isCursorFeatureEnabled(policy, CURSOR_CHANNEL_FEATURES.PAGE_GENERATE), false);
|
||||
});
|
||||
Reference in New Issue
Block a user