openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 960 B
JavaScript
import{D as parseStrictPositiveInteger}from"./number-coercion-B3CfI447.mjs";import{n as throwExpectedCliError}from"./expected-cli-error-oDVmXYil.mjs";
//!src/cli/gateway-port-option.ts
const MAX_TCP_PORT=65535;function parsePort(e,t,n){if(e===void 0||e===null)return;const r=parseStrictPositiveInteger(typeof e===`bigint`?String(e):e);if(r===void 0||r>MAX_TCP_PORT)n(`${t} must be an integer between 1 and ${MAX_TCP_PORT}.`);return r}function parseGatewayPortOption(e,t=`--port`){return parsePort(e,t,e=>{throw new Error(e)})}function parseGatewayClientPortOption(e){return parsePort(e,`--port`,throwExpectedCliError)}function resolveGatewayLocalPortOverride(e){const t=e.localPortOverride??parseGatewayClientPortOption(e.port);if(t!==void 0&&typeof e.url===`string`&&e.url.trim())throwExpectedCliError(`Use either --url or --port, not both.`);return t}export{parseGatewayPortOption as n,resolveGatewayLocalPortOverride as r,parseGatewayClientPortOption as t};