MCPcopy Index your code
hub / github.com/QLHazyCoder/FlowPilot / scheduleAutoRun

Function scheduleAutoRun

background.js:4030–4061  ·  view source on GitHub ↗
(totalRuns, options = {})

Source from the content-addressed store, hash-verified

4028}
4029
4030async function scheduleAutoRun(totalRuns, options = {}) {
4031 const state = await getState();
4032 if (isAutoRunLockedState(state) || isAutoRunPausedState(state) || autoRunActive) {
4033 throw new Error('自动运行已在进行中,请先停止后再重新计划。');
4034 }
4035 if (getPendingAutoRunTimerPlan(state)) {
4036 throw new Error('已有自动运行倒计时计划,请先取消或立即开始。');
4037 }
4038
4039 const delayMinutes = normalizeAutoRunDelayMinutes(options.delayMinutes);
4040 const timerPlan = normalizeAutoRunTimerPlan({
4041 kind: AUTO_RUN_TIMER_KIND_SCHEDULED_START,
4042 fireAt: Date.now() + delayMinutes * 60 * 1000,
4043 totalRuns,
4044 autoRunSkipFailures: options.autoRunSkipFailures,
4045 mode: options.mode,
4046 });
4047
4048 autoRunCurrentRun = 0;
4049 autoRunTotalRuns = timerPlan.totalRuns;
4050 autoRunAttemptRun = 0;
4051
4052 await persistAutoRunTimerPlan(timerPlan, {
4053 autoRunSkipFailures: timerPlan.autoRunSkipFailures,
4054 autoRunRoundSummaries: serializeAutoRunRoundSummaries(timerPlan.totalRuns, []),
4055 });
4056 await addLog(
4057 `自动运行已计划:${delayMinutes} 分钟后启动(${formatAutoRunScheduleTime(timerPlan.fireAt)}),目标 ${timerPlan.totalRuns} 轮。`,
4058 'info'
4059 );
4060 return { ok: true, scheduledAt: timerPlan.fireAt };
4061}
4062
4063async function cancelScheduledAutoRun(options = {}) {
4064 const state = await getState();

Callers 1

handleMessageFunction · 0.85

Calls 10

getStateFunction · 0.85
isAutoRunLockedStateFunction · 0.85
isAutoRunPausedStateFunction · 0.85
persistAutoRunTimerPlanFunction · 0.85
addLogFunction · 0.70

Tested by

no test coverage detected