enact-config 0.0.1

Unified configuration management for Enact - secure storage with keychain and encrypted files
Documentation

enact-config

Unified configuration management for Enact with secure storage and cloud sync.

Features

  • Environment Variables: Read secrets from ENACT_* environment variables (great for .env files 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 enact_config::{ConfigManager, default_config_path};

let config_path = default_config_path()?;
let manager = ConfigManager::new(config_path).await?;

// Load configuration
let config = manager.load().await?;

// Set a secret (stored in keychain)
manager.set_secret("providers.azure.apiKey", "your-api-key").await?;

// Save configuration
manager.save(&config).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 .env files (if loaded via dotenvy or 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
export ENACT_PROVIDERS_AZURE_APIKEY=your-azure-api-key
export ENACT_PROVIDERS_ANTHROPIC_APIKEY=your-anthropic-api-key

2. Current shell session:

export ENACT_PROVIDERS_AZURE_APIKEY=your-azure-api-key

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)
dotenvy::dotenv().ok();

4. Programmatically:

std::env::set_var("ENACT_PROVIDERS_AZURE_APIKEY", "your-azure-api-key");

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