enact-config
Unified configuration management for Enact with secure storage and cloud sync.
Features
- Environment Variables: Read secrets from
ENACT_*environment variables (great for.envfiles in development) - OS Keychain: Secure storage for secrets (API keys, tokens, credentials) with fallback support
- Encrypted File Storage: AES-256-GCM encrypted storage for settings
- Cloud Sync: Automatic configuration synchronization (respects air-gapped mode)
- Multi-platform: Works on macOS, Linux, and Windows
Usage
use ;
let config_path = default_config_path?;
let manager = new.await?;
// Load configuration
let config = manager.load.await?;
// Set a secret (stored in keychain)
manager.set_secret.await?;
// Save configuration
manager.save.await?;
Configuration Structure
Configuration is split into:
- Secrets: Stored in OS keychain (API keys, tokens, credentials) or environment variables
- Settings: Stored in encrypted file (feature flags, timeouts, preferences, storage backends, tool engines)
Environment Variable Support
The configuration manager automatically checks all global environment variables starting with ENACT_* before falling back to the OS keychain. This includes:
- System-wide environment variables
- User-level environment variables
- Shell session variables
- Variables from
.envfiles (if loaded viadotenvyor similar)
No .env file is required - any ENACT_* environment variable set in your environment will be automatically detected and used.
Key to Environment Variable Mapping
Keys are converted to environment variable names by:
- Converting to uppercase
- Replacing dots with underscores
- Prefixing with
ENACT_
Examples
| Key | Environment Variable |
|---|---|
providers.azure.apiKey |
ENACT_PROVIDERS_AZURE_APIKEY |
providers.anthropic.apiKey |
ENACT_PROVIDERS_ANTHROPIC_APIKEY |
providers.openai.apiKey |
ENACT_PROVIDERS_OPENAI_APIKEY |
Setting Environment Variables
You can set ENACT_* environment variables in any of these ways:
1. System-wide or user-level (persistent):
# In ~/.bashrc, ~/.zshrc, or system-wide config
2. Current shell session:
3. Using .env files (optional, for convenience):
Create a .env file in your project root:
ENACT_PROVIDERS_AZURE_APIKEY=your-azure-api-key
ENACT_PROVIDERS_ANTHROPIC_APIKEY=your-anthropic-api-key
ENACT_PROVIDERS_OPENAI_APIKEY=your-openai-api-key
Then load it in your application (optional - only needed if using .env files):
// Example with dotenvy (add to your Cargo.toml if needed)
dotenv.ok;
4. Programmatically:
set_var;
The ConfigManager automatically checks all of these sources - no additional configuration needed. Environment variables work out of the box without any .env file loader.
Air-Gapped Mode
When runtime.mode === "airgapped":
- Cloud sync is disabled
- Network access is blocked
- Only local features are available