feat(config): add Env field to RuntimeConfig and AgentPresetInfo (#860)
Add support for agent presets to specify environment variables that
get exported when starting sessions. This enables agents to use
environment-based configuration.
Changes:
- Add Env field to RuntimeConfig struct in types.go
- Add Env field to AgentPresetInfo struct in agents.go
- Update RuntimeConfigFromPreset to copy Env from preset
- Update fillRuntimeDefaults to preserve Env field
- Merge agent Env vars in BuildStartupCommand functions
- Add comprehensive tests for Env preservation and copy semantics
This is a prerequisite for the OpenCode agent preset which uses
OPENCODE_PERMISSION='{"*":"allow"}' for auto-approve mode.
Co-authored-by: Avyukth <subhrajit.makur@hotmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -102,6 +102,21 @@ func TestRuntimeConfigFromPreset(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRuntimeConfigFromPresetReturnsNilEnvForPresetsWithoutEnv(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Built-in presets like Claude don't have Env set
|
||||
// This verifies nil Env handling in RuntimeConfigFromPreset
|
||||
rc := RuntimeConfigFromPreset(AgentClaude)
|
||||
if rc == nil {
|
||||
t.Fatal("RuntimeConfigFromPreset returned nil")
|
||||
}
|
||||
|
||||
// Claude preset doesn't have Env, so it should be nil
|
||||
if rc.Env != nil && len(rc.Env) > 0 {
|
||||
t.Errorf("Expected nil/empty Env for Claude preset, got %v", rc.Env)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsKnownPreset(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
|
||||
Reference in New Issue
Block a user