openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
32 lines (31 loc) • 1.64 kB
JavaScript
import { r as isGatewayRunInvocationArgv } from "./gateway-run-argv-CMDDyZ3j.mjs";
import { t as resolveCliArgvInvocation } from "./argv-invocation-C9SmXUsh.mjs";
import { n as tryProcessCwd } from "./safe-cwd-CZqaxroH.mjs";
import { r as resolveCliContainerTarget } from "./container-target-Gm4i9O54.mjs";
import { r as resolveStateDir } from "./state-dir-DiG0gXzD.mjs";
import "./paths-DAcAg5aV.mjs";
import { t as loadGlobalRuntimeDotEnvFiles } from "./dotenv-global-BwvKQuHq.mjs";
import { r as loadWorkspaceDotEnvFile } from "./dotenv-qUrr6GRR.mjs";
import path from "node:path";
//#region src/cli/dotenv.ts
/** Load `.env` files for normal CLI commands without overriding existing process env. */
function loadCliDotEnv(e) {
const t = tryProcessCwd();
if (t) loadWorkspaceDotEnvFile(path.join(t, ".env"));
if (e?.loadGlobalEnv === false) return;
loadGlobalRuntimeDotEnvFiles({ stateEnvPath: path.join(resolveStateDir(process.env), ".env") });
}
/** Load only the dotenv scope an early CLI failure may consult for diagnostic formatting. */
async function loadCliDotEnvForEarlyDiagnostic(e, t = process.env) {
if (resolveCliContainerTarget(e, t)) return;
const n = resolveCliArgvInvocation(e);
if (n.commandPath[0] === "agent" && n.commandPath[1] === "exec") return;
if (n.primary === "agent" && !e.includes("--local")) {
const { loadGatewayDispatchCliDotEnv: e } = await import("./gateway-dispatch-dotenv-B1rNiKgh.mjs");
await e();
return;
}
loadCliDotEnv({ loadGlobalEnv: n.hasHelpOrVersion || !isGatewayRunInvocationArgv(e) });
}
//#endregion
export { loadCliDotEnvForEarlyDiagnostic as n, loadCliDotEnv as t };