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
+125
View File
@@ -1091,3 +1091,128 @@ test('POST /agent/runs materializes selected assets before creating run', async
assetIds: ['asset-9'],
}]);
});
test('POST /agent/runs keeps non-allowlisted H5 users on existing chat flow for page tasks', async () => {
const created = [];
const prevCursorEnabled = process.env.MEMIND_CURSOR_EXECUTOR_ENABLED;
const prevUseCursor = process.env.MEMIND_AIDER_SKILL_USE_CURSOR;
process.env.MEMIND_CURSOR_EXECUTOR_ENABLED = '1';
process.env.MEMIND_AIDER_SKILL_USE_CURSOR = '1';
try {
const handler = createPostAgentRunsHandler({
userAuth: {
async ownsSession() {
return true;
},
},
cursorExecutorPolicyService: {
async getEffectivePolicy(userId) {
return {
enabled: true,
userAllowlist: ['other-user'],
channelAllowlist: ['h5', 'wechat_mp'],
intentAllowlist: ['page.generate'],
userAllowed: userId === 'other-user',
};
},
},
agentRunGateway: {
async createRun(userId, payload) {
created.push({ userId, payload });
return { id: 'run-chat-1', status: 'queued' };
},
},
});
const res = createResponseRecorder();
await handler(
{
currentUser: { id: 'user-1', username: 'john' },
body: {
session_id: 'session-1',
request_id: 'req-page-1',
user_message: {
role: 'user',
content: [{ type: 'text', text: '帮我写首诗,并做成页面' }],
metadata: { displayText: '帮我写首诗,并做成页面' },
},
},
},
res,
);
assert.equal(res.statusCode, 202);
assert.equal(created[0].payload.toolMode, 'chat');
assert.equal(created[0].payload.taskType, null);
assert.notEqual(created[0].payload.userMessage?.metadata?.memindRun?.executor, 'cursor');
assert.notEqual(created[0].payload.userMessage?.metadata?.memindRun?.pageCursorDefault, true);
} finally {
if (prevCursorEnabled == null) delete process.env.MEMIND_CURSOR_EXECUTOR_ENABLED;
else process.env.MEMIND_CURSOR_EXECUTOR_ENABLED = prevCursorEnabled;
if (prevUseCursor == null) delete process.env.MEMIND_AIDER_SKILL_USE_CURSOR;
else process.env.MEMIND_AIDER_SKILL_USE_CURSOR = prevUseCursor;
}
});
test('POST /agent/runs routes allowlisted H5 users into cursor channel for page tasks', async () => {
const created = [];
const prevCursorEnabled = process.env.MEMIND_CURSOR_EXECUTOR_ENABLED;
const prevUseCursor = process.env.MEMIND_AIDER_SKILL_USE_CURSOR;
process.env.MEMIND_CURSOR_EXECUTOR_ENABLED = '1';
process.env.MEMIND_AIDER_SKILL_USE_CURSOR = '1';
try {
const handler = createPostAgentRunsHandler({
userAuth: {
async ownsSession() {
return true;
},
},
cursorExecutorPolicyService: {
async getEffectivePolicy(userId) {
return {
enabled: true,
userAllowlist: ['user-1'],
channelAllowlist: ['h5'],
intentAllowlist: ['page.generate'],
userAllowed: userId === 'user-1',
};
},
},
agentRunGateway: {
async createRun(userId, payload) {
created.push({ userId, payload });
return { id: 'run-cursor-1', status: 'queued' };
},
},
});
const res = createResponseRecorder();
await handler(
{
currentUser: { id: 'user-1', username: 'john' },
body: {
session_id: 'session-1',
request_id: 'req-page-2',
user_message: {
role: 'user',
content: [{ type: 'text', text: '帮我写首诗,并做成页面' }],
metadata: { displayText: '帮我写首诗,并做成页面' },
},
},
},
res,
);
assert.equal(res.statusCode, 202);
assert.equal(created[0].payload.toolMode, 'code');
assert.equal(created[0].payload.taskType, 'h5_chat_code_task');
assert.equal(created[0].payload.userMessage?.metadata?.memindRun?.executor, 'cursor');
assert.equal(created[0].payload.userMessage?.metadata?.memindRun?.pageCursorDefault, true);
assert.equal(created[0].payload.userMessage?.metadata?.memindRun?.cursorChannel, true);
} finally {
if (prevCursorEnabled == null) delete process.env.MEMIND_CURSOR_EXECUTOR_ENABLED;
else process.env.MEMIND_CURSOR_EXECUTOR_ENABLED = prevCursorEnabled;
if (prevUseCursor == null) delete process.env.MEMIND_AIDER_SKILL_USE_CURSOR;
else process.env.MEMIND_AIDER_SKILL_USE_CURSOR = prevUseCursor;
}
});