@@ -22,6 +22,10 @@ interface Settings {
22
22
[ key : string ] : string | undefined ;
23
23
}
24
24
25
+ interface NamespacedSettings {
26
+ [ namespace : string ] : Settings ;
27
+ }
28
+
25
29
let environmentSettings : Settings = { } ;
26
30
27
31
/**
@@ -91,6 +95,15 @@ export function loadEnvConfig(): Settings {
91
95
if ( ! result . error ) {
92
96
console . log ( `Loaded .env file from: ${ envPath } ` ) ;
93
97
}
98
+
99
+ // Parse namespaced settings
100
+ const namespacedSettings = parseNamespacedSettings ( process . env as Settings ) ;
101
+
102
+ // Attach to process.env for backward compatibility
103
+ Object . entries ( namespacedSettings ) . forEach ( ( [ namespace , settings ] ) => {
104
+ process . env [ `__namespaced_${ namespace } ` ] = JSON . stringify ( settings ) ;
105
+ } ) ;
106
+
94
107
return process . env as Settings ;
95
108
}
96
109
@@ -135,3 +148,21 @@ elizaLogger.info("Parsed settings:", {
135
148
} ) ;
136
149
137
150
export default settings ;
151
+
152
+ // Add this function to parse namespaced settings
153
+ function parseNamespacedSettings ( env : Settings ) : NamespacedSettings {
154
+ const namespaced : NamespacedSettings = { } ;
155
+
156
+ for ( const [ key , value ] of Object . entries ( env ) ) {
157
+ if ( ! value ) continue ;
158
+
159
+ const [ namespace , ...rest ] = key . split ( '.' ) ;
160
+ if ( ! namespace || rest . length === 0 ) continue ;
161
+
162
+ const settingKey = rest . join ( '.' ) ;
163
+ namespaced [ namespace ] = namespaced [ namespace ] || { } ;
164
+ namespaced [ namespace ] [ settingKey ] = value ;
165
+ }
166
+
167
+ return namespaced ;
168
+ }
0 commit comments