feat: add enum support to environment parser #796
                
     Draft
            
            
          
      
        
          +358
        
        
          −1
        
        
          
        
      
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Summary
This PR adds comprehensive enum support to the environment parser, enabling it to handle both
enum.Enumsubclasses andLiteraltypes with case-insensitive matching.Changes Made
Core Implementation
EnumEnvParserclass: A new parser specifically designed to handle enum typesenum.Enumsubclasses with both string and integer valuesLiteraltypes from thetypingmoduleParser Integration
get_env_parserfunction: Now detects enum types and returns appropriateEnumEnvParserinstancesStrEnvParser, now usesEnumEnvParserfor better validation and case-insensitive matchingKey Features
"debug"matchesLogLevel.DEBUG,"high"matchesPriority.HIGHTesting
Added comprehensive test coverage including:
from_envfunctionAll existing tests continue to pass, ensuring no regressions.
Example Usage
Backward Compatibility
✅ All existing functionality is preserved
✅ No breaking changes to the API
✅ Existing tests continue to pass
✅ Discriminated union parsing works correctly
Code Quality
@tofarr can click here to continue refining the PR
Agent Server images for this PR
• GHCR package: https://github.com/All-Hands-AI/agent-sdk/pkgs/container/agent-server
Variants & Base Images
golang:1.21-bookwormeclipse-temurin:17-jdknikolaik/python-nodejs:python3.12-nodejs22Pull (multi-arch manifest)
Run
All tags pushed for this build
The
e4da687tag is a multi-arch manifest (amd64/arm64); your client pulls the right arch automatically.