@@ -52,18 +52,6 @@ export function getHealthProbeUrl(agent: AgentDefinition | null): string {
5252 return agent . healthProbe ?. url || `http://127.0.0.1:${ DASHBOARD_PORT } /health` ;
5353}
5454
55- export function getHealthProbeUrlForPort ( agent : AgentDefinition | null , port : number ) : string {
56- const probeUrl = getHealthProbeUrl ( agent ) ;
57- if ( ! Number . isInteger ( port ) || port < 1 || port > 65535 ) return probeUrl ;
58- try {
59- const parsed = new URL ( probeUrl ) ;
60- parsed . port = String ( port ) ;
61- return parsed . toString ( ) ;
62- } catch {
63- return probeUrl . replace ( / : ( \d + ) (? = \/ | $ ) / , `:${ String ( port ) } ` ) ;
64- }
65- }
66-
6755function escapeEre ( value : string ) : string {
6856 return value . replace ( / [ \\ ^ $ . * + ? ( ) [ \] { } | ] / g, "\\$&" ) ;
6957}
@@ -154,20 +142,15 @@ function gatewayLaunchCommand(command: string, runAsUser?: string): string {
154142 return `${ logSelection } if [ "$(id -u)" = "0" ] && command -v gosu >/dev/null 2>&1 && id ${ shellQuote ( runAsUser ) } >/dev/null 2>&1; then nohup gosu ${ shellQuote ( runAsUser ) } ${ command } >> "$_GATEWAY_LOG" 2>&1 & else ${ userLaunch } fi;` ;
155143}
156144
157- function hermesGatewayEnvPrefix ( port ?: number ) : string {
145+ function hermesGatewayEnvPrefix ( ) : string {
158146 const decodeProxy = "http://127.0.0.1:3129" ;
159- const envVars = [
147+ return [
160148 "HERMES_HOME=/sandbox/.hermes" ,
161149 `HTTPS_PROXY=${ decodeProxy } ` ,
162150 `HTTP_PROXY=${ decodeProxy } ` ,
163151 `https_proxy=${ decodeProxy } ` ,
164152 `http_proxy=${ decodeProxy } ` ,
165- ] ;
166- if ( typeof port === "number" && Number . isInteger ( port ) && port >= 1 && port <= 65535 ) {
167- envVars . push ( `NEMOCLAW_DASHBOARD_PORT=${ String ( port ) } ` ) ;
168- envVars . push ( `CHAT_UI_URL=http://127.0.0.1:${ String ( port ) } ` ) ;
169- }
170- return envVars . join ( " " ) ;
153+ ] . join ( " " ) ;
171154}
172155
173156function hermesDecodeProxyRecoveryCommand ( ) : string {
@@ -207,7 +190,7 @@ export function buildOpenClawRecoveryScript(port: number): string {
207190export function buildRecoveryScript ( agent : AgentDefinition | null , port : number ) : string | null {
208191 if ( ! agent ) return null ;
209192
210- const probeUrl = getHealthProbeUrlForPort ( agent , port ) ;
193+ const probeUrl = getHealthProbeUrl ( agent ) ;
211194 const binaryPath = agent . binary_path || "/usr/local/bin/openclaw" ;
212195 const binaryName = binaryPath . split ( "/" ) . pop ( ) ?? "openclaw" ;
213196 const defaultGatewayCommand = `${ binaryName } gateway run` ;
@@ -231,7 +214,7 @@ export function buildRecoveryScript(agent: AgentDefinition | null, port: number)
231214 // that's about to crash on a missing guard. (#2478)
232215 const isHermes = agent . name === "hermes" ;
233216 const hermesHome = isHermes ? "export HERMES_HOME=/sandbox/.hermes; " : "" ;
234- const hermesLaunchEnv = isHermes ? `env ${ hermesGatewayEnvPrefix ( port ) } ` : "" ;
217+ const hermesLaunchEnv = isHermes ? `env ${ hermesGatewayEnvPrefix ( ) } ` : "" ;
235218 const launchCommand = usesValidatedBinary
236219 ? gatewayLaunchCommand ( `${ hermesLaunchEnv } "$AGENT_BIN" gateway run${ isHermes ? "" : ` --port ${ port } ` } ` )
237220 : gatewayLaunchCommand (
@@ -279,10 +262,6 @@ export function getGatewayCommand(agent: AgentDefinition | null): string {
279262 return agent ?. gateway_command || "openclaw gateway run" ;
280263}
281264
282- export function getAgentForwardPort ( agent : AgentDefinition | null ) : number {
283- return agent ?. forwardPort ?? DASHBOARD_PORT ;
284- }
285-
286265/**
287266 * Build a single copy-pasteable command for the user to run when automatic
288267 * gateway recovery fails. Unlike the raw gateway command, this keeps the
@@ -293,7 +272,7 @@ export function buildManualRecoveryCommand(agent: AgentDefinition | null, port:
293272 const defaultGatewayCommand = `${ shellQuote ( binaryPath ) } gateway run` ;
294273 const gatewayCmd = agent ?. gateway_command ?. trim ( ) || defaultGatewayCommand ;
295274 const isHermes = agent ?. name === "hermes" ;
296- const envPrefix = isHermes ? `${ hermesGatewayEnvPrefix ( port ) } ` : "" ;
275+ const envPrefix = isHermes ? `${ hermesGatewayEnvPrefix ( ) } ` : "" ;
297276 const portFlag = isHermes ? "" : ` --port ${ port } ` ;
298277 const decodeProxySetup = isHermes ? `${ hermesDecodeProxyRecoveryCommand ( ) } ` : "" ;
299278 return `${ buildGatewayLogSelection ( ) } ${ decodeProxySetup } ${ envPrefix } nohup ${ gatewayCmd } ${ portFlag } >> "$_GATEWAY_LOG" 2>&1 &` ;
0 commit comments