waveterm/frontend/util/getenv.ts
Mike Sawka d272a4ec03
New AIPanel (#2370)
Massive PR, over 13k LOC updated, 128 commits to implement the first pass at the new Wave AI panel.  Two backend adapters (OpenAI and Anthropic), layout changes to support the panel, keyboard shortcuts, and a huge focus/layout change to integrate the panel seamlessly into the UI.

Also fixes some small issues found during the Wave AI journey (zoom fixes, documentation, more scss removal, circular dependency issues, settings, etc)
2025-10-07 13:32:10 -07:00

31 lines
825 B
TypeScript

// Copyright 2025, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0
function getWindow(): Window {
return globalThis.window;
}
function getProcess(): NodeJS.Process {
return globalThis.process;
}
function getApi(): ElectronApi {
return (window as any).api;
}
/**
* Gets an environment variable from the host process, either directly or via IPC if called from the browser.
* @param paramName The name of the environment variable to attempt to retrieve.
* @returns The value of the environment variable or null if not present.
*/
export function getEnv(paramName: string): string {
const win = getWindow();
if (win != null) {
return getApi().getEnv(paramName);
}
const proc = getProcess();
if (proc != null) {
return proc.env[paramName];
}
return null;
}