Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Routines: option to skip the after-reset replay of a recurring routine's run
Doğukaan Kılıçarslan8241f9fcf969
diff --git a/apps/docs/content/docs/features/automation.mdx b/apps/docs/content/docs/features/automation.mdxindex cb58290669..2cfe06ce69 100644--- a/apps/docs/content/docs/features/automation.mdx+++ b/apps/docs/content/docs/features/automation.mdx@@ -36,6 +36,10 @@ Each run starts fresh by default. For work that builds on last time, such as a QIf your computer is often off when a routine is due, open the routine's **Advanced** options and turn on **Also run when OpenMausBot starts**. The routine then runs once each time OpenMausBot opens, as well as on its schedule. Its run logs show these runs as **On startup**. A routine that OpenMausBot is already catching up on at startup runs once, not twice, and an occurrence missed by more than 12 hours is covered by the startup run instead of being reported as missed. Switching to another workspace and back, or OpenMausBot recovering from a crash, doesn't count as opening the app again. Pausing a routine stops its startup runs too. It's available for repeating routines, and you can also ask the bot in chat to turn it on.+### When the AI's usage limit stops a run++If a bot's AI reaches its usage limit during a run and the limit resets within 12 hours, OpenMausBot starts that run once more a minute after the reset, and tells you so. For a repeating routine you can have it wait for its next scheduled run instead: set `"recurringRoutinesSkipLimitReplay": true` under `features` in `~/.openmausbot/config.json`. The stopped run then fails with the usual usage-limit notice. Runs you start with **Run now**, one-time routines and routines that run when a limit resets still start again at the reset, and a bot with a backup AI still switches to it at once.+### Clear a folder's unread dotsRight-click a folder or open its **…** menu, then choose **Mark folder as read**. This clears unread dots without opening each thread. It does not answer approvals, dismiss questions, or stop any running work.diff --git a/server/config.ts b/server/config.tsindex 978199ece1..bb45ff82a2 100644--- a/server/config.ts+++ b/server/config.ts@@ -245,6 +245,8 @@ const featureConfigSchema = z.object({claudeUserSkills: z.boolean().optional(), // Claude bots also load the skills in ~/.claude/skills, in place. Off unless true./** LLM-generated titles for new threads. Off unless true. */llmThreadTitles: z.boolean().optional(),+ /** A recurring routine run that a usage limit stopped waits for its next scheduled run instead of starting again at the reset. Off unless true. */+ recurringRoutinesSkipLimitReplay: z.boolean().optional(),/** A new bot's setup card offers answers its engine writes for it, when there is something to go on. On unless false. */smartSetupChoices: z.boolean().optional(),/** Recall matching passages from the bot's memory into each turn. On unless false. */@@ -518,7 +520,7 @@ export interface AppConfig extends HelperConfig {context?: { rebuildBytes?: number; compactAt?: number; autoCompact?: boolean; roomCompactAt?: number; roomSessions?: boolean; replayToolHistory?: boolean };memory?: { captureQuietMs?: number; tidyHour?: number };localVm?: { mode?: "shared" | "per-bot" | "pool"; maxInstances?: number; idleTimeoutMinutes?: number; preserveInstalledApps?: boolean };- features?: { skillAuthoring?: boolean; skillReview?: boolean; skillReviewSteps?: number; showToolCalls?: boolean; browser?: boolean; sharedComputers?: boolean; claudeUserMcp?: boolean; claudeUserSkills?: boolean; llmThreadTitles?: boolean; smartSetupChoices?: boolean; autoRecall?: boolean; skillsLibrary?: boolean; shareLearnedSkills?: "off" | "ask" | "auto"; roomMemoryCapture?: boolean; parallelRoomJobs?: boolean; chiefEscalations?: boolean; acpPlanLines?: boolean; agentsToolBridge?: boolean; savedSteps?: boolean };+ features?: { skillAuthoring?: boolean; skillReview?: boolean; skillReviewSteps?: number; showToolCalls?: boolean; browser?: boolean; sharedComputers?: boolean; claudeUserMcp?: boolean; claudeUserSkills?: boolean; llmThreadTitles?: boolean; recurringRoutinesSkipLimitReplay?: boolean; smartSetupChoices?: boolean; autoRecall?: boolean; skillsLibrary?: boolean; shareLearnedSkills?: "off" | "ask" | "auto"; roomMemoryCapture?: boolean; parallelRoomJobs?: boolean; chiefEscalations?: boolean; acpPlanLines?: boolean; agentsToolBridge?: boolean; savedSteps?: boolean };onboarding?: { completedAt?: string; version?: number; reelSeen?: boolean; hintsSeen?: string[]; firstTurnAt?: string };browserProfiles?: BrowserProfile[];browserEngine?: BrowserEngineConfig;diff --git a/server/index.ts b/server/index.tsindex 8104d276fa..7bec4c915d 100644--- a/server/index.ts+++ b/server/index.ts@@ -8915,6 +8915,7 @@ const automationDestinations = createAutomationDestinations({ store, mainThread:cloud: CLOUD_HOME ? { owner: CLOUD_OWNER_KEY!, opener: routineOpener, reportFromOthers: cloudReportFromOthers, opened: (threadId, person) => threadStarters.set(threadId, person) } : null });routines = new RoutineManager({emit: broadcast, limitResetAt: (engine) => limitClock.resetAt(engine), checks: proactive.checks,+ skipLimitReplay: () => cfg.features?.recurringRoutinesSkipLimitReplay === true,limitBackup: (botId, scope) => { const bot = store.bot(botId); return quotaSwitchEnabled() ? Boolean(bot && limitTakeover.backups(botId, bot.modelSelection, scope, approvalModeFor(bot)).length) : Boolean(bot && startupBackups(bot, cfg.automaticRecovery).length); },launchId: DESKTOP_MANAGED && /^[\w-]{1,100}$/.test(process.env.OMB_DESKTOP_LAUNCH_ID ?? "")? process.env.OMB_DESKTOP_LAUNCH_ID : undefined,diff --git a/server/routine-recovery.test.ts b/server/routine-recovery.test.tsindex f2a041d194..482898bce8 100644--- a/server/routine-recovery.test.ts+++ b/server/routine-recovery.test.ts@@ -416,6 +416,37 @@ describe("an unattended run only its owner can fix", () => {expect(h.deferred).toHaveLength(1);});+ it("with skipLimitReplay on, fails a recurring routine's scheduled run at a usage limit; manual and one-time runs still wait for the reset", async () => {+ const h = harness({ skipLimitReplay: () => true });+ const limit = "This Claude account has reached its 5-hour limit, which resets soon. Until then, switch this bot to another AI or Claude account.";+ const hourly = h.manager.create({ name: "Price check", prompt: "Check the price", botId: "maus-1", schedule: { type: "interval", everyMinutes: 60, anchorAt: START } });+ const once = h.manager.create({ name: "Reminder", prompt: "Remind me", botId: "maus-2", schedule: { type: "once", at: START + 30 * MINUTE } });+ await h.advance(30 * MINUTE);+ const oneTime = h.runs().find((run) => run.routineId === once.id)!;+ h.fail(oneTime.threadId!, limit, { stopReason: "quota", limitResetsAt: START + 3 * 3_600_000 });+ expect(h.run(oneTime.id)).toMatchObject({ status: "queued", retried: "usage_limit" });+ await h.advance(30 * MINUTE);+ const scheduled = h.runs().find((run) => run.routineId === hourly.id)!;+ expect(scheduled).toMatchObject({ status: "running", triggerSource: "schedule" });+ h.fail(scheduled.threadId!, limit, { stopReason: "quota", limitResetsAt: START + 3 * 3_600_000 });+ expect(h.run(scheduled.id)).toMatchObject({ status: "failed", error: limit });+ expect(h.failed.map(({ run, alert }) => [run.id, alert])).toEqual([+ [scheduled.id, { detail: "This bot's AI reached its usage limit. Its routines work again once it resets, or choose another AI for this bot now." }],+ ]);+ const manual = await h.start(hourly.id);+ h.fail(manual.threadId!, limit, { stopReason: "quota", limitResetsAt: START + 3 * 3_600_000 });+ expect(h.run(manual.id)).toMatchObject({ status: "queued", retried: "usage_limit" });+ });++ it("starts a recurring routine's scheduled run again at the reset while skipLimitReplay is off", async () => {+ const h = harness();+ const hourly = h.manager.create({ name: "Price check", prompt: "Check the price", botId: "maus-1", schedule: { type: "interval", everyMinutes: 60, anchorAt: START } });+ await h.advance(60 * MINUTE);+ const scheduled = h.runs().find((run) => run.routineId === hourly.id)!;+ h.fail(scheduled.threadId!, "This Claude account has reached its 5-hour limit.", { stopReason: "quota", limitResetsAt: START + 3 * 3_600_000 });+ expect(h.run(scheduled.id)).toMatchObject({ status: "queued", retried: "usage_limit", retryAt: START + 3 * 3_600_000 + MINUTE });+ });+it("fails a usage limit with no reset time, or one too far off, and tells the owner", async () => {const h = harness();const run = await h.start(h.routine("maus-1").id);diff --git a/server/routine-recovery.ts b/server/routine-recovery.tsindex faccdd03e7..94bb41d1a7 100644--- a/server/routine-recovery.ts+++ b/server/routine-recovery.ts@@ -27,6 +27,8 @@ export interface RoutineFailureFacts {limit?: "engine" | "model" | "credits";/** A backup engine takes over from one whose usage limit refused the run, or that is signed out. */backupReady?: boolean;+ /** A usage limit fails the run instead of starting it again at the reset: its routine runs again on its own schedule. */+ skipLimitReplay?: boolean;/** The turn's reply came back; only a step it ran failed or wasn't allowed (the runtime error's `partial`). */partial?: boolean;}@@ -181,7 +183,7 @@ export function recoverRun(run: RoutineRun, failure: string, facts: RoutineFailu}const first = firstNotice(notices, run.botId, verdict.cause, now);const reset = verdict.resetsAt;- if (reset && reset > now && reset - now <= LIMIT_WAIT_MS && requeueOnce(run, "usage_limit", failure, now, reset + AFTER_RESET_MS)) {+ if (reset && !facts.skipLimitReplay && reset > now && reset - now <= LIMIT_WAIT_MS && requeueOnce(run, "usage_limit", failure, now, reset + AFTER_RESET_MS)) {return { queued: true, ...(first ? { alert: { detail: `This bot's AI reached its usage limit. This run starts again at ${when(reset + AFTER_RESET_MS)}.` } } : {}) };}const action = verdict.cause === "setup" ? failure : verdict.cause === "credits" && facts.trialCredit ? TRIAL_ACTION : OWNER_ACTION[verdict.cause];diff --git a/server/routines.ts b/server/routines.tsindex 73132a1e20..ea6610eb31 100644--- a/server/routines.ts+++ b/server/routines.ts@@ -264,6 +264,8 @@ export interface RoutineManagerOptions {limitResetAt?: (engine: string) => number | null;/** The bot has a backup engine to continue on when its own engine's usage limit refuses a run, or it is signed out. */limitBackup?: (botId: string, scope?: "engine" | "model" | "credits" | "signed-out") => boolean;+ /** A recurring routine run that a usage limit stopped waits for its next scheduled run instead of starting again at the reset. */+ skipLimitReplay?: () => boolean;/** Work this thread handed to another bot is still open, so its wait is not only on the person. */handedOffWorkLive?: (threadId: string) => boolean;launchId?: string;@@ -1309,7 +1311,8 @@ export class RoutineManager {this.failureFacts.delete(run.id);if (this.closing) return;const held = facts.limit !== undefined || facts.limitResetsAt !== undefined ? facts.limit ?? "engine" : facts.stopReason === "auth_required" ? "signed-out" : undefined, backupReady = held !== undefined && this.options.limitBackup?.(run.botId, held) === true;- const recovery = recoverRun(run, failure, { ...facts, ...(backupReady ? { backupReady } : {}) }, this.now(), this.ownerNotices);+ const skipLimitReplay = this.options.skipLimitReplay?.() === true && this.scheduledRecurringRun(run);+ const recovery = recoverRun(run, failure, { ...facts, ...(backupReady ? { backupReady } : {}), ...(skipLimitReplay ? { skipLimitReplay } : {}) }, this.now(), this.ownerNotices);if (!recovery.queued) this.failRun(Object.assign(run, { partial: (facts.partial && Boolean(run.output)) || undefined }), recovery.error, "failed", recovery.alert);else {this.saveLater();@@ -1319,6 +1322,12 @@ export class RoutineManager {queueMicrotask(() => this.tickInBackground());}+ private scheduledRecurringRun(run: RoutineRun): boolean {+ if ((run.triggerSource ?? (run.manual ? "manual" : "schedule")) !== "schedule") return false;+ const type = this.routines.find((routine) => routine.id === run.routineId)?.schedule.type;+ return type !== undefined && type !== "once" && type !== "limit_reset";+ }+finishGoalRun(runId: string, status: GroupGoalRunStatus, detail: string): RoutineRun | null {const run = this.runs.find((candidate) => candidate.id === runId &&