fix(agent-run): align cursor executor path with 103 production hotfixes

Recover requiredExecutor fallback, direct cursor launch in tool gateway,
and user-facing brand sanitization in source so the next portal release
can replace manual bundled edits on 103.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-08-27 09:31:36 +08:00
parent b356ae8509
commit a29e1ec5c8
8 changed files with 581 additions and 30 deletions
+79
View File
@@ -32,10 +32,59 @@ test('tool gateway is disabled by default and reports protocol', () => {
protocol: 'agent-run-v1',
executors: ['aider', 'openhands'],
defaultExecutor: 'aider',
cursorEnabled: false,
cursorTaskTypes: ['h5_chat_code_task', 'mindspace_page', 'mindspace_html_page'],
openhandsTaskTypes: ['repo_refactor', 'multi_file', 'complex_repo', 'page_data_dev_complex'],
});
});
test('tool gateway exposes cursor executor when enabled', () => {
const gateway = createToolGateway({
env: {
MEMIND_CURSOR_EXECUTOR_ENABLED: '1',
MEMIND_TOOL_GATEWAY_CURSOR_TASK_TYPES: 'h5_chat_code_task',
},
});
assert.deepEqual(gateway.getStatus().executors, ['cursor', 'aider', 'openhands']);
assert.equal(
gateway.selectExecutor({ taskType: 'h5_chat_code_task' }),
'cursor',
);
assert.equal(gateway.selectExecutor({ taskType: 'small_patch' }), 'aider');
});
test('tool gateway honors explicit cursor executor in run metadata', () => {
const gateway = createToolGateway({
env: { MEMIND_CURSOR_EXECUTOR_ENABLED: '1' },
});
assert.equal(gateway.selectExecutor({
taskType: 'page_data_dev_complex',
userMessage: {
metadata: {
memindRun: {
executor: 'cursor',
},
},
},
}), 'cursor');
});
test('tool gateway honors requiredExecutor when executor is absent', () => {
const gateway = createToolGateway({
env: { MEMIND_CURSOR_EXECUTOR_ENABLED: '1' },
});
assert.equal(gateway.selectExecutor({
userMessage: {
metadata: {
memindRun: {
requiredExecutor: 'cursor',
channel: 'wechat_mp',
},
},
},
}), 'cursor');
});
test('tool gateway selects openhands for configured task types', () => {
const gateway = createToolGateway({
env: {
@@ -144,3 +193,33 @@ test('tool gateway dry run builds executor launch plan without spawning', async
assert.equal(plans.length, 1);
assert.equal(plans[0].options.instruction, 'fix it');
});
test('tool gateway cursor dry run does not require llm provider service', async () => {
const gateway = createToolGateway({
env: {
MEMIND_TOOL_GATEWAY_ENABLED: '1',
MEMIND_TOOL_GATEWAY_DRY_RUN: '1',
MEMIND_CURSOR_EXECUTOR_ENABLED: '1',
},
});
const result = await gateway.executeJob({
runId: 'run-cursor',
requestId: 'req-cursor',
userId: 'user-1',
cwd: '/tmp/work',
userMessage: {
content: [{ type: 'text', text: 'build page' }],
metadata: {
memindRun: {
requiredExecutor: 'cursor',
},
},
},
});
assert.equal(result.dryRun, true);
assert.equal(result.executor, 'cursor');
assert.equal(result.executorLabel, 'TKMind 智趣');
assert.match(String(result.command), /agent$/);
});