Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: allow passing secrets through environment #1454

Merged
merged 12 commits into from
Dec 26, 2024

Conversation

odilitime
Copy link
Collaborator

Resubmit #410

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:

  1. New environment variable pattern: CHARACTER.YOUR_CHARACTER_NAME.SETTING_NAME
  2. Automatic handling of spaces in character names (converted to underscores)
  3. Enhanced settings hierarchy:
    • Character-specific namespaced env variables (highest priority)
    • Character settings from JSON
    • Global environment variables
    • Default values
  4. 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:

  1. Added namespaced settings pattern to secrets management guide
  2. Updated configuration guide with new examples
  3. Updated agent package documentation with hierarchy explanation
  4. 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

  1. Review code changes:

    • packages/core/src/settings.ts
    • packages/agent/src/index.ts
  2. 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

  1. 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
  2. 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

@odilitime odilitime changed the title Attempt to fix conflicts in PR410 chore: Attempt to fix conflicts in PR410 Dec 26, 2024
@odilitime odilitime changed the title chore: Attempt to fix conflicts in PR410 feat: allow passing secrets through environment Dec 26, 2024
Copy link
Collaborator

@Freytes Freytes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good documentation, I would recommend a refactor for AWS

Copy link
Collaborator

@twilwa twilwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok at a glance

@odilitime odilitime merged commit 99f4eca into elizaOS:develop Dec 26, 2024
5 checks passed
1to3for5vi7ate9x pushed a commit to 1to3for5vi7ate9x/eliza that referenced this pull request Jan 26, 2025
feat: allow passing secrets through environment
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants