@@ -182,21 +182,8 @@ export function resolveConfigPath(
182182 return path . join ( stateDir , CONFIG_FILENAME ) ;
183183}
184184
185- /**
186- * @deprecated Use resolveConfigPathCandidate() instead. This constant is evaluated
187- * at module load time and does not respect OPENCLAW_HOME set after import.
188- * Kept for backwards compatibility but should be avoided in new code.
189- */
190185export const CONFIG_PATH = resolveConfigPathCandidate ( ) ;
191186
192- /**
193- * Runtime-evaluated config path that respects OPENCLAW_HOME.
194- * Use this instead of CONFIG_PATH when OPENCLAW_HOME may be set dynamically.
195- */
196- export function getConfigPath ( env : NodeJS . ProcessEnv = process . env ) : string {
197- return resolveConfigPathCandidate ( env , envHomedir ( env ) ) ;
198- }
199-
200187/**
201188 * Resolve default config path candidates across default locations.
202189 * Order: explicit config path → state-dir-derived paths → new default.
@@ -271,34 +258,18 @@ export function resolveGatewayPort(
271258 cfg ?: OpenClawConfig ,
272259 env : NodeJS . ProcessEnv = process . env ,
273260) : number {
274- // When OPENCLAW_HOME is set (isolated instance), prefer config over inherited env vars.
275- // This prevents a parent gateway's OPENCLAW_GATEWAY_PORT from bleeding through.
276- const isIsolatedInstance = Boolean ( env . OPENCLAW_HOME ?. trim ( ) ) ;
277-
278- // Config port takes precedence for isolated instances
279- const configPort = cfg ?. gateway ?. port ;
280- if (
281- isIsolatedInstance &&
282- typeof configPort === "number" &&
283- Number . isFinite ( configPort ) &&
284- configPort > 0
285- ) {
286- return configPort ;
287- }
288-
289- // Check env vars (for non-isolated or when config doesn't specify port)
290261 const envRaw = env . OPENCLAW_GATEWAY_PORT ?. trim ( ) || env . CLAWDBOT_GATEWAY_PORT ?. trim ( ) ;
291262 if ( envRaw ) {
292263 const parsed = Number . parseInt ( envRaw , 10 ) ;
293264 if ( Number . isFinite ( parsed ) && parsed > 0 ) {
294265 return parsed ;
295266 }
296267 }
297-
298- // Fall back to config for non-isolated instances
299- if ( typeof configPort === "number" && Number . isFinite ( configPort ) && configPort > 0 ) {
300- return configPort ;
268+ const configPort = cfg ?. gateway ?. port ;
269+ if ( typeof configPort === "number" && Number . isFinite ( configPort ) ) {
270+ if ( configPort > 0 ) {
271+ return configPort ;
272+ }
301273 }
302-
303274 return DEFAULT_GATEWAY_PORT ;
304275}
0 commit comments