Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Pause a bot or a whole department until it is resumed (#4740)

Azad Jagtapa72a3f1346e3
diff --git a/docs/pausing-bots.md b/docs/pausing-bots.md
new file mode 100644
index 0000000000..499767a780
--- /dev/null
+++ b/docs/pausing-bots.md
@@ -0,0 +1,41 @@
+# Pausing a bot or a department
+
+**Pause bot** (a bot's menu in the sidebar, under More) and **Pause department** (a department's menu) stop
+everything that bot or department is doing and keep it from starting anything new, until you choose **Resume**.
+It is the one switch for "stop all effort for now", for example to save what is left of a plan's usage.
+
+## What pausing does
+
+Right away, for every bot it pauses:
+
+- every conversation that is working stops, as Stop does, including the work it handed to other bots;
+- a routine run in progress is cancelled.
+
+Until it is resumed, a paused bot takes no new work:
+
+- a message to it is refused with a line saying it is paused and how to resume it;
+- its routines and webhooks don't run: each run that comes due fails with the same line, and the routine's card says
+ its bot is paused;
+- another bot that tries to hand it work is told it is paused, and not to route around it;
+- in a room it is skipped, and the room goes on with its other members;
+- the bot API and the headless CLI get `409` with code `bot_held`.
+
+Its conversations, memory, settings and routines are all kept: **Resume** picks up where it left off. A paused bot
+shows **Paused** under its name in the sidebar.
+
+A bot is paused by itself, or with its department. One paused with its department is resumed from the department's
+menu. A department keeps its pause when it is renamed; a bot moved into a paused department is paused with it.
+
+## Who can pause
+
+The owner of the server, or an admin on a Team Cloud. Each pause and resume is recorded in the admin activity log
+(`bot.pause`, `bot.resume`, `department.pause`, `department.resume`).
+
+This is separate from the Starter plan keeping only some bots awake: a bot can be paused for either reason, and is
+resumed for each in its own place.
+
+## API
+
+- `GET /api/paused`: `{ bots, departments, heldBots }`, what is paused and every bot that is held because of it.
+- `POST /api/paused` with `{ "kind": "bot" | "department", "id": "<bot id or department name>", "paused": true | false }`:
+ answers with the new state and `stopped`, how many conversations it stopped.
diff --git a/server/bot-pause.e2e.test.ts b/server/bot-pause.e2e.test.ts
new file mode 100644
index 0000000000..7eb303face
--- /dev/null
+++ b/server/bot-pause.e2e.test.ts
@@ -0,0 +1,63 @@
+// #4740 on a real server, its AI a fixture whose turns never end (FAKE_CLAUDE_MODE=hang), so there is always work to stop.
+import { randomUUID } from "node:crypto";
+import { afterAll, beforeAll, expect, it } from "vitest";
+
+import { launchVerificationServer, runControlOmb, type VerificationServer } from "../scripts/control-omb.ts";
+
+let fixture: VerificationServer;
+const call = async (method: string, path: string, body?: unknown) => {
+ const response = await fetch(fixture.info.url + path, {
+ method, headers: { "content-type": "application/json", origin: fixture.info.url }, ...(body === undefined ? {} : { body: JSON.stringify(body) }),
+ });
+ return { status: response.status, body: await response.json().catch(() => ({})) as Record<string, any> };
+};
+const ok = async (method: string, path: string, body?: unknown) => {
+ const answer = await call(method, path, body);
+ expect(answer.status, `${method} ${path}: ${JSON.stringify(answer.body)}`).toBeLessThan(300);
+ return answer.body;
+};
+const newBot = async (name: string) => (await runControlOmb(["new-bot", "--name", name, "--url", fixture.info.url]) as { bot: { id: string; activeTaskId: string } }).bot;
+const send = (bot: { id: string; activeTaskId: string }, text: string) => call("POST", `/api/bots/${bot.id}/messages`, { text, threadId: bot.activeTaskId, sendId: randomUUID() });
+const busy = async (botId: string) => ((await ok("GET", "/api/bots")).bots as Array<{ id: string; tasks?: Array<{ busy?: boolean }> }>)
+ .find((bot) => bot.id === botId)?.tasks?.some((task) => task.busy) === true;
+
+beforeAll(async () => { fixture = await launchVerificationServer({ ...process.env, FAKE_CLAUDE_MODE: "hang" }); }, 120_000);
+afterAll(async () => { await fixture?.close(); });
+
+it("pausing a bot stops its running work and refuses new work until it is resumed", async () => {
+ const ada = await newBot("Ada");
+ expect((await send(ada, "Start a long job.")).status).toBeLessThan(300);
+ await expect.poll(() => busy(ada.id), { timeout: 20_000 }).toBe(true);
+
+ expect(await ok("POST", "/api/paused", { kind: "bot", id: ada.id, paused: true })).toMatchObject({ bots: [ada.id], heldBots: [ada.id], stopped: 1 });
+ await expect.poll(() => busy(ada.id), { timeout: 20_000 }).toBe(false);
+ expect((await ok("GET", "/api/config")).heldBots).toEqual([ada.id]);
+
+ const refused = await send(ada, "One more thing.");
+ expect(refused.status).toBe(409);
+ expect(refused.body).toMatchObject({ code: "bot_held" });
+ expect(JSON.stringify(refused.body)).toContain("Ada is paused");
+
+ expect(await ok("POST", "/api/paused", { kind: "bot", id: ada.id, paused: false })).toMatchObject({ bots: [], heldBots: [], stopped: 0 });
+ expect((await send(ada, "Carry on.")).status).toBeLessThan(300);
+ await expect.poll(() => busy(ada.id), { timeout: 20_000 }).toBe(true);
+}, 120_000);
+
+it("pausing a department pauses its bots, keeps the pause through a rename, and leaves other bots working", async () => {
+ const bo = await newBot("Bo");
+ const cy = await newBot("Cy");
+ await ok("POST", "/api/sidebar-sections", { name: "Sales", botIds: [bo.id] });
+ expect(await ok("POST", "/api/paused", { kind: "department", id: "Sales", paused: true })).toMatchObject({ departments: ["Sales"], heldBots: expect.arrayContaining([bo.id]) });
+ const refused = await send(bo, "Hello.");
+ expect(refused.status).toBe(409);
+ expect(JSON.stringify(refused.body)).toContain("Sales department");
+ expect((await send(cy, "Hello.")).status).toBeLessThan(300);
+
+ await ok("PATCH", "/api/sidebar-sections?section=Sales", { name: "Revenue" });
+ expect(await ok("GET", "/api/paused")).toMatchObject({ departments: ["Revenue"], heldBots: expect.arrayContaining([bo.id]) });
+ expect((await send(bo, "Still there?")).status).toBe(409);
+
+ await ok("POST", "/api/paused", { kind: "department", id: "Revenue", paused: false });
+ expect((await send(bo, "Back to work.")).status).toBeLessThan(300);
+ expect((await call("POST", "/api/paused", { kind: "department", id: "Nowhere", paused: true })).status).toBe(404);
+}, 120_000);
diff --git a/server/host/bot-holds.test.ts b/server/host/bot-holds.test.ts
new file mode 100644
index 0000000000..d0cc9245be
--- /dev/null
+++ b/server/host/bot-holds.test.ts
@@ -0,0 +1,103 @@
+import { mkdtempSync, readFileSync, statSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import { createBotHoldRoutes } from "../routes/bot-holds.ts";
+import type { RouteContext } from "../routes/table.ts";
+import { removeTempDir } from "../testing/cleanup.ts";
+import { createBotHolds } from "./bot-holds.ts";
+
+const dirs: string[] = [];
+afterEach(async () => { for (const dir of dirs.splice(0)) await removeTempDir(dir); });
+
+function setup() {
+ const dataDir = mkdtempSync(join(tmpdir(), "omb-bot-holds-"));
+ dirs.push(dataDir);
+ const bots = [
+ { id: "ada", name: "Ada", section: "Sales" },
+ { id: "bo", name: "Bo", section: "Sales" },
+ { id: "cy", name: "Cy", section: "Support" },
+ { id: "di", name: "Di" },
+ ];
+ const changed = vi.fn();
+ const make = () => createBotHolds({ dataDir, bots: () => bots, changed,
+ line: (_language, key, params) => `${key}:${params.bot}${params.department ? `:${params.department}` : ""}` });
+ return { dataDir, bots, changed, make };
+}
+
+describe("pausing a bot or a department", () => {
+ it("pauses one bot, or every bot in a department, and says which way it was paused", () => {
+ const { make, changed } = setup();
+ const holds = make();
+ expect(holds.heldBots()).toEqual([]);
+ expect(holds.set("bot", "cy", true).newlyHeld).toEqual(["cy"]);
+ expect(holds.set("department", " Sales ", true).newlyHeld).toEqual(["ada", "bo"]);
+ expect(holds.heldBots()).toEqual(["ada", "bo", "cy"]);
+ expect(holds.held("di")).toBe(false);
+ expect(holds.text("cy")).toBe("server.botHeld:Cy");
+ expect(holds.text("ada")).toBe("server.botHeldDepartment:Ada:Sales");
+ expect(holds.text("di")).toBeNull();
+ expect(holds.handoff("ada")).toContain("@Ada is paused by the person (its Sales department is paused)");
+ expect(holds.handoff("di")).toBeNull();
+ expect(changed).toHaveBeenCalledTimes(2);
+ });
+
+ it("keeps the pause across restarts, in a file only this user reads", () => {
+ const { make, dataDir } = setup();
+ make().set("department", "Support", true);
+ expect(make().heldBots()).toEqual(["cy"]);
+ expect(statSync(join(dataDir, "paused-bots.json")).mode & 0o777).toBe(0o600);
+ expect(JSON.parse(readFileSync(join(dataDir, "paused-bots.json"), "utf8"))).toMatchObject({ bots: [], departments: ["Support"] });
+ });
+
+ it("resumes, follows a department's new name, and forgets what is gone", () => {
+ const { make, bots } = setup();
+ const holds = make();
+ holds.set("bot", "di", true);
+ holds.set("department", "Sales", true);
+ expect(holds.set("department", "Sales", false).newlyHeld).toEqual([]);
+ expect(holds.held("ada")).toBe(false);
+ holds.set("department", "Sales", true);
+ holds.rename("Sales", "Revenue");
+ for (const bot of bots) if (bot.section === "Sales") bot.section = "Revenue";
+ expect(holds.state().departments).toEqual(["Revenue"]);
+ expect(holds.held("ada")).toBe(true);
+ holds.forget("bot", "di");
+ holds.forget("department", "Revenue");
+ expect(holds.state()).toEqual({ bots: [], departments: [] });
+ });
+});
+
+describe("the pause routes", () => {
+ function call(routes: ReturnType<typeof createBotHoldRoutes>, method: string, body?: unknown) {
+ const out: { status?: number; body?: Record<string, unknown> } = {};
+ return routes({ req: {} as never, res: {} as never, url: new URL("http://x/api/paused"), path: "/api/paused", method, auth: { kind: "loopback" } as never,
+ json: ((_res: unknown, status: number, value: Record<string, unknown>) => { out.status = status; out.body = value; }) as never,
+ readBody: (async () => body) as never,
+ } as RouteContext).then(() => out);
+ }
+
+ it("pauses, stops only the bots that just became paused, records it, and resumes without stopping anything", async () => {
+ const { make } = setup();
+ const holds = make();
+ const stop = vi.fn(async (ids: readonly string[]) => ids.length);
+ const audit = vi.fn();
+ const routes = createBotHoldRoutes({ holds, stop, audit,
+ named: (kind, id) => (kind === "bot" ? ({ ada: "Ada", bo: "Bo" } as Record<string, string>)[id] ?? null : id === "Sales" ? "Sales" : null) });
+
+ expect(await call(routes, "POST", { kind: "bot", id: "ada", paused: true })).toMatchObject({ status: 200, body: { bots: ["ada"], heldBots: ["ada"], stopped: 1 } });
+ expect(await call(routes, "POST", { kind: "department", id: "Sales", paused: true })).toMatchObject({ status: 200, body: { heldBots: ["ada", "bo"], stopped: 1 } });
+ expect(stop.mock.calls).toEqual([[["ada"]], [["bo"]]]);
+ expect(await call(routes, "POST", { kind: "department", id: "Sales", paused: false })).toMatchObject({ status: 200, body: { heldBots: ["ada"], stopped: 0 } });
+ expect(stop).toHaveBeenCalledTimes(2);
+ expect(audit.mock.calls.map(([entry]) => entry)).toEqual([
+ { kind: "bot", id: "ada", name: "Ada", paused: true },
+ { kind: "department", id: "Sales", name: "Sales", paused: true },
+ { kind: "department", id: "Sales", name: "Sales", paused: false },
+ ]);
+ expect(await call(routes, "GET")).toMatchObject({ status: 200, body: { bots: ["ada"], departments: [], heldBots: ["ada"] } });
+ expect(await call(routes, "POST", { kind: "bot", id: "nobody", paused: true })).toMatchObject({ status: 404 });
+ expect(await call(routes, "POST", { kind: "room", id: "x", paused: true })).toMatchObject({ status: 400 });
+ });
+});
diff --git a/server/host/bot-holds.ts b/server/host/bot-holds.ts
new file mode 100644
index 0000000000..49508f8cda
--- /dev/null
+++ b/server/host/bot-holds.ts
@@ -0,0 +1,105 @@
+// Bots the person paused (#4740): one bot, or every bot in a department, takes no new work until it is resumed.
+// <data>/paused-bots.json keeps which bots and departments are paused; a bot is paused when it is named, or its
+// department is. Every way work starts asks here, beside the Starter plan's own pause (starter-caps.ts): a person's
+// message, the bot API, a routine or webhook run, a hand-off from another bot, and its turn in a room.
+import { readFileSync } from "node:fs";
+import { join } from "node:path";
+
+import { writeFileAtomic } from "../atomic.ts";
+import { sectionKey } from "../store.ts";
+
+export interface PausedState {
+ bots: string[];
+ departments: string[];
+}
+
+export interface BotHolds {
+ /** The bot takes no new work: it, or its department, is paused. */
+ held(botId: string): boolean;
+ /** Every paused bot, by itself or with its department. */
+ heldBots(): string[];
+ state(): PausedState;
+ /** The words a paused bot's turn is refused with, in this language; null when it is not paused. */
+ text(botId: string, language?: string): string | null;
+ /** What a bot that tried to hand it work is told; null when it is not paused. */
+ handoff(botId: string): string | null;
+ /** Pauses or resumes one bot or one department; the bots that became paused, so their running work can be stopped. */
+ set(kind: "bot" | "department", id: string, paused: boolean): { state: PausedState; newlyHeld: string[] };
+ /** A bot or department that is gone stops being remembered. */
+ forget(kind: "bot" | "department", id: string): void;
+ /** A paused department that is renamed stays paused under its new name. */
+ rename(from: string, to: string): void;
+}
+
+export function createBotHolds(deps: {
+ dataDir: string;
+ bots(): ReadonlyArray<{ id: string; name: string; section?: string }>;
+ /** serverLine(language, key, params) */
+ line(language: string | undefined, key: "server.botHeld" | "server.botHeldDepartment", params: Record<string, string>): string;
+ changed(): void;
+}): BotHolds {
+ const file = join(deps.dataDir, "paused-bots.json");
+ let state: PausedState = load();
+
+ function load(): PausedState {
+ try {
+ const raw = JSON.parse(readFileSync(file, "utf8")) as Partial<PausedState>;
+ const list = (value: unknown) => (Array.isArray(value) ? [...new Set(value.filter((item): item is string => typeof item === "string" && item.length > 0 && item.length <= 200))] : []);
+ return { bots: list(raw.bots), departments: list(raw.departments) };
+ } catch {
+ return { bots: [], departments: [] };
+ }
+ }
+
+ const save = () => {
+ writeFileAtomic(file, `${JSON.stringify({ v: 1, ...state }, null, 2)}\n`, { mode: 0o600 });
+ deps.changed();
+ };
+ const bot = (botId: string) => deps.bots().find((candidate) => candidate.id === botId);
+ /** The department that pauses this bot, if one does. */
+ const department = (found: { section?: string } | undefined) => {
+ const key = sectionKey(found?.section);
+ return key && state.departments.includes(key) ? key : null;
+ };
+ const held = (botId: string) => state.bots.includes(botId) || department(bot(botId)) !== null;
+
+ return {
+ held,
+ heldBots: () => deps.bots().filter((candidate) => state.bots.includes(candidate.id) || department(candidate) !== null).map((candidate) => candidate.id),
+ state: () => ({ bots: [...state.bots], departments: [...state.departments] }),
+ text(botId, language) {
+ const found = bot(botId);
+ if (!found || !held(botId)) return null;
+ const by = state.bots.includes(botId) ? null : department(found);
+ return by ? deps.line(language, "server.botHeldDepartment", { bot: found.name, department: by }) : deps.line(language, "server.botHeld", { bot: found.name });
+ },
+ handoff(botId) {
+ const found = bot(botId);
+ if (!found || !held(botId)) return null;
+ return `@${found.name} is paused by the person${state.bots.includes(botId) ? "" : ` (its ${department(found)} department is paused)`}, so nothing was handed to it. `
+ + "Tell the person in one line that they can resume it from its menu in the sidebar. Do not retry, and do not hand this to another bot to work around the pause.";
+ },
+ set(kind, id, paused) {
+ const before = new Set(this.heldBots());
+ const key = kind === "department" ? sectionKey(id) : id;
+ const list = kind === "bot" ? state.bots : state.departments;
+ const next = paused ? [...new Set([...list, key])] : list.filter((item) => item !== key);
+ state = kind === "bot" ? { ...state, bots: next } : { ...state, departments: next };
+ save();
+ return { state: this.state(), newlyHeld: this.heldBots().filter((botId) => !before.has(botId)) };
+ },
+ forget(kind, id) {
+ const list = kind === "bot" ? state.bots : state.departments;
+ const key = kind === "department" ? sectionKey(id) : id;
+ if (!list.includes(key)) return;
+ state = kind === "bot" ? { ...state, bots: list.filter((item) => item !== key) } : { ...state, departments: list.filter((item) => item !== key) };
+ save();
+ },
+ rename(from, to) {
+ const key = sectionKey(from);
+ if (!state.departments.includes(key)) return;
+ state = { ...state, departments: [...new Set(state.departments.map((item) => (item === key ? sectionKey(to) : item)))] };
+ save();
+ },
+ };
+}
diff --git a/server/index.ts b/server/index.ts
index e5c9bd32d2..936548d195 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -118,7 +118,7 @@ import { vpsLeftBehindNotice } from "./cloud-backend.ts";
import * as composio from "./composio.ts";
import { appSandboxRule, connectorCallFromFrame, connectorRefusalText, connectorScopeRefusalText, connectorUnrecognizedText, evaluateConnectorTools } from "./connector-verdict.ts";
import { signInCardText } from "./connector-card-text.ts";
-import { BOT_PAUSED_CODE } from "../shared/bot-limit.ts"; import { createStarterAwake } from "./host/starter-awake.ts"; import { createStarterCaps } from "./host/starter-caps.ts"; import { createStarterAwakeRoutes } from "./routes/starter-awake.ts"; import { chiefOfStaffSystemPrompt } from "./chief-of-staff.ts"; import { coordinateTooLong } from "./too-long.ts"; import { chiefAbsentFrom, createChiefRooms } from "./host/chief-rooms.ts"; import { chiefLevel, readTeamRolesWith } from "./chief-level.ts"; import { defaultBotRefusal, ensureDefaultBot } from "./default-bot.ts";
+import { BOT_HELD_CODE, BOT_PAUSED_CODE } from "../shared/bot-limit.ts"; import { createBotHolds } from "./host/bot-holds.ts"; import { createBotHoldRoutes } from "./routes/bot-holds.ts"; import { createStarterAwake } from "./host/starter-awake.ts"; import { createStarterCaps } from "./host/starter-caps.ts"; import { createStarterAwakeRoutes } from "./routes/starter-awake.ts"; import { chiefOfStaffSystemPrompt } from "./chief-of-staff.ts"; import { coordinateTooLong } from "./too-long.ts"; import { chiefAbsentFrom, createChiefRooms } from "./host/chief-rooms.ts"; import { chiefLevel, readTeamRolesWith } from "./chief-level.ts"; import { defaultBotRefusal, ensureDefaultBot } from "./default-bot.ts";
import { buildRecall, recallRooms, recallThreadIds, withRecalled } from "./recall.ts";
import { hostTimeZone, takesTurnClock, turnClockLine, withTurnClock } from "./turn-clock.ts";
import { createMemoryUpkeep, dreamConversations, upkeepEnabled } from "./memory-upkeep.ts";
@@ -2847,7 +2847,7 @@ const phones = createPhones({
mint: (botId, turn) => mintInternalCapability({ botId, ...turn, kind: "device", depth: 0, skillAuthoring: false, createdBots: 0, openedThreads: 0 }),
active: (turn) => internalCapabilityIsActive(turn as InternalCapability),
});
-const cloudPlanTier = createCloudPlanTier({ dataDir: DATA_DIR, cloudHome: Boolean(CLOUD_HOME), changed: () => broadcast({ kind: "config", ...configStatus() }) }); const starterAwake = createStarterAwake({ dataDir: DATA_DIR, starter: () => cloudPlanTier.starter(), bots: () => store.bots, changed: () => broadcast({ kind: "config", ...configStatus() }) }); const starterCaps = createStarterCaps({ starter: () => cloudPlanTier.starter(), awake: starterAwake, waitsOnOthers: (threadId) => coordinator.outstandingFor(threadId).length > 0, laneOwned: (threadId) => burst.laneOwned(threadId), botName: (botId) => store.bot(botId)?.name, pausedLine: (language, limit) => serverLine(language, "server.botPaused", { limit }), refused: () => broadcast({ kind: "config", ...configStatus() }) }); engineMemory.useCap(starterCaps.engine); let cloudPower: CloudPower | null = null; // The sleep handshake of a plan that sleeps (server/cloud-power.ts), made just before the server listens.
+const cloudPlanTier = createCloudPlanTier({ dataDir: DATA_DIR, cloudHome: Boolean(CLOUD_HOME), changed: () => broadcast({ kind: "config", ...configStatus() }) }); const starterAwake = createStarterAwake({ dataDir: DATA_DIR, starter: () => cloudPlanTier.starter(), bots: () => store.bots, changed: () => broadcast({ kind: "config", ...configStatus() }) }); const starterCaps = createStarterCaps({ starter: () => cloudPlanTier.starter(), awake: starterAwake, waitsOnOthers: (threadId) => coordinator.outstandingFor(threadId).length > 0, laneOwned: (threadId) => burst.laneOwned(threadId), botName: (botId) => store.bot(botId)?.name, pausedLine: (language, limit) => serverLine(language, "server.botPaused", { limit }), refused: () => broadcast({ kind: "config", ...configStatus() }) }); engineMemory.useCap(starterCaps.engine); const botHolds = createBotHolds({ dataDir: DATA_DIR, bots: () => store.bots, line: (language, key, params) => serverLine(language, key, params), changed: () => broadcast({ kind: "config", ...configStatus() }) }); let cloudPower: CloudPower | null = null; // The sleep handshake of a plan that sleeps (server/cloud-power.ts), made just before the server listens.
const teamWelcome = createTeamWelcomeStore(DATA_DIR); const { cloudHealth, cloudSigned } = createCloudSignedHost({ cloudHome: CLOUD_HOME, sessions, power: () => cloudPower, box: () => botBox.report(), teamAdmin: teamAdminHost(), policyChanged: nudgeCloudTeamPolicy, invited: (email, by) => teamWelcome.invited(personKey({ id: "", email }), by), memberBrowserOff: () => managedPolicy.remoteAccessRefusal() !== undefined, plan: (cancelled) => routineHolds?.plan(cancelled), planTier: (tier) => cloudPlanTier.set(tier), memberLeft: (email) => leaveTeam ? leaveTeam(email).then((result) => { botApi.manager.revokeMintedBy(personKey({ id: "", email })); teamOwners.left(email); teamMessages.inbox.forget(personKey({ id: "", email })); forgetSetupPresser(store, personKey({ id: "", email })); devsReports.forget(personKey({ id: "", email })); return result; }) : Promise.reject(new Error("not a team")), health: { store, bus, dataDir: DATA_DIR, eventsDir: EVENTS_DIR, version: serverVersion(), image: process.env.OMB_CLOUD_IMAGE,
engines: () => registry.instances().map((instance) => ({ instanceId: instance.instanceId, driverKind: instance.driverKind, snapshot: registry.knownSnapshot(instance.instanceId) })),
connectors: () => emailHost.health(composio.configured(cfg) ? composio.connectedServices(cfg) : null),
@@ -3908,7 +3908,7 @@ const questionRouting = createQuestionRouting({ store, handedInUnproven, active:
steer: async (threadId, text) => canSteerThread(threadId) && (await steerThread(threadId, text)) !== "refused", mayReach: outsideLineage.mayReach });
const handoffTicks = createHandoffTicks(), coordinator: Coordinator = createCoordinator({
dataDir: DATA_DIR,
- now: Date.now, wrote: handoffTicks.kick, handoffLimit: starterCaps.handoffs,
+ now: Date.now, wrote: handoffTicks.kick, handoffLimit: { refusal: (botId, open) => botHolds.handoff(botId) ?? starterCaps.handoffs.refusal(botId, open) },
log: line => console.error("coordinator:", line),
legacyThreads: {
standingThreadOf: botId => botMainThread(botId) ?? store.bot(botId)?.threadId,
@@ -5128,7 +5128,7 @@ const setupSuggestions = setupSuggestionsFor({ store, config: () => cfg, shared:
withinBudget: () => { try { assertWithinBudget(cfg, DATA_DIR); return true; } catch { return false; } }, writer: (botId) => sideJobs.text("setup-suggestions", botId), apps: { configured: () => composio.configured(cfg), mode: () => composio.connectionMode(cfg), connected: () => composio.connectedServices(cfg) }, log: (line) => console.log(line) });
const memoryUpkeep = createMemoryUpkeep({
- bots: () => { const paused = new Set(starterAwake.paused()); return store.bots.filter((bot) => !paused.has(bot.id)); },
+ bots: () => { const paused = new Set(starterAwake.paused()); return store.bots.filter((bot) => !paused.has(bot.id) && !botHolds.held(bot.id)); },
bot: (id) => store.bot(teamHost.baseBotId(id)) ?? undefined,
engine: (botId) => sideJobs.text("memory", teamHost.baseBotId(botId)),
busy: (botId) => botHasActiveTurn(teamHost.baseBotId(botId)),
@@ -7557,7 +7557,7 @@ async function beginTurn(
workspaceMaintenance.assertAvailable(); moveFreeze.assertTurns();
const profile = store.bot(botId); assertBotHere(profile);
if (!profile) throw Object.assign(new Error("no such bot"), { status: 404 });
- const threadId = opts?.threadId ?? profile.threadId, paused = starterCaps.pausedText(botId, threadLanguage(threadId)); if (paused) throw Object.assign(new Error(paused), { status: 409, code: BOT_PAUSED_CODE });
+ const threadId = opts?.threadId ?? profile.threadId, paused = botHolds.text(botId, threadLanguage(threadId)) ?? starterCaps.pausedText(botId, threadLanguage(threadId)); if (paused) throw Object.assign(new Error(paused), { status: 409, code: botHolds.held(botId) ? BOT_HELD_CODE : BOT_PAUSED_CODE });
const continuingRoutine = opts?.cardContinuation ? activeRoutineRunForThread(threadId) : null;
if (continuingRoutine) {
const onDispatchError = opts?.onDispatchError;
@@ -8785,7 +8785,7 @@ routines = new RoutineManager({
skipStartupRuns: (startedFromSleep = Boolean(CLOUD_HOME) && wokeFromSleep(DATA_DIR)), // a Cloud home waking from a sleep it was stopped for
hasPendingDelegations: runtimeWorkPending, refusedHandoff: refusedHandoffs.take, handedOffWorkLive: (threadId) => coordinator.outstandingFor(threadId).length > 0,
routineTurn: (threadId) => directRequestOwners.get(threadId)?.automation !== undefined, personTurn: (threadId) => directRequestOwners.get(threadId)?.origin?.kind === "user",
- botState: unattendedDispatchState, pausedText: (botId) => starterCaps.pausedText(botId, threadLanguage(store.bot(botId)?.threadId ?? "")),
+ botState: unattendedDispatchState, pausedText: (botId) => botHolds.text(botId, threadLanguage(store.bot(botId)?.threadId ?? "")) ?? starterCaps.pausedText(botId, threadLanguage(store.bot(botId)?.threadId ?? "")),
goalState: (groupId, coordinatorBotId) => {
if (!groupId) return unattendedDispatchState(coordinatorBotId);
const group = store.group(groupId);
@@ -9627,11 +9627,11 @@ async function runClaimedGroupMemberTurn(
? group.threadId === threadId
: Boolean(group && store.groupTaskByThread(group.id, threadId));
if (!group || !bot || !ownsThread) return false;
- if (roomHeld(group, bot.id)) {
+ if (roomHeld(group, bot.id) || botHolds.held(bot.id)) {
noteHeldSkip(group.id, threadId, bot, latestRoomTextId(threadId));
if (orchestration) {
orchestration.result.outcome = "unavailable";
- orchestration.result.stopReason = heldMemberLine(bot.name);
+ orchestration.result.stopReason = roomHeld(group, bot.id) ? heldMemberLine(bot.name) : botHolds.text(bot.id, threadLanguage(threadId))!;
}
return true;
}
@@ -11693,7 +11693,7 @@ function configStatus() {
const eventLogMaxBytes = threadEventLogMaxBytes(cfg);
const eventLogRetentionDays = threadEventLogRetentionDays(cfg);
return {
- cloudStarter: cloudPlanTier.starter(), waitingForRoom: engineMemory.waiting(), planTurns: starterCaps.status(), awakeLimit: starterAwake.limit(), pausedBots: starterAwake.paused(), xai: keyStatus(cfg.xai?.key),
+ cloudStarter: cloudPlanTier.starter(), waitingForRoom: engineMemory.waiting(), planTurns: starterCaps.status(), awakeLimit: starterAwake.limit(), pausedBots: starterAwake.paused(), pausedByPerson: botHolds.state(), heldBots: botHolds.heldBots(), xai: keyStatus(cfg.xai?.key),
mistral: keyStatus(cfg.mistral?.key),
cerebras: keyStatus(cfg.cerebras?.key),
groq: keyStatus(cfg.groq?.key), greenference: keyStatus(cfg.greenference?.key), modelgo: keyStatus(cfg.modelgo?.key),
@@ -12057,7 +12057,7 @@ const cloudMoveRoutes = createCloudMoveRoutes();
// `workspaceAccess` is assigned at boot, after this line: read it per request.
ROUTES.push(createHostedSlackRoutes({ bot: (id) => store.bot(id), hostedReady: () => Boolean(workspaceAccess) && entitled("admin") })); ROUTES.push(createStopLineRoutes());
const orgInstallStatuses = () => orgLibrary?.installStatuses() ?? new Map();
-ROUTES.push(createBotPresetRoutes({ presets: presetStore, orgStatuses: orgInstallStatuses })); ROUTES.push(createWorkspaceBannerRoutes({ changed: () => broadcast({ kind: "config", ...configStatus() }) })); const starterAwakeRoutes = createStarterAwakeRoutes({ awake: starterAwake }); ROUTES.push(starterAwakeRoutes);
+ROUTES.push(createBotPresetRoutes({ presets: presetStore, orgStatuses: orgInstallStatuses })); ROUTES.push(createBotHoldRoutes({ holds: botHolds, named: (kind, id) => (kind === "bot" ? store.bot(id)?.name ?? null : store.sections.includes(id.trim()) ? id.trim() : null), stop: async (botIds) => { let stopped = 0; for (const botId of botIds) for (const { threadId } of store.tasks(botId)) if (threadBusy(botId, threadId) || coordinator.activeDirect(threadId)) { await stopThreadForPerson(botId, threadId); stopped++; } return stopped; }, audit: (entry, auth, req) => { if (!DESKTOP_MANAGED && adminActivityRecording()) appendAdminAction(DATA_DIR, { category: "bot", action: `${entry.kind}.${entry.paused ? "pause" : "resume"}`, target: { kind: entry.kind, id: entry.id, name: entry.name }, actor: adminActorFor(auth, req) }); } })); ROUTES.push(createWorkspaceBannerRoutes({ changed: () => broadcast({ kind: "config", ...configStatus() }) })); const starterAwakeRoutes = createStarterAwakeRoutes({ awake: starterAwake }); ROUTES.push(starterAwakeRoutes);
ROUTES.push(createSharedComputerRoutes({ enabled: (auth) => lendingEnabled() || (ownerLends() && ownHome.owner(auth)), computers: sharedComputers, sessionLive: (id) => sessions.isLive(id), environmentId: ENVIRONMENT_ID,
cloudHomeLender: CLOUD_HOME ? CLOUD_HOME_LENDER : null, principal: sessionLendingPrincipal, personKey: (session) => lendingPersonKey(session, ownHome.ownServer()), power: () => cloudPower, links: CLOUD_HOME ? deviceLinks : null, upgrades, asks: computerAsks?.asks ?? null, answerer: cardAnswererFor }));
// `routines` is assigned at boot, so it is read per request.
@@ -12170,7 +12170,7 @@ ROUTES.push(createBotMemoryRoutes({
}));
const teamMoveIn = CLOUD_TEAM ? createTeamMoveIn({ team: CLOUD_TEAM, dataDir: DATA_DIR, sessions, store, routines: () => routines, library: () => readSkillLibraryIndex(), starters: threadStarters }) : null; const cloudSendOwner = (auth: RequestAuth) => teamMoveIn ? teamMoveIn.owner(auth) : (CLOUD_HOME && auth.kind === "session" && auth.scopes.includes("admin")) || ownHome.owner(auth) ? { person: actorKey(auth as RequestAuth & { kind: "session" }), name: cfg.profile?.name?.trim() || "User" } : null; const botMoves = CLOUD_PERSONAL || DESKTOP_MANAGED ? createBotMoves({ store, routines: () => routines, webhooks: () => webhooks, appEvents: () => appTriggers.manager, waits: () => botWaits, busy: (id) => botHasActiveTurn(id) || Boolean(routines?.activeRunForBot(id)) }) : null; ROUTES.push(createBotMoveRoutes({ moves: botMoves, enabled: Boolean(botMoves) })); if (teamMoveIn) { ROUTES.unshift(teamMoveIn.guard); ROUTES.push(teamMoveIn.routes); teamOwners.backfill(teamMoveIn.list()); } ROUTES.push(createDeciderRoutes({ decider, extractor, config: () => cfg }), createImageSettingsRoutes({ config: () => cfg }), createTtsRoutes({ config: () => cfg }), createHelperSuggestionRoutes({ notNow: proactive.suggestionNotNow }), createSetupRequestRoutes({ store, language: () => appLanguage() ?? Intl.DateTimeFormat().resolvedOptions().locale, sendRefusal: cloudGuestSendRefusal, presser: (auth) => setupPresser(sharedMembership(), auth, messageSender(auth)), canSetUp: (botId, threadId) => registry.get(store.projectBotForTask(botId, threadId)?.modelSelection.instanceId ?? "")?.adapter.capabilities.agentsMcp === true, send: (auth, botId, threadId, text) => acceptDirectSend({ botId, threadId, text, sender: messageSender(auth), trigger: usageTriggerFor(auth), personPresent: auth.kind === "session" || DESKTOP_MANAGED }) }), createNotificationRoutes(undefined, notificationListed), createUpdateCheckRoutes(updateRouteDeps({ desktopManaged: DESKTOP_MANAGED, managed: Boolean(CLOUD_HOME || HOSTED_WORKSPACE), dataDir: DATA_DIR, activeTurns: () => liveTurnByThread.size, actor: adminActorFor })), createSeatsRoutes({ signInList: signInAllowList, sessions: () => sessions.list() }), createTimeZoneRoutes({ adopts: Boolean(CLOUD_HOME), dataDir: DATA_DIR, changed: () => routines?.rescheduleLocalTimes() }), createCloudSendRoutes({ appVersion: serverVersion(), ...(CLOUD_TEAM ? { refusal: personalMoveRefusal(CLOUD_TEAM), scope: (auth) => teamMoveIn?.scope(auth) ?? null } : {}), bots: () => store.bots, messagesTail: (threadId, limit) => store.messagesTail(threadId, limit), skills: (bot) => listSkills(bot.id), logins, config: () => cfg, lineLanguage: personLanguages.forLine, chats: { store, dataDir: DATA_DIR, owner: cloudSendOwner, ...(CLOUD_OWNER_KEY ? { ownerKey: CLOUD_OWNER_KEY } : {}), stamped: (threadId) => ownerOnlyCache.delete(threadId), instanceExists: (id) => Boolean(registry.get(id)), approvalSupported: (selection, mode) => supportsApprovalMode(selection, mode) }, cloudHome: Boolean(CLOUD_HOME), ownHome: ownHome.owner, automations: { routines: () => routines, calls: () => calendarCalls, webhooks: () => webhooks, appEvents: () => appTriggers.manager, waits: () => botWaits }, connectionsMoved: (language) => cloudConnections.moved(language), connections: () => cloudConnections.connections(), connectionFingerprints: (nonce) => cloudConnections.fingerprints(nonce), move: { dataDir: DATA_DIR, store, routines: () => routines, calls: () => calendarCalls, webhooks: () => webhooks, appEvents: () => appTriggers.manager, claudeCodeSkills: () => (claudeUserSkillsEnabled(cfg) ? claudeCodeSkillInputs() : []), instanceExists: (id) => Boolean(registry.get(id)), owner: cloudSendOwner, ownRoutine: (routine, person) => { cloudRoutineAuthors?.record(routine.id, routine); cloudRoutineAuthors?.wrote(routine.id, person); }, arrived: () => ownerOnlyCache.clear(), teamMemory, aboutMe: () => cfg.profile?.aboutMe ?? "", saveAboutMe: (text) => { saveConfig({ profile: { ...cfg.profile, aboutMe: text } }); Object.assign(cfg, loadConfig()); broadcast({ kind: "config", ...configStatus() }); } } }), cloudConnections.routes, createTodayRoutes({ visibleFor: (auth) => visibleTo(viewerFor(auth)), ...(teamOwners.asks ? { asks: teamOwners.asks, messages: teamMessages.needsYou } : {}), sources: () => ({ bots: store.bots, groups: store.groups, routines, parked: coordinator.active(), engines: registry.instances().map((instance) => ({ instanceId: instance.instanceId, snapshot: registry.lastSnapshot(instance.instanceId) })) }) }), createInboxRoutes(teamMessages)); const conversationSharing = createConversationSharing({ team: CLOUD_TEAM, store: () => store, shares: conversationShares, saves: createTeamMemorySaves({ dataDir: DATA_DIR }), starter: (threadId) => threadStarters.get(threadId), audienceOf: teamHost.audienceOf, sees: (auth, threadId) => visibleTo(viewerFor(auth)).thread(threadId), levelOf, levelFor: (person, botId) => visibleTo(person.role === "member" ? { kind: "member", email: person.email } : { kind: "all", email: person.email }).level(botId), people: () => teamOwners.people?.list() ?? [], nameOf: (email) => teamHost.personName(personKey({ id: "", email })) ?? email, language: (person) => personLanguages.forLine(person), busy: threadBusy, routinesIn: (threadId) => (routines?.listRoutines() ?? []).filter((routine) => routine.sourceThreadId === threadId || routine.resultsThreadId === threadId).length, outside: cloudGuestDriven, audienceChanged: (botId, threadId) => { store.patchTask(botId, threadId, { rewound: true, resumeCursors: {} }); }, changed: (botId) => { const bot = store.bot(botId); if (bot) broadcast({ kind: "bot", bot: wireBot(bot) }); }, inbox: () => teamMessages.inbox, looking: (email, threadId) => teamPresence.looking(email, threadId), notify, botOf: (threadId) => store.botByThread(threadId)?.id, handTo: (threadId, person) => threadStarters.handTo(threadId, person) }); ROUTES.push(conversationSharing.routes);
if (CLOUD_TEAM) teamHost.adoptServerProfile(sessions.list().flatMap((session) => session.email ? [session.email] : []));
-const sidebarRoutes = createSidebarSectionRoutes({ store, teamComputers, maxBots: MAX_WORKSPACE_BOTS, assertTeamComputerChangeIdle, wireBot }); ROUTES.push(teamPresence.routes, sidebarRoutes, createPresenceRoutes({ isOwner: ownerOrAdmin, heard: (auth, language) => personLanguages.heard(auth.kind === "session" ? actorKey(auth) : THIS_COMPUTER, language), sawChat: (_auth, threadId) => { if (store.botByThread(threadId)) sawThread(threadId); }, active: async (source, zone, language) => { const answer = await proactive.brief.active(source, zone, language); firstHourHooks.arrived(); return answer; }, ...(CLOUD_TEAM ? { member: (auth) => { noAiNotice.flush(); return teamMessages.arrived(auth); } } : {}) }), createMeRoutes({ team: CLOUD_TEAM, session: (auth) => (auth.kind === "session" ? auth.session : null), welcome: teamWelcome, profile: teamHost.memberProfile, save: teamHost.saveMemberProfile, seed: teamHost.seedMemberProfile, seeded: teamHost.seededFields, changed: () => broadcast({ kind: "config", ...configStatus() }) }), teamAway.routes, createTeamPhoneRoutes({ team: CLOUD_TEAM, sessions, publicBase: (req, auth) => pairingLinkBase(publicUrl(), auth.kind === "session" ? requestOrigin(req) : null) }),
+const sidebarRoutes = createSidebarSectionRoutes({ store, teamComputers, maxBots: MAX_WORKSPACE_BOTS, assertTeamComputerChangeIdle, wireBot, renamed: (from, to) => (to ? botHolds.rename(from, to) : botHolds.forget("department", from)) }); ROUTES.push(teamPresence.routes, sidebarRoutes, createPresenceRoutes({ isOwner: ownerOrAdmin, heard: (auth, language) => personLanguages.heard(auth.kind === "session" ? actorKey(auth) : THIS_COMPUTER, language), sawChat: (_auth, threadId) => { if (store.botByThread(threadId)) sawThread(threadId); }, active: async (source, zone, language) => { const answer = await proactive.brief.active(source, zone, language); firstHourHooks.arrived(); return answer; }, ...(CLOUD_TEAM ? { member: (auth) => { noAiNotice.flush(); return teamMessages.arrived(auth); } } : {}) }), createMeRoutes({ team: CLOUD_TEAM, session: (auth) => (auth.kind === "session" ? auth.session : null), welcome: teamWelcome, profile: teamHost.memberProfile, save: teamHost.saveMemberProfile, seed: teamHost.seedMemberProfile, seeded: teamHost.seededFields, changed: () => broadcast({ kind: "config", ...configStatus() }) }), teamAway.routes, createTeamPhoneRoutes({ team: CLOUD_TEAM, sessions, publicBase: (req, auth) => pairingLinkBase(publicUrl(), auth.kind === "session" ? requestOrigin(req) : null) }),
createTeamConnectionRoutes({ host: teamConnections, cfg: () => cfg, composio, policy: managedPolicy, publicOrigin: CLOUD_HOME?.publicOrigin ?? null, record: (auth, row) => appendAdminAction(DATA_DIR, { ...row, actor: decisionActorFor(auth) }) }), createSignInCardRoutes({ settle: signInSettle.settle, saveLogin: (botId, threadId, messageId, body, auth) => CLOUD_TEAM && !auth.scopes.includes("admin") ? Promise.resolve({ status: 403 as const, body: memberLoginRefusal(CLOUD_TEAM) }) : saveLoginFromCard(botId, threadId, messageId, body), saveTarget: signInSaveTarget, threadVisible: (auth, threadId) => visibleTo(viewerFor(auth)).thread(threadId), vault: createSignInVaultChoices({ logins, cardBots: (id) => botLogins.cardBots(id), settle: signInSettle.settle, openCard: (botId, threadId, messageId) => { const card = signInMessage(botId, threadId, messageId)?.signIn; return card && card.place === "browser" && !card.superseded && !card.answeredInChat && !card.stopped && !signInOutcome(card) ? card : null; } }) })); const appSuggestions = createAppSuggestions({ dataDir: DATA_DIR, store, configured: () => composio.configured(cfg), catalog: () => composio.listToolkits(cfg), services: () => composio.connectedServices(cfg), offerable: (slug) => !managedPolicy.appRefusal(slug) && !managedConnectorUnavailableReason(composio.connectionMode(cfg), slug) && !teamConnections.personApps().includes(slug), pickAvailable: () => appPickAvailable(cfg), decider }); ROUTES.push(createAppSuggestionRoutes(appSuggestions));
ROUTES.push(createRoomHoldRoutes({
group: (id) => store.group(id),
@@ -15222,7 +15222,7 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {
} catch (e) {
const status = (e as any)?.status ?? 500;
const candidateCode = (e as { code?: unknown })?.code;
- const code = typeof candidateCode === "string" && ["guarded_busy", "guarded_branch", "guarded_permissions", "guarded_request_changed", "guarded_request_untracked", "outside_workspace", "file_too_large", "no_ai", BOT_PAUSED_CODE].includes(candidateCode)
+ const code = typeof candidateCode === "string" && ["guarded_busy", "guarded_branch", "guarded_permissions", "guarded_request_changed", "guarded_request_untracked", "outside_workspace", "file_too_large", "no_ai", BOT_PAUSED_CODE, BOT_HELD_CODE].includes(candidateCode)
? candidateCode : undefined;
return json(res, status, { error: e instanceof Error ? e.message : String(e), ...(code ? { code } : {}), ...userErrorFields(e), ...cloudLimitFields(e) });
} finally {
@@ -15305,7 +15305,7 @@ if (CLOUD_HOME) registerCloudPower(cloudPower = createCloudPower({ dataDir: DATA
liveCall: () => liveCalls.current() !== null, computer: () => cloudComputerPower.awake() || boatLifecycleBusyBots.size > 0, nextDueAt: () => { const due = [routines?.nextDueAt() ?? null, proactive.brief.nextWakeAt(), botWaits.nextWakeAt()].filter((at): at is number => at !== null); return due.length ? Math.min(...due) : null; },
maintenance: () => workspaceMaintenance.active || providerFleetReloading || providerAuthSessions.active || browserEngineInstall !== null } }));
-let pausedSent = starterAwake.paused().join(); store.onChange((change) => { if (change.type !== "bot" && change.type !== "bot.deleted") return; const paused = starterAwake.paused().join(); if (paused !== pausedSent) { pausedSent = paused; broadcast({ kind: "config", ...configStatus() }); } });
+let pausedSent = starterAwake.paused().join(); store.onChange((change) => { if (change.type === "bot.deleted") botHolds.forget("bot", change.botId); if (change.type !== "bot" && change.type !== "bot.deleted") return; const paused = starterAwake.paused().join(); if (paused !== pausedSent) { pausedSent = paused; broadcast({ kind: "config", ...configStatus() }); } });
server.listen(PORT, listenHost(server), async () => {
companyRuntimeReady(); cloudHealth?.speed.ready(); void tailnetShare.start(process.env);
console.log(`openmausbot server on http://127.0.0.1:${PORT}`);
diff --git a/server/routes/bot-holds.ts b/server/routes/bot-holds.ts
new file mode 100644
index 0000000000..cbab5d69f7
--- /dev/null
+++ b/server/routes/bot-holds.ts
@@ -0,0 +1,37 @@
+// Pausing a bot or a department (#4740): GET what is paused; POST {kind, id, paused} pauses or resumes one, and pausing
+// also stops the work its bots are doing now. Admin-scope routes: on a Team Cloud only an owner or admin pauses.
+import type { IncomingMessage } from "node:http";
+import { z } from "zod";
+
+import type { BotHolds } from "../host/bot-holds.ts";
+import type { RequestAuth } from "../request-auth.ts";
+import { PASS, type RouteHandler } from "./table.ts";
+
+export interface BotHoldRouteDeps {
+ holds: BotHolds;
+ /** The bot's or department's name when it exists here; null when it does not. */
+ named(kind: "bot" | "department", id: string): string | null;
+ /** Stops every running turn, routine run and hand-off of these bots; how many conversations it stopped. */
+ stop(botIds: readonly string[]): Promise<number>;
+ /** Records the change in the admin activity log. */
+ audit(entry: { kind: "bot" | "department"; id: string; name: string; paused: boolean }, auth: RequestAuth, req: IncomingMessage): void;
+}
+
+const body = z.object({ kind: z.enum(["bot", "department"]), id: z.string().trim().min(1).max(200), paused: z.boolean() }).strict();
+
+export function createBotHoldRoutes(deps: BotHoldRouteDeps): RouteHandler {
+ return async ({ req, res, path, method, auth, json, readBody }) => {
+ if (path !== "/api/paused") return PASS;
+ if (method === "GET") return void json(res, 200, { ...deps.holds.state(), heldBots: deps.holds.heldBots() });
+ if (method !== "POST") return PASS;
+ const parsed = body.safeParse(await readBody(req, 4_096).catch(() => null));
+ if (!parsed.success) return void json(res, 400, { error: "Send kind (bot or department), id and paused (true or false)." });
+ const { kind, id, paused } = parsed.data;
+ const name = deps.named(kind, id);
+ if (name === null) return void json(res, 404, { error: kind === "bot" ? "No such bot." : "No such department." });
+ const { state, newlyHeld } = deps.holds.set(kind, id, paused);
+ const stopped = paused && newlyHeld.length ? await deps.stop(newlyHeld) : 0;
+ deps.audit({ kind, id, name, paused }, auth, req);
+ json(res, 200, { ...state, heldBots: deps.holds.heldBots(), stopped });
+ };
+}
diff --git a/server/routes/sidebar-sections.ts b/server/routes/sidebar-sections.ts
index 7bc3df18a5..c8e60ec930 100644
--- a/server/routes/sidebar-sections.ts
+++ b/server/routes/sidebar-sections.ts
@@ -20,6 +20,8 @@ export interface SidebarSectionRouteDeps {
maxBots: number;
assertTeamComputerChangeIdle(before: BotRecord, after: BotRecord): void;
wireBot(bot: BotRecord): WireBot;
+ /** A department was renamed (`to`) or deleted (null): what is kept about it by name follows. */
+ renamed?(from: string, to: string | null): void;
}
export function createSidebarSectionRoutes(deps: SidebarSectionRouteDeps): RouteHandler {
@@ -46,6 +48,7 @@ export function createSidebarSectionRoutes(deps: SidebarSectionRouteDeps): Route
}
const error = nextName === null ? store.deleteSection(section) : store.renameSection(section, nextName, teamComputers);
if (error) return json(res, error === "No such department" ? 404 : 409, storeRefusal(error));
+ deps.renamed?.(section, nextName);
return json(res, 200, { sections: store.sections });
}
if (method === "PUT" && path === "/api/sidebar-sections") {
diff --git a/shared/bot-limit.ts b/shared/bot-limit.ts
index 93d3bcb270..ebd921af7e 100644
--- a/shared/bot-limit.ts
+++ b/shared/bot-limit.ts
@@ -7,6 +7,9 @@ export const BOT_LIMIT_CODE = "bot_limit";
/** The code on a turn refused because its bot is paused: a Starter Cloud keeps only so many bots awake. */
export const BOT_PAUSED_CODE = "bot_paused";
+/** The code on a turn refused because the person paused its bot, or its department (Pause in the sidebar menus). */
+export const BOT_HELD_CODE = "bot_held";
+
/** The bots a plan's awake limit counts. A place's MausBot comes with it; an archived bot or one that moved away isn't at work here. */
export function botsTowardLimit(bots: ReadonlyArray<Pick<DefaultBotFields, "defaultBot"> & { hidden?: boolean; movedTo?: unknown }>): number {
return bots.filter((bot) => !bot.defaultBot && !bot.hidden && !bot.movedTo).length;
diff --git a/src/components/PauseMenus.dom.test.ts b/src/components/PauseMenus.dom.test.ts
new file mode 100644
index 0000000000..bbc0aee2d8
--- /dev/null
+++ b/src/components/PauseMenus.dom.test.ts
@@ -0,0 +1,54 @@
+// @vitest-environment happy-dom
+import { act, createElement } from "react";
+import { createRoot, type Root } from "react-dom/client";
+import { afterEach, beforeEach, expect, it, vi } from "vitest";
+
+const fixture = vi.hoisted(() => ({
+ calls: [] as Array<{ path: string; body: unknown }>,
+ admin: true as boolean | null,
+ config: { pausedByPerson: { bots: [] as string[], departments: [] as string[] }, heldBots: [] as string[] },
+}));
+vi.mock("@/state/api", () => ({ api: async (path: string, init: { body: string }) => { fixture.calls.push({ path, body: JSON.parse(init.body) }); return { stopped: 2 }; } }));
+vi.mock("@/state/store", () => ({ api: vi.fn(), useStore: () => ({ state: { config: fixture.config, bots: [], groups: [] }, dispatch: vi.fn() }) }));
+vi.mock("@/lib/use-owner-or-admin", () => ({ useOwnerOrAdmin: () => fixture.admin }));
+import { TeamMenuItems } from "./SidebarTeamMenu";
+import { RoutineList } from "./routines/RoutineList";
+
+let container: HTMLDivElement, root: Root;
+beforeEach(() => {
+ vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
+ fixture.calls = [];
+ fixture.admin = true;
+ fixture.config = { pausedByPerson: { bots: [], departments: [] }, heldBots: [] };
+ container = document.createElement("div"); document.body.append(container); root = createRoot(container);
+});
+afterEach(async () => { await act(async () => root.unmount()); container.remove(); vi.unstubAllGlobals(); });
+
+const menu = (onRead = vi.fn()) => createElement(TeamMenuItems, { department: "Sales", onRead, onAddBots: vi.fn(), onRename: vi.fn(), onShare: vi.fn(), onDelete: vi.fn() });
+
+it("lets an admin pause a department, and resume it once paused", async () => {
+ const onRead = vi.fn();
+ await act(async () => root.render(menu(onRead)));
+ const pause = container.querySelector<HTMLButtonElement>('[data-team-pause="pause"]')!;
+ expect(pause.textContent).toBe("Pause department");
+ await act(async () => pause.click());
+ expect(fixture.calls).toEqual([{ path: "/api/paused", body: { kind: "department", id: "Sales", paused: true } }]);
+ expect(onRead).toHaveBeenCalled();
+
+ fixture.config = { pausedByPerson: { bots: [], departments: ["Sales"] }, heldBots: [] };
+ await act(async () => root.render(menu()));
+ expect(container.querySelector('[data-team-pause="resume"]')!.textContent).toBe("Resume department");
+});
+
+it("offers nothing to someone who is not an owner or admin", async () => {
+ fixture.admin = false;
+ await act(async () => root.render(menu()));
+ expect(container.querySelector("[data-team-pause]")).toBeNull();
+});
+
+it("says on a routine that its bot is paused", async () => {
+ const routine = { id: "r1", botId: "ada", name: "Morning report", enabled: true, schedule: { type: "daily", time: "09:00", weekdays: [1, 2, 3, 4, 5] }, prompt: "x" };
+ await act(async () => root.render(createElement(RoutineList, { routines: [routine] as never, runs: [], bots: [{ id: "ada", name: "Ada" }] as never, heldBots: ["ada"],
+ loading: false, error: false, onOpen: vi.fn(), onLogs: vi.fn(), onToggle: vi.fn() })));
+ expect(container.querySelector("[data-routine-bot-held]")!.textContent).toBe("Its bot is paused, so this routine won’t run until the bot is resumed.");
+});
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index f3eb4d0283..38a8bc5e83 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -18,7 +18,7 @@ import { searchMatchesThreads, useSearchDisclosure } from "@/lib/search-disclosu
import { useHeldMenuMotion, useMenuMotion } from "./MenuMotion";
import { lastNonReceipt } from "@/lib/receipts";
import { botPreview, groupPreview } from "./sidebar-preview";
-import { activeLocale, t } from "@/lib/i18n";
+import { activeLocale, t } from "@/lib/i18n"; import { isBotHeld } from "@/lib/bot-pause";
import { copyText } from "@/lib/copy-text";
import type { LocaleKey } from "@/locales";
import { ConfirmDialog } from "./ConfirmDialog";
@@ -655,7 +655,7 @@ export interface BotRowProps {
instances: InstanceInfo[];
liveCall: AppState["liveCall"];
locale: string;
- generatedTitles: boolean;
+ generatedTitles: boolean; /** Paused by the person, by itself or with its department: it takes no new work. */ held?: boolean;
density: SidebarDensity;
query: string;
dispatch: Dispatch<Action>;
@@ -685,7 +685,7 @@ export function botRowProps<State extends Pick<AppState, "activeView" | "selecte
instances: state.instances,
liveCall: state.liveCall,
locale: activeLocale(),
- generatedTitles: llmThreadTitlesEnabled(state.config),
+ generatedTitles: llmThreadTitlesEnabled(state.config), held: isBotHeld(state.config, bot.id),
dispatch,
};
}
@@ -717,7 +717,7 @@ export const BotListItem = memo(function BotListItem(props: BotRowProps) {
const visible = useVisibleMessages(bot);
const last = lastNonReceipt(visible);
const title = bot.title.trim();
- const details = [title, bot.chiefOfStaff ? t("sidebar.bot.chiefOfStaff") : ""].filter(Boolean);
+ const details = [props.held ? t("pause.badge") : "", title, bot.chiefOfStaff ? t("sidebar.bot.chiefOfStaff") : ""].filter(Boolean);
const rowClass = cn(
"flex w-full items-center rounded-xl text-left transition-colors duration-150", SIMPLE_ROW_FOCUS,
iconOnly
diff --git a/src/components/SidebarBotMenu.tsx b/src/components/SidebarBotMenu.tsx
index e9b0ba0c8d..67a2f13b22 100644
--- a/src/components/SidebarBotMenu.tsx
+++ b/src/components/SidebarBotMenu.tsx
@@ -1,6 +1,7 @@
import { useEffect, useLayoutEffect, useRef, useState } from "react";
import { createPortal } from "react-dom";
-import { Archive, BellDot, Check, CheckCheck, ChevronRight, ClipboardCopy, Copy, Crown, FolderMinus, FolderOpen, FolderPlus, Loader2, MessagesSquare, MoreHorizontal, Pencil, Pin, PinOff, SquarePen, Star, Trash2, Users } from "lucide-react";
+import { Archive, BellDot, Check, CheckCheck, ChevronRight, ClipboardCopy, Copy, Crown, FolderMinus, FolderOpen, FolderPlus, Loader2, MessagesSquare, MoreHorizontal, Pause, Pencil, Pin, PinOff, Play, SquarePen, Star, Trash2, Users } from "lucide-react";
+import { isBotHeld, isPausedHere, setPaused } from "@/lib/bot-pause";
import { api, useStore, openBot, type Bot } from "@/state/store";
import { cn } from "@/lib/cn";
import { useHeldMenuMotion } from "./MenuMotion";
@@ -262,8 +263,15 @@ export function BotContextMenu({
{ disabled: readingBotId !== null, keepOpen: true },
)
: item(<BellDot size={16} className="text-ink-secondary" />, t("sidebar.bot.simple.markUnread"), () => dispatch({ type: "markUnread", botId: bot.id }));
+ // Only the owner or an admin pauses; a bot paused with its department is resumed from the department's menu.
+ const pausedHere = isPausedHere(state.config, "bot", bot.id);
+ const pause = admin !== true ? null : item(pausedHere ? <Play size={16} className="text-ink-secondary" /> : <Pause size={16} className="text-ink-secondary" />,
+ t(pausedHere ? "pause.resumeBot" : "pause.pauseBot"),
+ () => { void setPaused("bot", bot.id, !pausedHere).catch((error: unknown) => dispatch({ type: "error", message: error instanceof Error ? error.message : String(error) })); },
+ !pausedHere && isBotHeld(state.config, bot.id) ? { disabled: true, hint: t("pause.byDepartment") } : undefined);
const moreItems = remoteClient ? [editProfile, owner, ...deleteAll] : [
editProfile,
+ pause,
team ? null : chiefItem(),
member && !ownEdit ? null : item(<Copy size={16} className="text-ink-secondary" />, t("sidebar.bot.duplicate"), () => dispatch({ type: "duplicateBot", botId: bot.id })),
owner,
diff --git a/src/components/SidebarBotRead.test.ts b/src/components/SidebarBotRead.test.ts
index 6e01febb09..d4cc09a72e 100644
--- a/src/components/SidebarBotRead.test.ts
+++ b/src/components/SidebarBotRead.test.ts
@@ -169,7 +169,7 @@ describe("Simple mode's bot menu", () => {
point(more(), 200);
await wait(320);
expect(flyout()).not.toBeNull();
- expect([...flyout()!.querySelectorAll("button")].map((node) => node.textContent)).toEqual(["Edit profile", "Make Chief of Staff", "Duplicate", "Delete all conversations…"]);
+ expect([...flyout()!.querySelectorAll("button")].map((node) => node.textContent)).toEqual(["Edit profile", "Pause bot", "Make Chief of Staff", "Duplicate", "Delete all conversations…"]);
point(pin, 80);
await wait(20);
expect(flyout()).toBeNull();
diff --git a/src/components/SidebarTeamMenu.tsx b/src/components/SidebarTeamMenu.tsx
index 9763646c1a..8c453012ef 100644
--- a/src/components/SidebarTeamMenu.tsx
+++ b/src/components/SidebarTeamMenu.tsx
@@ -1,5 +1,7 @@
import { useState } from "react";
-import { CheckCheck, Loader2, Share2, SlidersHorizontal, SquarePen, Trash2, Users } from "lucide-react";
+import { CheckCheck, Loader2, Pause, Play, Share2, SlidersHorizontal, SquarePen, Trash2, Users } from "lucide-react";
+import { isPausedHere, setPaused } from "@/lib/bot-pause";
+import { useOwnerOrAdmin } from "@/lib/use-owner-or-admin";
import { cn } from "@/lib/cn";
import { departmentUnread, markDepartmentRead } from "@/lib/folder-read";
import { t } from "@/lib/i18n";
@@ -29,6 +31,28 @@ function MarkDepartmentRead({ name, className, onDone }: { name: string; classNa
</button>;
}
+/** Pause or resume every bot in the department: only the owner or an admin. */
+function PauseDepartment({ name, className, onDone }: { name: string; className: string; onDone: () => void }) {
+ const { state, dispatch } = useStore();
+ const [saving, setSaving] = useState(false);
+ if (useOwnerOrAdmin() !== true) return null;
+ const paused = isPausedHere(state.config, "department", name);
+ const toggle = async () => {
+ setSaving(true);
+ try {
+ await setPaused("department", name, !paused);
+ onDone();
+ } catch (error) {
+ dispatch({ type: "error", message: error instanceof Error ? error.message : String(error) });
+ } finally {
+ setSaving(false);
+ }
+ };
+ return <button type="button" role="menuitem" data-team-pause={paused ? "resume" : "pause"} className={className} disabled={saving} onClick={() => void toggle()}>
+ {saving ? <Loader2 size={16} className="animate-spin" /> : paused ? <Play size={16} /> : <Pause size={16} />}{t(paused ? "pause.resumeDepartment" : "pause.pauseDepartment")}
+ </button>;
+}
+
export function TeamMenuItems({ onAddBots, onRename, onShare, onDelete, onSetForAll, department, onRead }: {
/** The department this menu is for: with it, the menu offers Mark all as read. */
department?: string;
@@ -44,6 +68,7 @@ export function TeamMenuItems({ onAddBots, onRename, onShare, onDelete, onSetFor
<>
<button type="button" role="menuitem" autoFocus className={item} onClick={onAddBots}><Users size={16} />{t("team.addBots")}</button>
{department !== undefined && <MarkDepartmentRead name={department} className={cn(item, "disabled:opacity-60")} onDone={onRead ?? (() => {})} />}
+ {department !== undefined && <PauseDepartment name={department} className={cn(item, "disabled:opacity-60")} onDone={onRead ?? (() => {})} />}
{onSetForAll && <button type="button" role="menuitem" className={item} onClick={onSetForAll}><SlidersHorizontal size={16} />{t("teamSettings.menu")}</button>}
<button type="button" role="menuitem" className={item} onClick={onRename}><SquarePen size={16} />{t("team.rename")}</button>
<button type="button" role="menuitem" className={item} onClick={onShare}><Share2 size={16} />{t("team.share")}</button>
diff --git a/src/components/bot-panel/pages.tsx b/src/components/bot-panel/pages.tsx
index 1f460a8646..3cab2897dc 100644
--- a/src/components/bot-panel/pages.tsx
+++ b/src/components/bot-panel/pages.tsx
@@ -144,6 +144,7 @@ export function RoutinesPage({ bot, derived }: PageContext) {
routines={derived.botRoutines}
runs={state.routineRuns}
pausedBots={state.config?.pausedBots}
+ heldBots={state.config?.heldBots}
loading={state.routinesLoadState === "loading" && derived.botRoutines.length === 0}
error={state.routinesLoadState === "error"}
onOpen={setEditing}
diff --git a/src/components/bot-settings/RoutinesSection.tsx b/src/components/bot-settings/RoutinesSection.tsx
index 9cf470cca4..d775c78009 100644
--- a/src/components/bot-settings/RoutinesSection.tsx
+++ b/src/components/bot-settings/RoutinesSection.tsx
@@ -17,7 +17,7 @@ export function RoutinesSection({ bot, routines, runs, defaultRunOn }: { bot: Bo
<button type="button" onClick={() => dispatch({ type: "showRoutines", section: "logs", botId: bot.id })} className="flex items-center gap-1.5 rounded-lg bg-control px-3 py-2 text-[12px] text-ink hover:bg-raised-hover"><FileText size={13} />{t("routines.logs")}</button>
</div>
</div>
- <RoutineList routines={routines} runs={runs} pausedBots={state.config?.pausedBots} loading={state.routinesLoadState === "loading" && routines.length === 0} error={state.routinesLoadState === "error"} onOpen={setEditing} onLogs={(routine) => dispatch({ type: "showRoutines", section: "logs", botId: bot.id, routineId: routine.id })} onToggle={(routine) => dispatch({ type: "updateRoutine", routineId: routine.id, patch: { enabled: !routine.enabled } })} />
+ <RoutineList routines={routines} runs={runs} pausedBots={state.config?.pausedBots} heldBots={state.config?.heldBots} loading={state.routinesLoadState === "loading" && routines.length === 0} error={state.routinesLoadState === "error"} onOpen={setEditing} onLogs={(routine) => dispatch({ type: "showRoutines", section: "logs", botId: bot.id, routineId: routine.id })} onToggle={(routine) => dispatch({ type: "updateRoutine", routineId: routine.id, patch: { enabled: !routine.enabled } })} />
<button type="button" onClick={() => dispatch({ type: "showRoutines", section: "schedule", view: "list", botId: bot.id })} className="self-start text-[12px] text-accent hover:underline">{t("computer.routines.openTitle")} <ChevronRight size={14} aria-hidden="true" className="inline align-[-2px] rtl:-scale-x-100" /></button>
{editing && <RoutineEditor key={bot.id} routine={editing === "new" ? undefined : editing} bots={[bot]} lockedBotId={bot.id} defaultRunOn={defaultRunOn} onClose={() => setEditing(null)} />}
</div>;
diff --git a/src/components/routines/RoutineList.tsx b/src/components/routines/RoutineList.tsx
index 3f7cd25739..2a874df256 100644
--- a/src/components/routines/RoutineList.tsx
+++ b/src/components/routines/RoutineList.tsx
@@ -8,12 +8,14 @@ import { latestRoutineRun, routineDateTime, routineFinished, routineHeldNote, ro
import type { Bot } from "@/state/store";
import { Switch } from "../SettingsPrimitives";
-export function RoutineList({ routines, runs, bots, pausedBots, loading, error, onOpen, onLogs, onToggle }: {
+export function RoutineList({ routines, runs, bots, pausedBots, heldBots, loading, error, onOpen, onLogs, onToggle }: {
routines: Routine[];
runs: RoutineRun[];
bots?: Bot[];
/** Bots a Starter Cloud has paused: a routine on one runs nothing until it is swapped in. */
pausedBots?: readonly string[];
+ /** Bots the person paused, by themselves or with their department. */
+ heldBots?: readonly string[];
loading?: boolean;
error?: boolean;
onOpen: (routine: Routine) => void;
@@ -55,6 +57,7 @@ export function RoutineList({ routines, runs, bots, pausedBots, loading, error,
{t("routines.botPaused")}{" "}
<button type="button" className="cursor-pointer text-accent hover:underline" onClick={() => showBotLimit("paused")}>{t("routines.botPausedSwap")}</button>
</p>}
+ {routine.enabled && heldBots?.includes(routine.botId) && <p className="mt-2 text-[12px] leading-relaxed text-warning" data-routine-bot-held="">{t("routines.botHeld")}</p>}
{routine.heldFor && <p className="mt-2 text-[12px] leading-relaxed text-ink-secondary">{routineHeldNote(routine)}</p>}
{!!routine.skippedRuns && <p className="mt-2 text-[12px] text-ink-secondary">
{t("routines.skippedRuns", { count: routine.skippedRuns })}
diff --git a/src/lib/bot-pause.ts b/src/lib/bot-pause.ts
new file mode 100644
index 0000000000..74c6ddbe3e
--- /dev/null
+++ b/src/lib/bot-pause.ts
@@ -0,0 +1,28 @@
+// Pausing a bot or a department (#4740): it takes no new work, and what it is doing now stops, until it is resumed. The
+// server sends the new state to every open app in its config frame.
+import type { ConfigStatus } from "@/state/store";
+import { api } from "@/state/api";
+
+export type PauseKind = "bot" | "department";
+
+export interface PausedByPerson {
+ bots: string[];
+ departments: string[];
+}
+
+const NONE: PausedByPerson = { bots: [], departments: [] };
+
+export const pausedByPerson = (config: Pick<ConfigStatus, "pausedByPerson"> | null | undefined): PausedByPerson => config?.pausedByPerson ?? NONE;
+
+/** Paused by itself (a bot) or by name (a department); a bot paused only with its department is resumed from there. */
+export function isPausedHere(config: Pick<ConfigStatus, "pausedByPerson"> | null | undefined, kind: PauseKind, id: string): boolean {
+ const state = pausedByPerson(config);
+ return kind === "bot" ? state.bots.includes(id) : state.departments.includes(id.trim());
+}
+
+/** Taking no new work, by itself or with its department. */
+export const isBotHeld = (config: Pick<ConfigStatus, "heldBots"> | null | undefined, botId: string): boolean => config?.heldBots?.includes(botId) === true;
+
+export async function setPaused(kind: PauseKind, id: string, paused: boolean): Promise<{ stopped: number }> {
+ return api<{ stopped: number }>("/api/paused", { method: "POST", body: JSON.stringify({ kind, id, paused }), timeoutMs: 60_000 });
+}
diff --git a/src/locales/de.json b/src/locales/de.json
index 899a5070a9..42d262c14f 100644
--- a/src/locales/de.json
+++ b/src/locales/de.json
@@ -216,6 +216,8 @@
"server.planTurns.wait": "Wartet auf einen Platz: Starter führt auf dieser Cloud {limit} Aufgaben gleichzeitig aus. Davor in der Reihe: {ahead}. Es startet von selbst, sobald eine fertig ist, und ein größerer Plan führt mehr gleichzeitig aus.",
"server.planTurns.still": "Wartet noch: Starter führt {limit} Aufgaben gleichzeitig aus. Davor in der Reihe: {ahead}.",
"server.botPaused": "Pausiert: Starter hält {limit} Bots wach. Führe ein Upgrade durch, um ihn zu wecken, oder tausche, welche Bots wach sind.",
+ "server.botHeld": "{bot} ist pausiert und nimmt keine neue Arbeit an. Setze ihn über sein Menü in der Seitenleiste fort.",
+ "server.botHeldDepartment": "{bot} ist mit der Abteilung {department} pausiert und nimmt keine neue Arbeit an. Setze die Abteilung über ihr Menü in der Seitenleiste fort.",
"server.teammates.queued.thread": "{bot} hat damit noch nicht begonnen: Ein früherer Durchlauf in diesem Thread läuft noch.",
"server.teammates.queued.slots": "{bot} hat damit noch nicht begonnen: Es laufen bereits {busy} von {limit} Threads gleichzeitig.",
"server.teammates.queued.room": "{bot} hat damit noch nicht begonnen: Es beendet gerade einen Durchlauf in einem Raum.",
diff --git a/src/locales/en.json b/src/locales/en.json
index 0c69f377ca..c8cdfa48b3 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -352,6 +352,15 @@
"server.planTurns.wait": "Waiting for a turn: Starter runs {limit} tasks at once on this Cloud. Ahead of this one: {ahead}. It starts by itself when one finishes, and a bigger plan runs more at once.",
"server.planTurns.still": "Still waiting: Starter runs {limit} tasks at once. Ahead of this one: {ahead}.",
"server.botPaused": "Paused: Starter keeps {limit} bots awake. Upgrade to wake it, or swap which bots are awake.",
+ "server.botHeld": "{bot} is paused, so it takes no new work. Resume it from its menu in the sidebar.",
+ "server.botHeldDepartment": "{bot} is paused with the {department} department, so it takes no new work. Resume the department from its menu in the sidebar.",
+ "pause.pauseBot": "Pause bot",
+ "pause.resumeBot": "Resume bot",
+ "pause.pauseDepartment": "Pause department",
+ "pause.resumeDepartment": "Resume department",
+ "pause.byDepartment": "Paused with its department: resume the department",
+ "pause.badge": "Paused",
+ "routines.botHeld": "Its bot is paused, so this routine won’t run until the bot is resumed.",
"server.teammates.queued.thread": "{bot} hasn't started this yet: an earlier turn in that thread is still running.",
"server.teammates.queued.slots": "{bot} hasn't started this yet: it's already running {busy} of {limit} threads at once.",
"server.teammates.queued.room": "{bot} hasn't started this yet: it's finishing a turn in a room.",
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index 61883bfcdd..90b9c6082a 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -335,6 +335,15 @@
"server.planTurns.wait": "Aguardando a vez: o Starter roda {limit} tarefas ao mesmo tempo nesta Cloud. À frente desta: {ahead}. Ela começa sozinha quando uma terminar, e um plano maior roda mais ao mesmo tempo.",
"server.planTurns.still": "Ainda aguardando: o Starter roda {limit} tarefas ao mesmo tempo. À frente desta: {ahead}.",
"server.botPaused": "Pausado: o Starter mantém {limit} bots ativos. Faça upgrade para ativá-lo ou troque quais bots ficam ativos.",
+ "server.botHeld": "{bot} está pausado e não recebe trabalho novo. Retome-o pelo menu dele na barra lateral.",
+ "server.botHeldDepartment": "{bot} está pausado junto com o departamento {department} e não recebe trabalho novo. Retome o departamento pelo menu dele na barra lateral.",
+ "pause.pauseBot": "Pausar bot",
+ "pause.resumeBot": "Retomar bot",
+ "pause.pauseDepartment": "Pausar departamento",
+ "pause.resumeDepartment": "Retomar departamento",
+ "pause.byDepartment": "Pausado junto com o departamento: retome o departamento",
+ "pause.badge": "Pausado",
+ "routines.botHeld": "O bot está pausado, então esta rotina não roda até ele ser retomado.",
"server.teammates.queued.thread": "{bot} ainda não começou esta tarefa: uma sessão anterior nessa conversa ainda está em andamento.",
"server.teammates.queued.slots": "{bot} ainda não começou esta tarefa. Conversas simultâneas em andamento: {busy} de {limit}.",
"server.teammates.queued.room": "{bot} ainda não começou esta tarefa: está terminando uma sessão em um grupo.",
diff --git a/src/state/config-status.ts b/src/state/config-status.ts
index 221dbd39b9..4de7063de8 100644
--- a/src/state/config-status.ts
+++ b/src/state/config-status.ts
@@ -69,6 +69,10 @@ export interface ConfigStatus {
awakeLimit?: number;
/** Bots paused for the plan's limit: kept, but taking no turns. */
pausedBots?: string[];
+ /** What the person paused (Pause in the sidebar menus): bots by id and departments by name. Absent from older servers. */
+ pausedByPerson?: { bots: string[]; departments: string[] };
+ /** Every bot taking no new work because the person paused it or its department. */
+ heldBots?: string[];
threads?: { maxConcurrentPerBot: number; eventLogMaxBytes?: number; eventLogRetentionDays?: number };
automaticRecovery?: { enabled: boolean; backup?: ModelSelection };
/** Prompt-cache keep-warm for idle Claude threads. Absent from older servers. */