Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c58a23d155 |
@@ -94,7 +94,10 @@ export function looksLikeScheduledTaskNonDelivery(text, { readyPaths = [] } = {}
|
|||||||
if (/public\/[^\s]+\.html/i.test(normalized)) return false;
|
if (/public\/[^\s]+\.html/i.test(normalized)) return false;
|
||||||
if (/页面链接/u.test(normalized)) return false;
|
if (/页面链接/u.test(normalized)) return false;
|
||||||
if (/(?:已生成|已完成|交付).{0,24}(?:页面|链接|结果)/u.test(normalized)) return false;
|
if (/(?:已生成|已完成|交付).{0,24}(?:页面|链接|结果)/u.test(normalized)) return false;
|
||||||
return normalized.length < 40;
|
if (/^验证成功[。!!]?$/u.test(normalized)) return false;
|
||||||
|
if (/^(?:任务)?(?:已)?完成[。!!]?$/u.test(normalized)) return false;
|
||||||
|
if (/^【验证】/u.test(normalized) && normalized.length >= 6) return false;
|
||||||
|
return normalized.length < 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function finalizeScheduledTaskPageDelivery({
|
export async function finalizeScheduledTaskPageDelivery({
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ test('looksLikeScheduledTaskNonDelivery detects clarification replies', () => {
|
|||||||
looksLikeScheduledTaskNonDelivery('好的', { readyPaths: ['public/news.html'] }),
|
looksLikeScheduledTaskNonDelivery('好的', { readyPaths: ['public/news.html'] }),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
assert.equal(looksLikeScheduledTaskNonDelivery('验证成功'), false);
|
||||||
|
assert.equal(looksLikeScheduledTaskNonDelivery('已完成'), false);
|
||||||
|
assert.equal(looksLikeScheduledTaskNonDelivery('好的'), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('extractScheduledTaskDeliveryText reads last assistant message', () => {
|
test('extractScheduledTaskDeliveryText reads last assistant message', () => {
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ async function testLivePortalWorker(pool, userId, { dueSeconds }) {
|
|||||||
const created = await scheduledTaskService.createTask({
|
const created = await scheduledTaskService.createTask({
|
||||||
userId,
|
userId,
|
||||||
title: `${TEST_TITLE_PREFIX}live_portal`,
|
title: `${TEST_TITLE_PREFIX}live_portal`,
|
||||||
taskSpec: '用三句话总结今天的热点新闻(验证脚本,回复文本即可,不要生成页面)',
|
taskSpec: '【验证】直接回复一行文字:验证成功。禁止追问、禁止生成页面、禁止调用任何工具。',
|
||||||
recurrence: 'once',
|
recurrence: 'once',
|
||||||
runAtLocal: formatRunAtLocal(runAtMs, tz),
|
runAtLocal: formatRunAtLocal(runAtMs, tz),
|
||||||
notifyChannel: 'web',
|
notifyChannel: 'web',
|
||||||
@@ -212,10 +212,16 @@ async function testLivePortalWorker(pool, userId, { dueSeconds }) {
|
|||||||
});
|
});
|
||||||
pass('Live 任务已创建', `${waitSeconds}s 后执行,id=${created.id}`);
|
pass('Live 任务已创建', `${waitSeconds}s 后执行,id=${created.id}`);
|
||||||
|
|
||||||
console.log(`\n等待 Portal worker 执行(最多 ${waitSeconds + 120}s)…`);
|
const executionTimeoutMs = Number(
|
||||||
|
process.env.H5_SCHEDULED_TASK_EXECUTION_TIMEOUT_MS
|
||||||
|
?? process.env.VERIFY_SCHEDULED_TASK_EXECUTION_TIMEOUT_MS
|
||||||
|
?? 180_000,
|
||||||
|
);
|
||||||
|
const waitBudgetMs = waitSeconds * 1000 + executionTimeoutMs + 60_000;
|
||||||
|
console.log(`\n等待 Portal worker 执行(最多 ${Math.ceil(waitBudgetMs / 1000)}s,含 Agent 超时 ${Math.ceil(executionTimeoutMs / 1000)}s)…`);
|
||||||
console.log('请确认 Portal 进程已开启 scheduled task worker(H5_SCHEDULED_TASK_WORKER_ENABLED=1,或未设置时 H5_REMINDER_WORKER_ENABLED=1)\n');
|
console.log('请确认 Portal 进程已开启 scheduled task worker(H5_SCHEDULED_TASK_WORKER_ENABLED=1,或未设置时 H5_REMINDER_WORKER_ENABLED=1)\n');
|
||||||
|
|
||||||
const deadline = Date.now() + (waitSeconds + 120) * 1000;
|
const deadline = Date.now() + waitBudgetMs;
|
||||||
let terminal = null;
|
let terminal = null;
|
||||||
while (Date.now() < deadline) {
|
while (Date.now() < deadline) {
|
||||||
const [rows] = await pool.query(
|
const [rows] = await pool.query(
|
||||||
@@ -223,6 +229,11 @@ async function testLivePortalWorker(pool, userId, { dueSeconds }) {
|
|||||||
[created.id],
|
[created.id],
|
||||||
);
|
);
|
||||||
terminal = rows[0];
|
terminal = rows[0];
|
||||||
|
if (!terminal) {
|
||||||
|
fail('Live Portal worker', `任务 ${created.id} 在数据库中消失`);
|
||||||
|
await cleanupTestRows(pool, userId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (terminal?.status === 'completed' || terminal?.status === 'failed') break;
|
if (terminal?.status === 'completed' || terminal?.status === 'failed') break;
|
||||||
await new Promise((resolve) => setTimeout(resolve, 5000));
|
await new Promise((resolve) => setTimeout(resolve, 5000));
|
||||||
}
|
}
|
||||||
@@ -231,6 +242,10 @@ async function testLivePortalWorker(pool, userId, { dueSeconds }) {
|
|||||||
pass('Live Portal worker', `任务 completed,updated_at=${terminal.updated_at}`);
|
pass('Live Portal worker', `任务 completed,updated_at=${terminal.updated_at}`);
|
||||||
} else if (terminal?.status === 'failed') {
|
} else if (terminal?.status === 'failed') {
|
||||||
fail('Live Portal worker', terminal.last_error ?? 'failed');
|
fail('Live Portal worker', terminal.last_error ?? 'failed');
|
||||||
|
} else if (terminal?.status === 'running') {
|
||||||
|
fail('Live Portal worker', `Agent 仍在执行中(status=running);可提高 H5_SCHEDULED_TASK_EXECUTION_TIMEOUT_MS 或检查 Goose 连通性`);
|
||||||
|
} else if (terminal?.status === 'active' && terminal?.last_error) {
|
||||||
|
fail('Live Portal worker', `已失败并重试调度:${terminal.last_error}`);
|
||||||
} else {
|
} else {
|
||||||
fail('Live Portal worker', `超时,最后 status=${terminal?.status ?? 'unknown'}`);
|
fail('Live Portal worker', `超时,最后 status=${terminal?.status ?? 'unknown'}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user