feat: 增加手动停止错误处理,优化自动重启逻辑

This commit is contained in:
QLHazyCoder
2026-04-17 10:14:54 +08:00
parent 1a7ae1dc27
commit 32e3973340
3 changed files with 25 additions and 1 deletions
+4
View File
@@ -5062,6 +5062,10 @@ async function runAutoSequenceFromStep(startStep, context = {}) {
}
step += 1;
} catch (err) {
if (isStopError(err)) {
throw err;
}
const restartDecision = await getPostStep6AutoRestartDecision(step, err);
if (restartDecision.shouldRestart) {
postStep6RestartCount += 1;
+19
View File
@@ -96,6 +96,9 @@ async function getState() {
mailProvider: '163',
};
}
function isStopError(error) {
return (error?.message || String(error || '')) === '流程已被用户停止。';
}
function isStepDoneStatus(status) {
return status === 'completed' || status === 'manual_completed' || status === 'skipped';
}
@@ -195,3 +198,19 @@ test('auto-run stops restarting once add-phone is detected', async () => {
assert.deepStrictEqual(result.events.steps, [6]);
assert.ok(result.events.logs.some(({ message }) => /进入 add-phone/.test(message)));
});
test('auto-run stop errors after step 6 are rethrown immediately instead of restarting', async () => {
const harness = createHarness({
failureStep: 8,
failureBudget: 1,
failureMessage: '流程已被用户停止。',
authState: { state: 'password_page', url: 'https://auth.openai.com/log-in' },
});
const result = await harness.runAndCaptureError();
assert.equal(result?.error?.message, '流程已被用户停止。');
assert.equal(result.events.invalidations.length, 0);
assert.deepStrictEqual(result.events.steps, [6, 7, 8]);
assert.ok(!result.events.logs.some(({ message }) => /回到步骤 6 重新开始授权流程/.test(message)));
});
+2 -1
View File
@@ -368,7 +368,8 @@
3. 每轮执行前重置必要运行态
4. 执行 `runAutoSequenceFromStep`
- 步骤 6 内部仍保留登录态恢复的有限重试
- 一旦进入步骤 6~9,遇到报错且认证流程未进入 `add-phone`,则自动回到步骤 6 无限重开,直到成功、手动停止或命中 `add-phone`
- 一旦进入步骤 6~9,遇到普通报错且认证流程未进入 `add-phone`,则自动回到步骤 6 无限重开
- 如果是手动停止,则立即退出自动流程,不会再触发“回到步骤 6 重开”
5. 如果失败,根据设置决定:
- 立即停止
- 当前轮重试