utils/env/env_manager library

Classes

EnvInfo
Immutable snapshot of the environment at startup.
EnvVarValidationResult
Result of validating a bounded integer env var.

Enums

EnvVarValidationStatus
Validation status for a bounded integer env var.
NeomagePlatform
Supported platform identifiers.

Constants

dangerousShellSettings → const List<String>
Dangerous shell settings that can execute arbitrary shell code.
jetbrainsIdes → const List<String>
Well-known JetBrains IDE identifiers.
safeEnvVars → const Set<String>
Safe environment variables that can be applied before the trust dialog.

Functions

applyConfigEnvironmentVariables({required Map<String, String>? getGlobalConfigEnv(), required Map<String, String>? getAllSettingsEnv(), void clearCACertsCache()?, void clearMTLSCache()?, void clearProxyCache()?, void configureGlobalAgents()?}) → void
Apply ALL environment variables after trust is established.
applySafeConfigEnvironmentVariables({required Map<String, String>? getGlobalConfigEnv(), required Map<String, String>? getSettingsForSourceEnv(String source), required Map<String, String>? getAllSettingsEnv(), required bool isSettingSourceEnabled(String source)}) → void
Apply environment variables from trusted sources.
detectDeploymentEnvironment() → String
detectJetBrainsIDEFromParentProcessAsync() → Future<String?>
detectPackageManagers() → Future<List<String>>
Detect available package managers.
detectRuntimes() → Future<List<String>>
Detect available runtimes.
detectTerminal() → String?
Detect the terminal / editor hosting the CLI.
filterSettingsEnv(Map<String, String>? env) → Map<String, String>
Compose the strip filters applied to every settings-sourced env object.
getAWSRegion() → String
Get the AWS region with fallback to default.
getDefaultVertexRegion() → String
Get the default Vertex AI region.
getGlobalNeomageFile({String fileSuffix = ''}) → String
Returns the path to the global neomage config JSON file.
getHostPlatformForAnalytics() → NeomagePlatform
Returns the host platform for analytics reporting.
getIsBubblewrapSandbox() → bool
Check if running inside a Bubblewrap sandbox.
getIsDocker() → Future<bool>
Check if running inside a Docker container (Linux only).
getNeomageConfigHomeDir() → String
getTeamsDir() → String
Returns the teams directory under the config home.
getTerminalWithJetBrainsDetection() → String?
Synchronous version using cache or falling back to detectTerminal().
getTerminalWithJetBrainsDetectionAsync() → Future<String?>
Async terminal detection with JetBrains awareness.
getVertexRegionForModel(String? model) → String?
Get the Vertex AI region for a specific model. Different models may be available in different regions.
hasInternetAccess() → Future<bool>
Check internet access (best-effort, 1 s timeout).
hasNodeOption(String flag) → bool
Check if NODE_OPTIONS contains a specific flag. Splits on whitespace and checks for exact match.
initJetBrainsDetection() → Future<void>
Initialise JetBrains IDE detection early.
isBareMode() → bool
--bare / MAGE_SIMPLE: skip hooks, LSP, plugin sync, skill walk, attribution, background prefetches, and ALL keychain/credential reads.
isConductor() → bool
Checks if we're running via Conductor.
isEnvDefinedFalsy(dynamic envVar) → bool
Check if an environment variable is explicitly set to a falsy value. Accepts '0', 'false', 'no', 'off' (case-insensitive).
isEnvTruthy(dynamic envVar) → bool
Check if an environment-variable-like value is truthy. Accepts '1', 'true', 'yes', 'on' (case-insensitive).
isInProtectedNamespace() → bool
Conservative check for whether Neomage is running inside a protected (privileged or ASL3+) COO namespace or cluster.
isMuslEnvironment() → bool
Checks whether the system uses musl libc instead of glibc.
isNpmFromWindowsPath() → bool
Checks if the npm executable is from the Windows filesystem in WSL.
isProviderManagedEnvVar(String key) → bool
Check if a key is a provider-managed env var.
isRunningOnHomespace() → bool
Check if running on Homespace (ant-internal cloud environment).
isWslEnvironment() → bool
parseEnvVars(List<String>? rawEnvArgs) → Map<String, String>
Parse an array of KEY=VALUE strings into a map.
shouldMaintainProjectWorkingDir() → bool
Check if bash commands should maintain project working directory.
validateBoundedIntEnvVar({required String name, required String? value, required int defaultValue, required int upperLimit}) → EnvVarValidationResult
Validate and clamp an integer env var within 1 .. upperLimit. Returns the default when the value is absent or non-positive.