2c3c1f7a52
Memind CI / Test, build, and release guards (push) Failing after 2m37s
Wire WECHAT_AGENT_REPLY_TIMEOUT into the same Cursor takeover path used by agent runs, raise the default WeChat reply timeout to 20 minutes, and fall back to env-based tool-gateway detection when runtime exports are missing. Co-authored-by: Cursor <cursoragent@cursor.com>
85 lines
2.8 KiB
JavaScript
85 lines
2.8 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import {
|
|
attemptWechatCursorPageTimeoutTakeover,
|
|
buildWechatPageTimeoutTakeoverRow,
|
|
} from './wechat-cursor-page-timeout-takeover.mjs';
|
|
|
|
const enabledEnv = {
|
|
MEMIND_CURSOR_EXECUTOR_ENABLED: '1',
|
|
MEMIND_CURSOR_PAGE_TIMEOUT_TAKEOVER: '1',
|
|
MEMIND_AIDER_SKILL_USE_CURSOR: '1',
|
|
};
|
|
|
|
test('buildWechatPageTimeoutTakeoverRow uses display text from intent', () => {
|
|
const row = buildWechatPageTimeoutTakeoverRow({
|
|
displayText: '帮我生成 google 今日热门页面',
|
|
});
|
|
const parsed = JSON.parse(row.user_message_json);
|
|
assert.equal(parsed.metadata.displayText, '帮我生成 google 今日热门页面');
|
|
});
|
|
|
|
test('attemptWechatCursorPageTimeoutTakeover skips non-page intents', async () => {
|
|
const result = await attemptWechatCursorPageTimeoutTakeover({
|
|
error: { code: 'WECHAT_AGENT_REPLY_TIMEOUT' },
|
|
intent: { displayText: '今天天气怎么样' },
|
|
wechatIntent: { kind: 'chat.general' },
|
|
userId: 'user-1',
|
|
sessionId: '20260911_7',
|
|
requestId: 'req-1',
|
|
agentRunGateway: { createRun: async () => ({ id: 'run-1' }) },
|
|
env: enabledEnv,
|
|
});
|
|
assert.equal(result, null);
|
|
});
|
|
|
|
test('attemptWechatCursorPageTimeoutTakeover dispatches cursor run on goose timeout', async () => {
|
|
const calls = [];
|
|
const agentRunGateway = {
|
|
getToolGatewayStatus: () => ({ enabled: true, executors: ['cursor'] }),
|
|
async createRun(userId, payload) {
|
|
calls.push(['createRun', userId, payload]);
|
|
return { id: 'run-cursor-1' };
|
|
},
|
|
dispatchRun(runId) {
|
|
calls.push(['dispatchRun', runId]);
|
|
},
|
|
async getRunForUser() {
|
|
return {
|
|
status: 'succeeded',
|
|
error: null,
|
|
};
|
|
},
|
|
async listRunEventsForUser() {
|
|
return {
|
|
events: [{
|
|
eventType: 'tool_gateway_result',
|
|
data: {
|
|
executor: 'cursor',
|
|
stdoutTail: '页面已生成:https://example.com/MindSpace/user-1/public/google-trends.html',
|
|
},
|
|
}],
|
|
};
|
|
},
|
|
};
|
|
|
|
const result = await attemptWechatCursorPageTimeoutTakeover({
|
|
error: { code: 'WECHAT_AGENT_REPLY_TIMEOUT' },
|
|
intent: { displayText: '帮我生成 google 今日热门话题分析页面' },
|
|
wechatIntent: { kind: 'page.generate' },
|
|
userId: 'user-1',
|
|
sessionId: '20260911_7',
|
|
requestId: 'req-1',
|
|
agentRunGateway,
|
|
env: enabledEnv,
|
|
});
|
|
|
|
assert.ok(result?.text);
|
|
assert.match(result.text, /google-trends\.html/);
|
|
assert.equal(calls.some((call) => call[0] === 'dispatchRun'), true);
|
|
const createPayload = calls.find((call) => call[0] === 'createRun')?.[2];
|
|
assert.equal(createPayload.userMessage.metadata.memindRun.cursorTimeoutTakeover, true);
|
|
assert.equal(createPayload.toolMode, 'code');
|
|
assert.equal(createPayload.forceDeepReasoning, true);
|
|
});
|