Skip to content

Commit e9d753a

Browse files
committed
fix(gateway-cli): add --port option to gateway health/probe and RPC commands
- gateway run accepts --port but gateway health and gateway probe did not, causing 'unknown option' errors when targeting non-default ports - Add --port option to gatewayCallOpts (both in call.ts and register.ts) - Construct ws://127.0.0.1:$PORT URL when --port is set without --url Fixes #79100
1 parent dbd5689 commit e9d753a

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎src/cli/gateway-cli/call.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { withProgress } from "../progress.js";
1212
export type GatewayRpcOpts = {
1313
config?: OpenClawConfig;
1414
url?: string;
15+
port?: string;
1516
token?: string;
1617
password?: string;
1718
timeout?: string;
@@ -24,6 +25,7 @@ const DEFAULT_GATEWAY_RPC_TIMEOUT_MS = 10_000;
2425
export const gatewayCallOpts = (cmd: Command) =>
2526
cmd
2627
.option("--url <url>", "Gateway WebSocket URL (defaults to gateway.remote.url when configured)")
28+
.option("--port <port>", "Gateway port (used when --url is not set)")
2729
.option("--token <token>", "Gateway token (if required)")
2830
.option("--password <password>", "Gateway password (password auth)")
2931
.option("--timeout <ms>", "Timeout in ms", "10000")
@@ -34,6 +36,9 @@ export const callGatewayCli = async (method: string, opts: GatewayRpcOpts, param
3436
const timeoutMs = parseTimeoutMsWithFallback(opts.timeout, DEFAULT_GATEWAY_RPC_TIMEOUT_MS, {
3537
invalidType: "error",
3638
});
39+
// FIX #79100: Allow --port as a shorthand for local gateway connections when
40+
// --url is not set. Construct a ws:// URL targeting the specified port.
41+
const url = opts.url ?? (opts.port ? `ws://127.0.0.1:${opts.port}` : undefined);
3742
return await withProgress(
3843
{
3944
label: `Gateway ${method}`,
@@ -43,7 +48,7 @@ export const callGatewayCli = async (method: string, opts: GatewayRpcOpts, param
4348
async () =>
4449
await callGateway({
4550
config: opts.config,
46-
url: opts.url,
51+
url,
4752
token: opts.token,
4853
password: opts.password,
4954
method,

‎src/cli/gateway-cli/register.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ function loadDaemonStatusGatherModule() {
9191
function gatewayCallOpts(cmd: Command): Command {
9292
return cmd
9393
.option("--url <url>", "Gateway WebSocket URL (defaults to gateway.remote.url when configured)")
94+
.option("--port <port>", "Gateway port (used when --url is not set)")
9495
.option("--token <token>", "Gateway token (if required)")
9596
.option("--password <password>", "Gateway password (password auth)")
9697
.option("--timeout <ms>", "Timeout in ms", "10000")

0 commit comments

Comments
 (0)