/** * Mode detection utilities for hosted/local deployment * * Local mode: Full ingestion capabilities, no auth required, SQLite * Hosted mode: View-only hub, auth required, aggregates data from devices */ export type ScribeMode = "local" | "hosted"; /** * Get the current deployment mode from environment * Defaults to 'local' if not specified */ export function getMode(): ScribeMode { const mode = process.env.SCRIBE_MODE?.trim(); if (mode === "hosted") return "hosted"; return "local"; } /** * Check if running in hosted mode (view-only hub) */ export function isHosted(): boolean { return getMode() === "hosted"; } /** * Check if running in local mode (full ingestion) */ export function isLocal(): boolean { return getMode() === "local"; } /** * Get mode-specific configuration */ export function getModeConfig() { const mode = getMode(); return { mode, // Local mode can ingest data canIngest: mode === "local", // Local mode can manage scan roots canManageScanRoots: mode === "local", // Hosted mode requires authentication requiresAuth: mode === "hosted", // Hosted mode can receive uploads from devices canReceiveUploads: mode === "hosted", // Local mode can export/upload to hosted hub canUploadToHub: mode === "local", }; }