UNPKG

@openguardrails/moltguard

Version:

AI agent security plugin for OpenClaw: prompt injection detection, PII sanitization, and monitoring dashboard

43 lines 2.16 kB
/** * Centralized environment variable access for MoltGuard. * * This module is the ONLY place that reads `process.env` so that * modules performing network calls never contain env access in the * same source unit. This avoids false-positive "credential * harvesting" alerts from OpenClaw's skill scanner. */ import os from "node:os"; import path from "node:path"; // --------------------------------------------------------------------------- // OpenClaw home directory // --------------------------------------------------------------------------- export const openclawHome = process.env.OPENCLAW_HOME || path.join(os.homedir(), ".openclaw"); // --------------------------------------------------------------------------- // Development mode // --------------------------------------------------------------------------- export const isDev = process.env.NODE_ENV === "development" || process.env.OG_DEV === "1" || process.env.OG_DEV === "true" || (process.env.OG_CORE_URL?.includes("localhost") ?? false); // --------------------------------------------------------------------------- // Core URL // --------------------------------------------------------------------------- const DEV_CORE_URL = "http://localhost:53666"; const PROD_CORE_URL = "https://www.openguardrails.com/core"; export const envCoreUrl = process.env.OG_CORE_URL; export const defaultCoreUrl = envCoreUrl ?? (isDev ? DEV_CORE_URL : PROD_CORE_URL); // --------------------------------------------------------------------------- // API key (optional env override) // --------------------------------------------------------------------------- export const envApiKey = process.env.OG_API_KEY ?? ""; // --------------------------------------------------------------------------- // Environment variable setter (for dashboard-launcher runtime config) // --------------------------------------------------------------------------- /** * Sets environment variables at runtime. Centralised here so that files * making network calls never contain env access directly. */ export function setEnv(key, value) { process.env[key] = value; } //# sourceMappingURL=env.js.map