@@ -76,6 +76,7 @@ public static class Fields
7676 public const string AgentRootDir = "root_dir" ;
7777 public const string AgentRunCommand = "run_command" ;
7878 public const string AgentRunCommandLinux = "run_command_linux" ;
79+ public const string AgentEnvironment = "environment" ;
7980 public const string AgentHivemind = "hivemind" ;
8081
8182 public const string LoadoutBlueTable = "blue_loadout" ;
@@ -260,6 +261,33 @@ private string GetRunCommand(TomlTable runnableSettings)
260261#endif
261262 }
262263
264+ private List < EnvironmentVariableT > GetEnvironment ( TomlTable runnableSettings )
265+ {
266+ TomlTable environment = GetValue < TomlTable > (
267+ runnableSettings ,
268+ Fields . AgentEnvironment ,
269+ [ ]
270+ ) ;
271+
272+ List < EnvironmentVariableT > variables = [ ] ;
273+ using ( _context . Begin ( Fields . AgentEnvironment ) )
274+ {
275+ foreach ( var ( key , rawValue ) in environment )
276+ {
277+ if ( rawValue is not string value )
278+ {
279+ throw new InvalidCastException (
280+ $ "{ _context . ToStringWithEnd ( key ) } has value { rawValue } , but a value of type String was expected."
281+ ) ;
282+ }
283+
284+ variables . Add ( new ( ) { Name = key , Value = value } ) ;
285+ }
286+ }
287+
288+ return variables ;
289+ }
290+
263291 private ScriptConfigurationT LoadScriptConfig ( string scriptConfigPath )
264292 {
265293 TomlTable scriptToml = LoadTomlFile ( scriptConfigPath ) ;
@@ -276,6 +304,7 @@ private ScriptConfigurationT LoadScriptConfig(string scriptConfigPath)
276304 GetValue ( settings , Fields . AgentRootDir , "" )
277305 ) ,
278306 RunCommand = GetRunCommand ( settings ) ,
307+ Environment = GetEnvironment ( settings ) ,
279308 AgentId = GetValue ( settings , Fields . AgentAgentId , "" ) ,
280309 } ;
281310 }
@@ -511,6 +540,7 @@ bool autoStart
511540 Name = nameOverride ?? GetValue < string > ( settings , Fields . AgentName , "" ) ,
512541 Loadout = loadout ,
513542 RunCommand = autoStart ? GetRunCommand ( settings ) : "" ,
543+ Environment = GetEnvironment ( settings ) ,
514544 Hivemind = GetValue ( settings , Fields . AgentHivemind , false ) ,
515545 RootDir = rootDir ,
516546 } ;
0 commit comments