eliza
eliza copied to clipboard
fix: .env Namespaced Character Secrets
Relates to:
N/A
Risks
Medium - This PR adds a new feature for character-specific environment variable namespacing.
Risks include:
- Changes to environment variable handling
- Changes to character settings loading
- Potential impact on existing character configurations
Background
I wanted to be able to check in character files without having to sanitize them first
What does this PR do?
Feature Implementation
Adds support for character-specific namespaced environment variables:
- New environment variable pattern:
CHARACTER.YOUR_CHARACTER_NAME.SETTING_NAME
- Automatic handling of spaces in character names (converted to underscores)
- Enhanced settings hierarchy:
- Character-specific namespaced env variables (highest priority)
- Character settings from JSON
- Global environment variables
- Default values
- Maintains backward compatibility with existing settings system
Key changes:
- Modified settings loader in
packages/core/src/settings.ts
- Updated character loading in
packages/agent/src/index.ts
- Added automatic conversion of character name spaces to underscores
Documentation Updates
Updated documentation to reflect the new feature:
- Added namespaced settings pattern to secrets management guide
- Updated configuration guide with new examples
- Updated agent package documentation with hierarchy explanation
- Added clear examples for both .env and character.json methods
What kind of change is this?
Features (non-breaking change which adds functionality)
Documentation changes needed?
Yes - Documentation has been updated to reflect the new feature:
- Added namespaced settings pattern
- Updated configuration examples
- Updated settings hierarchy explanation
- Added character name handling instructions
Testing
Where should a reviewer start?
Feature Testing
-
Review code changes:
-
packages/core/src/settings.ts
-
packages/agent/src/index.ts
-
-
Test functionality:
# Test with simple name CHARACTER.TESTBOT.OPENAI_API_KEY=sk-test # Test with spaces in name CHARACTER.MY_TEST_BOT.ANTHROPIC_API_KEY=sk-other
Documentation Testing
Review updated docs:
- docs/docs/guides/secrets-management.md
- docs/docs/guides/configuration.md
- docs/docs/packages/agent.md
Detailed testing steps
-
Feature Testing:
- Create character with spaces in name
- Add namespaced variables to .env
- Verify correct loading into character settings
- Test precedence over character.json settings
- Verify backward compatibility
- Test global fallback behavior
-
Documentation Verification:
- Verify pattern examples are correct
- Verify hierarchy explanation is clear
- Verify character name handling is explained
- Test example configurations
Screenshots
N/A - Feature implementation and documentation changes