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>
123 lines
3.6 KiB
JavaScript
123 lines
3.6 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import {
|
|
buildCursorPageTimeoutTakeover,
|
|
cursorPageTimeoutTakeoverEnabled,
|
|
resolveCursorPageTimeoutTakeover,
|
|
shouldRetryPageGenerationWithCursor,
|
|
} from './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('cursorPageTimeoutTakeoverEnabled respects env flag', () => {
|
|
assert.equal(cursorPageTimeoutTakeoverEnabled({}), false);
|
|
assert.equal(cursorPageTimeoutTakeoverEnabled(enabledEnv), true);
|
|
});
|
|
|
|
test('shouldRetryPageGenerationWithCursor accepts page timeout without deliverables', () => {
|
|
const row = {
|
|
user_message_json: JSON.stringify({
|
|
role: 'user',
|
|
content: [{ type: 'text', text: '帮我生成上海一日游攻略页面' }],
|
|
metadata: {
|
|
displayText: '帮我生成上海一日游攻略页面',
|
|
memindRun: { toolMode: 'chat' },
|
|
},
|
|
}),
|
|
};
|
|
assert.equal(
|
|
shouldRetryPageGenerationWithCursor({
|
|
row,
|
|
error: { code: 'AGENT_RUN_TIMEOUT' },
|
|
toolGatewayStatus: { enabled: true, executors: ['cursor'] },
|
|
env: enabledEnv,
|
|
}),
|
|
true,
|
|
);
|
|
});
|
|
|
|
test('shouldRetryPageGenerationWithCursor skips when deliverables already recovered', () => {
|
|
const row = {
|
|
user_message_json: JSON.stringify({
|
|
metadata: {
|
|
displayText: '帮我生成上海一日游攻略页面',
|
|
memindRun: { pageCursorDefault: true },
|
|
},
|
|
}),
|
|
};
|
|
assert.equal(
|
|
shouldRetryPageGenerationWithCursor({
|
|
row,
|
|
error: { code: 'AGENT_RUN_TIMEOUT' },
|
|
toolGatewayStatus: { enabled: true, executors: ['cursor'] },
|
|
env: enabledEnv,
|
|
}),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test('buildCursorPageTimeoutTakeover rewrites message for cursor code executor', () => {
|
|
const row = {
|
|
user_message_json: JSON.stringify({
|
|
role: 'user',
|
|
content: [{ type: 'text', text: '帮我生成上海一日游攻略页面' }],
|
|
metadata: {
|
|
displayText: '帮我生成上海一日游攻略页面',
|
|
memindRun: { toolMode: 'chat' },
|
|
},
|
|
}),
|
|
};
|
|
const takeover = buildCursorPageTimeoutTakeover(row, { env: enabledEnv });
|
|
assert.ok(takeover);
|
|
assert.equal(takeover.runOptions.requiredExecutor, 'cursor');
|
|
assert.equal(takeover.runOptions.toolMode, 'code');
|
|
assert.equal(takeover.userMessage.metadata.memindRun.cursorTimeoutTakeover, true);
|
|
assert.match(
|
|
takeover.userMessage.content[0].text,
|
|
/MindSpace 工作区生成或更新 public\/\*\.html 页面/,
|
|
);
|
|
});
|
|
|
|
test('shouldRetryPageGenerationWithCursor accepts wechat agent reply timeout', () => {
|
|
const row = {
|
|
user_message_json: JSON.stringify({
|
|
role: 'user',
|
|
content: [{ type: 'text', text: '帮我生成 Google 今日热门页面' }],
|
|
metadata: {
|
|
displayText: '帮我生成 Google 今日热门页面',
|
|
memindRun: { toolMode: 'chat' },
|
|
},
|
|
}),
|
|
};
|
|
assert.equal(
|
|
shouldRetryPageGenerationWithCursor({
|
|
row,
|
|
error: { code: 'WECHAT_AGENT_REPLY_TIMEOUT' },
|
|
toolGatewayStatus: { enabled: true, executors: ['cursor'] },
|
|
env: enabledEnv,
|
|
}),
|
|
true,
|
|
);
|
|
});
|
|
|
|
test('resolveCursorPageTimeoutTakeover returns null for non-timeout errors', () => {
|
|
const row = {
|
|
user_message_json: JSON.stringify({
|
|
metadata: { displayText: '帮我生成上海一日游攻略页面' },
|
|
}),
|
|
};
|
|
assert.equal(
|
|
resolveCursorPageTimeoutTakeover({
|
|
row,
|
|
error: { code: 'PUBLIC_PAGE_DELIVERABLE_MISSING' },
|
|
toolGatewayStatus: { enabled: true, executors: ['cursor'] },
|
|
env: enabledEnv,
|
|
}),
|
|
null,
|
|
);
|
|
});
|