Skip to content

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

15.0 KB
Raw Blame
// What GET /api/config tells the app about the server and its settings (re-exported by store.tsx).
import type { EffortLevel, LiveSettings } from "../../shared/wire";
import type { ImageComplexity, ImageProvider } from "../../shared/image-generation";
import type { FishSynthesis, FishTtsModel } from "../../shared/fish-voice";
import type { ToolGroup } from "../../shared/tool-groups";
import type { VoicePlaybackRate } from "../../shared/voice-playback";
import type { OnboardingStatus } from "@/lib/onboarding";
import type { ModelSelection } from "./store";

/** A saved credential: whether it is set and, for admins, its last four characters. The key itself never comes back. */
export interface SavedKey { configured: boolean; last4?: string }

export type NestedKeyName = "ttsKey" | "fishAudioKey" | "geminiTtsKey" | "cartesiaTtsKey" | "jevApiKey" | "openrouterDeciderKey" | "workersAiToken" | "customDeciderKey" | "openaiImageApiKey" | "customImageApiKey" | "openaiLiveKey" | "geminiImageApiKey";

export interface ImageSlotStatus { provider: ImageProvider; model: string; configured: boolean }

export interface OpenAiCompatCustomHeadersSummary {
  enabled: boolean;
  headers: Array<{ name: string; value?: string; configured: boolean; required: boolean; secret: boolean }>;
}

/** GET /api/config — configured flags only; secrets are never echoed. */
export interface ConfigStatus {
  /** The workspace's banner picture (GET /api/workspace/banner), by a version that changes with it; null without one. */
  workspaceBanner?: import("@/lib/place-banner").BannerSummary | null;
  xai?: SavedKey;
  mistral?: SavedKey;
  cerebras?: SavedKey;
  groq?: SavedKey;
  greenference?: SavedKey;
  modelgo?: SavedKey;
  deepseek?: SavedKey;
  meta?: SavedKey;
  /** X research comes with MausBot Cloud plans: `included` while this server holds the plan's relay credential;
   * `unavailable` when the Admin said no to this desktop's paid sign-in. */
  xResearch?: { included: boolean; unavailable?: boolean };
  /** The built-in tool groups this workspace has, the ones a bot's Settings offer to turn off. */
  toolGroups?: ToolGroup[];
  /** The person's own treg key for research: configured or not, never the key. */
  treg?: SavedKey;
  /** The Postiz organisation API key, and the Postiz server it belongs to when it is not Postiz Cloud. */
  postiz?: SavedKey & { url?: string };
  /** `everyClaudeBot`: the key runs every Claude bot, not only "Claude (API key)". */
  anthropic?: SavedKey & { everyClaudeBot?: boolean };
  openai?: SavedKey;
  openrouter?: SavedKey;
  openaiCompat?: SavedKey & {
    url?: string;
    customHeaders?: OpenAiCompatCustomHeadersSummary | { configured: boolean };
  };
  /** what this server is entitled to; Settings shows only what works here.
   * `license` reaches admins only, and only while the key is inside its
   * warning window or grace period. */
  edition?: {
    edition: "oss" | "enterprise";
    features: string[];
    license?: { expiresAt: string; expiresInDays: number; graceEndsAt?: string };
  };
  /** a fleet agent exists on this server (Settings → Workspaces) */
  fleet?: { available: boolean };
  budgets?: { monthlyUsd?: number; warnAtPercent?: number };
  billing?: { currency?: string; prices?: Record<string, { inputPerMillion: number; outputPerMillion: number; cachedInputPerMillion?: number }> };
  composio: SavedKey & { mode?: "managed" | "self-hosted" | "unavailable" };
  /** `included`: cloud computers come with Cloud Pro, no key is saved. */
  box: SavedKey & { included?: boolean; /** A pasted API key is saved (`configured` is also true for a sign-in alone). */ keySaved?: boolean; signIn?: import("../../shared/boat-sign-in").BoatSignInStatus };
  /** `servers`: named servers for the per-bot picker; empty for client sessions, missing from an older server. */
  vps: { configured: boolean; sshAlias: string; servers?: { name: string; sshAlias: string; memoryGb?: number; cpus?: number }[]; memoryGb?: number; cpus?: number };
  rooms: { turnTimeoutMinutes: number };
  /** Per-call ceiling (minutes) for a bot's MCP tools. Absent from servers
   * older than the setting; read it with mcpCallTimeoutMinutes(). */
  mcp?: { callTimeoutMinutes: number };
  /** Workspace defaults for new bots; absent effort = no level is sent. */
  newBots?: { effort?: EffortLevel };
  /** This Cloud is on the Starter plan, as the Admin last said; absent or false otherwise. */
  cloudStarter?: boolean;
  /** The most bots this Cloud's plan makes, its MausBot aside. Sent only by servers that capped Starter's bots; absent otherwise. */
  botLimit?: number;
  /** A task on this Cloud is waiting for memory right now. */
  waitingForRoom?: boolean;
  /** On Starter: the turns it runs at once and the hand-offs it holds waiting, and when work was last refused for a limit. */
  planTurns?: { running: number; waiting: number; refusedAt?: number; refused?: "tasks" | "paused" };
  /** On Starter: how many bots stay awake; absent when every bot does. */
  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[]; all?: true };
  /** Every bot taking no new work because the person paused it or its department. */
  heldBots?: string[];
  /** The server cannot read its saved routines, so none runs until it can. */
  routinesUnreadable?: true;
  threads?: { maxConcurrentPerBot: number; eventLogMaxBytes?: number; eventLogRetentionDays?: number };
  threadTitles?: { model: Pick<ModelSelection, "instanceId" | "model"> | null; followUp: boolean; instances: string[] };
  automaticRecovery?: { enabled: boolean; backup?: ModelSelection };
  /** Prompt-cache keep-warm for idle Claude threads. Absent from older servers. */
  cacheKeepWarm?: { enabled: boolean; windowMinutes: number };
  localVm: { mode: "shared" | "per-bot" | "pool"; maxInstances: number; idleTimeoutMinutes?: number; preserveInstalledApps?: boolean };
  /** `providerKeys`: names of the keys saved for OpenCode's other
   * providers, never the keys. */
  opencodeGo?: SavedKey & { providerKeys?: string[] };
  /** Voice. `configured` = the engine has what it needs (an ElevenLabs or
   * Fish Audio, Gemini or xAI key, or a Chatterbox server address); `ready` = that AND a voice, which is
   * what it takes to actually speak. The key itself is never echoed back;
   * `baseUrl` is the Chatterbox address; `model` selects Chatterbox or Gemini speech. */
  tts?: {
    configured: boolean;
    ready: boolean;
    voice: string;
    provider?: "elevenlabs" | "fish" | "system" | "chatterbox" | "xai" | "gemini" | "openai" | "deepseek" | "cartesia";
    baseUrl?: string;
    model?: string;
    /** Voice note with every reply, for every bot without its own choice. Absent from older servers. */
    everyReply?: boolean;
    playbackRate?: VoicePlaybackRate;
    /** "elevenlabs": the person chose to be heard through their own ElevenLabs key (Scribe). Absent: the default. */
    hearWith?: "elevenlabs";
    /** The language the person speaks to Scribe (ISO 639 code); absent lets Scribe detect it. */
    hearLanguage?: string;
    /** Fish Audio speech model; present only while Fish is the provider. */
    fishModel?: FishTtsModel;
    fishSynthesis?: FishSynthesis;
    /** ElevenLabs voice comes with Cloud Pro; no key is saved. */
    included?: boolean;
  };
  /** The decision model: switches and whether a key is on file. The key
   * itself never comes back. `enabled` is the switch as it takes effect
   * (off while no key is saved). `included`: Cloud Pro's decisions, no key
   * saved. OpenRouter only: `keySource` says which key is in use (its own, or
   * the one under Settings → API keys); `sharedKey`: that one is on file. */
  decider?: {
    provider: "jev" | "workersai" | "openrouter" | "custom" | "gemini";
    /** Jev, when the person picked it but the shared OpenRouter key decides until a Jev key is saved; OpenRouter, when
     * it was picked but a saved Gemini key decides until an OpenRouter key is saved. */
    chosen?: "jev" | "openrouter";
    /** The OpenRouter or custom model in use; present only while that is the provider. */
    model?: string;
    /** The custom endpoint's protocol, or the OpenRouter API. */
    api?: "chat" | "decisions" | "systemone";
    /** The custom endpoint's base URL (the person's own setting, not a secret); custom only. */
    baseUrl?: string;
    configured: boolean;
    keySource?: "own" | "shared";
    sharedKey?: boolean;
    included?: boolean;
    enabled: boolean;
    jobs: { roomRouting: boolean; turnEffort?: boolean };
  };
  /** The decision and extraction models' keys: which of the person's own are on file, never a key. */
  helpers?: {
    own: { jev: boolean; workersAi: boolean; openrouter: boolean };
    sharedKey?: boolean;
    workersAiAccountId?: string;
    extraction: { provider?: "jev" | "workersai" | "openrouter"; included?: boolean; ready: boolean };
  };
  /** Live calls (OpenAI GPT-Live): configured-or-not, never the key. */
  live?: LiveSettings;
  /** Keys kept inside another setting (voice, decisions, pictures, live calls), by their desktop credential name. */
  savedKeys?: Partial<Record<NestedKeyName, SavedKey>>;
  imageGen?: {
    configured: boolean;
    provider?: ImageProvider;
    model?: string;
    primary?: ImageSlotStatus;
    fallback?: ImageSlotStatus | null;
    ready?: boolean;
    maxPerTurn?: number;
    complexity?: ImageComplexity;
    customUrl?: string;
    customModel?: string;
    openaiConfigured?: boolean;
    xaiConfigured?: boolean;
    customKeyConfigured?: boolean;
    geminiConfigured?: boolean;
    openrouterConfigured?: boolean;
  };
  /** who's using the app — collected in onboarding, shown in the sidebar */
  profile?: { name: string; email: string; aboutMe?: string; avatarUrl?: string };
  /** Rules every bot follows, ahead of its department's context and its own instructions; sent to admins only. */
  everyBotRules?: string;
  /** UI language override; "" (or absent) follows the system language. */
  language?: string;
  /** What a paired phone calls this computer; "" uses the default. */
  computerName?: string;
  /** Opt-in flags. Absent means off. */
  features?: { skillAuthoring: boolean; skillReview?: boolean; skillReviewSteps?: number; showToolCalls?: boolean; browser?: boolean; sharedComputers?: boolean; claudeUserMcp?: boolean; skillsLibrary?: boolean; shareLearnedSkills?: "off" | "ask" | "auto"; roomMemoryCapture?: boolean; savedSteps?: boolean; savedStepsHere?: boolean; usbPhoneTakeover?: boolean; skillBurger?: boolean; threadTabs?: boolean; roomFeed?: boolean; roomFeedSince?: number; suggestedReplies?: boolean; promotions?: boolean };
  /** First-run progress: whether the welcome tour was finished and which
   * one-time hints were dismissed. Server-owned so it follows the workspace. */
  onboarding?: OnboardingStatus;
  /** Which browser this server can give bots: the desktop app's surface, the
   * agent-browser engine, or nothing yet (with the reason). */
  browserEngine?: BrowserEngineSummary;
  /** Named browser sessions any bot can be pointed at. */
  browserProfiles?: BrowserProfile[];
  /** The enrolled organisation's read-only desktop policy; null when this
   * desktop is not enrolled or its Admin sends no policy. */
  managedPolicy?: ManagedPolicySummary | null;
  /** This server is an OMB Cloud home: it offers no "this computer" and no
   * Local VM (server/cloud-home.ts). Absent everywhere else. */
  cloudHome?: boolean;
  /** A Team Cloud: the team this server is the home of, and the Plan page (MausBot Cloud) where its people and plan
   * are managed. Absent everywhere else. */
  team?: { id: string; name: string; cloudPage?: string };
}

export interface ManagedPolicySummary {
  organizationName: string;
  version: number;
  companyModelsOnly: boolean;
  allowedEngines: "all" | string[];
  mcp: { allowCustom: boolean; allowlist: string[] };
  computers: { thisComputer: boolean; localVm: boolean; box: boolean; vps: boolean };
  remoteAccess: boolean;
  /** Connected apps by service slug; absent from an older Team Cloud and from an organisation's policy. */
  apps?: { allowAll: boolean; allowlist: string[] };
  /** A Team Cloud's rules rather than an organisation's. */
  team?: true;
}

export interface BrowserEngineSummary {
  kind: "engine" | "unavailable";
  reason?: string;
  installable?: boolean;
  version?: string;
  /** The browser the engine starts, e.g. "Google Chrome 153 (installed)", or while Chrome for Testing downloads,
   * "Chrome for Testing 153.0.8010.47 (downloading: 52 of 182 MB)". */
  chrome?: string;
  /** agent-browser runs Chromium's headless shell, which many sites refuse, only because no Google Chrome is installed here. */
  noChrome?: true;
  installing?: boolean;
  installError?: string;
  /** Whether a browser profile can use "My Chrome", the person's own running
   * Chrome: only where the bots run on their computer (the desktop app). */
  myChrome?: boolean;
  /** On My Cloud, the computer that lends its Chrome. */
  myChromeOn?: { name: string; device: "PC" | "Mac" | "computer"; online: boolean };
  /** On My Cloud with no computer lending Chrome: it can be lent from the desktop app. */
  myChromeLendable?: true;
  /** browserEngine.engine: "chrome" when the bots' browsers run on OpenMausBot's own Chrome driver. */
  engine?: "agent-browser" | "chrome";
  /** The desktop app shows the Chrome engine's browsers as panes the person uses directly (browserEngine.surface "pane"). */
  pane?: true;
  /** browserEngine.cloudDisplay is on and this server can run it: the panel shows the browser's window as a remote
   * desktop (GET /api/bots/:id/browser/desktop), and falls back to the picture view when that closes with 4415. */
  desktopView?: true;
  /** The person can import a site's sign-in from their own browsers into a bot's (the desktop app, Chrome engine). */
  cookieImport?: true;
  /** Self-hosted servers only: whether bots' browsers may open this server's own sites and its local network
   * (browserEngine.egress.localNetwork, off by default). Absent on the desktop and on MausBot Cloud. */
  serverSites?: boolean;
  /** Whether an owner-configured SOCKS5 upstream is active; the endpoint is never exposed in config status. */
  proxyConfigured?: boolean;
  /** Whether an owner-configured SOCKS5 upstream is saved, even if the current browser engine cannot use it. */
  proxySaved?: boolean;
  /** Team Cloud only: whether this caller may change the shared SOCKS5 upstream. */
  proxyEditable?: boolean;
  /** Idle close timeout in minutes (0 keeps browsers open; unset means 10 min on desktop or 3 min on Cloud). */
  idleTimeoutMinutes?: number;
}

export interface BrowserProfile {
  id: string;
  name: string;
  /** "chrome": the profile's bots use the person's own Chrome (My Chrome).
   * Absent is the built-in browser. */
  browser?: "chrome";
  /** The server config supplies a CDP address for this profile. */
  attachedChrome?: true;
  /** Read-only durable Electron routing inherited from legacy profiles.
   * Config PATCH payloads must omit it. */
  partitionId?: string;
}