(targetRun, totalRuns, roundSummary, options = {})
| 151 | } |
| 152 | |
| 153 | async function waitBetweenAutoRunRounds(targetRun, totalRuns, roundSummary, options = {}) { |
| 154 | const { autoRunSkipFailures = false, roundSummaries = [] } = options; |
| 155 | if (totalRuns <= 1 || targetRun >= totalRuns) { |
| 156 | return false; |
| 157 | } |
| 158 | |
| 159 | const fallbackThreadIntervalMinutes = normalizeAutoRunFallbackThreadIntervalMinutes( |
| 160 | (await getState()).autoRunFallbackThreadIntervalMinutes |
| 161 | ); |
| 162 | if (fallbackThreadIntervalMinutes <= 0) { |
| 163 | return false; |
| 164 | } |
| 165 | |
| 166 | const currentRuntime = runtime.get(); |
| 167 | const statusLabel = roundSummary?.status === 'failed' ? '失败' : '完成'; |
| 168 | await addLog( |
| 169 | `线程间隔:第 ${targetRun}/${totalRuns} 轮已${statusLabel},等待 ${fallbackThreadIntervalMinutes} 分钟后开始下一轮。`, |
| 170 | 'info' |
| 171 | ); |
| 172 | await persistAutoRunTimerPlan({ |
| 173 | kind: AUTO_RUN_TIMER_KIND_BETWEEN_ROUNDS, |
| 174 | fireAt: Date.now() + fallbackThreadIntervalMinutes * 60 * 1000, |
| 175 | currentRun: targetRun, |
| 176 | totalRuns, |
| 177 | attemptRun: currentRuntime.autoRunAttemptRun, |
| 178 | autoRunSkipFailures, |
| 179 | roundSummaries, |
| 180 | countdownTitle: '线程间隔中', |
| 181 | countdownNote: `第 ${Math.min(targetRun + 1, totalRuns)}/${totalRuns} 轮即将开始`, |
| 182 | }, { |
| 183 | autoRunSkipFailures, |
| 184 | autoRunRoundSummaries: serializeAutoRunRoundSummaries(totalRuns, roundSummaries), |
| 185 | }); |
| 186 | runtime.set({ autoRunActive: false }); |
| 187 | return true; |
| 188 | } |
| 189 | |
| 190 | async function waitBeforeAutoRunRetry(targetRun, totalRuns, nextAttemptRun, options = {}) { |
| 191 | const { autoRunSkipFailures = false, roundSummaries = [] } = options; |
no test coverage detected