UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 5.01 kB
import{o as normalizeLowercaseStringOrEmpty}from"./string-coerce-CpTFcSwY.mjs"; //!src/daemon/constants.ts const GATEWAY_LAUNCH_AGENT_LABEL=`ai.openclaw.gateway`;const GATEWAY_SYSTEMD_SERVICE_NAME=`openclaw-gateway`;const GATEWAY_WINDOWS_TASK_NAME=`OpenClaw Gateway`;const GATEWAY_SERVICE_MARKER=`openclaw`;const GATEWAY_SERVICE_KIND=`gateway`;const GATEWAY_SERVICE_RUNTIME_PID_ENV=`OPENCLAW_GATEWAY_SERVICE_PID`;const GATEWAY_SERVICE_SELECTOR_ENV_KEYS=[`OPENCLAW_STATE_DIR`,`OPENCLAW_CONFIG_PATH`,`OPENCLAW_PROFILE`,`OPENCLAW_GATEWAY_PORT`,`OPENCLAW_LAUNCHD_LABEL`,`OPENCLAW_SYSTEMD_UNIT`,`OPENCLAW_WINDOWS_TASK_NAME`];function isGatewayServiceEnv(e){if(e.OPENCLAW_SERVICE_MARKER?.trim()!==`openclaw`)return false;const t=e.OPENCLAW_SERVICE_KIND?.trim();return!t||t===`gateway`}const NODE_LAUNCH_AGENT_LABEL=`ai.openclaw.node`;const NODE_SYSTEMD_SERVICE_NAME=`openclaw-node`;const NODE_WINDOWS_TASK_NAME=`OpenClaw Node`;const NODE_SERVICE_MARKER=`openclaw`;const NODE_SERVICE_KIND=`node`;const NODE_WINDOWS_TASK_SCRIPT_NAME=`node.cmd`;const LEGACY_GATEWAY_SYSTEMD_SERVICE_NAMES=[`clawdbot-gateway`];function normalizeGatewayProfile(e){const t=e?.trim();return t&&normalizeLowercaseStringOrEmpty(t)!=="default"?t:null}function resolveGatewayProfileSuffix(e){const t=normalizeGatewayProfile(e);return t?`-${t}`:``}function resolveGatewayLaunchAgentLabel(e){const t=normalizeGatewayProfile(e);return t?`ai.openclaw.${t}`:GATEWAY_LAUNCH_AGENT_LABEL}function resolveGatewaySystemdServiceName(e){return`${GATEWAY_SYSTEMD_SERVICE_NAME}${resolveGatewayProfileSuffix(e)}`}function resolveGatewaySystemdServiceNameCandidates(e){const t=resolveGatewaySystemdServiceName(e);const n=resolveGatewayProfileSuffix(e);if(!n)return[t,`openclaw`];const r=`openclaw${n}`;return r===NODE_SYSTEMD_SERVICE_NAME||r===GATEWAY_SYSTEMD_SERVICE_NAME||r.startsWith(`${GATEWAY_SYSTEMD_SERVICE_NAME}-`)?[t]:[t,r]}function resolveGatewayWindowsTaskName(e){const t=normalizeGatewayProfile(e);return t?`${GATEWAY_WINDOWS_TASK_NAME} (${t})`:GATEWAY_WINDOWS_TASK_NAME}function normalizeWindowsTaskIdentity(e){return e.replace(/^\\+/,``).toLowerCase()}function resolveGatewayNativeServiceIdentityConflict(e,t=process.platform){const n=normalizeGatewayProfile(e.OPENCLAW_PROFILE);if(!n)return null;if(t===`darwin`){const t=`OPENCLAW_LAUNCHD_LABEL`;const r=e[t]?.trim();const i=resolveGatewayLaunchAgentLabel(n);return r&&r!==i?{envKey:t,expected:i}:null}if(t===`linux`){const t=`OPENCLAW_SYSTEMD_UNIT`;const r=e[t]?.trim();const i=r?.endsWith(`.service`)?r:r&&`${r}.service`;const a=`${resolveGatewaySystemdServiceName(n)}.service`;return i&&i!==a?{envKey:t,expected:a}:null}if(t===`win32`){const t=`OPENCLAW_WINDOWS_TASK_NAME`;const r=e[t]?.trim();const i=resolveGatewayWindowsTaskName(n);return r&&normalizeWindowsTaskIdentity(r)!==normalizeWindowsTaskIdentity(i)?{envKey:t,expected:i}:null}return null}function formatGatewayServiceDescription(e){const t=normalizeGatewayProfile(e);return t?`OpenClaw Gateway (profile: ${t})`:`OpenClaw Gateway`}function resolveGatewayServiceDescription(e){return e.description??formatGatewayServiceDescription(e.env.OPENCLAW_PROFILE)}function resolveNodeLaunchAgentLabel(e){const t=normalizeGatewayProfile(e);return t?`${NODE_LAUNCH_AGENT_LABEL}.${t}`:NODE_LAUNCH_AGENT_LABEL}function isNodeLaunchAgentLabel(e){return e===NODE_LAUNCH_AGENT_LABEL||e.startsWith(`${NODE_LAUNCH_AGENT_LABEL}.`)}const DURABLE_PROCESS_LAUNCHD_LABEL_PREFIX=`ai.openclaw.durable-proc.`;function resolveNodeSystemdServiceName(e){return`${NODE_SYSTEMD_SERVICE_NAME}${resolveGatewayProfileSuffix(e)}`}function resolveNodeWindowsTaskName(e){const t=normalizeGatewayProfile(e);return t?`${NODE_WINDOWS_TASK_NAME} (${t})`:NODE_WINDOWS_TASK_NAME}function resolveNodeServiceIdentityEnvironment(e={}){const t=e.OPENCLAW_PROFILE;return{OPENCLAW_PROFILE:t,OPENCLAW_LAUNCHD_LABEL:resolveNodeLaunchAgentLabel(t),OPENCLAW_SYSTEMD_UNIT:resolveNodeSystemdServiceName(t),OPENCLAW_WINDOWS_TASK_NAME:resolveNodeWindowsTaskName(t),OPENCLAW_WINDOWS_TASK_HIDDEN_LAUNCHER:`1`,OPENCLAW_TASK_SCRIPT_NAME:NODE_WINDOWS_TASK_SCRIPT_NAME,OPENCLAW_LOG_PREFIX:`node${resolveGatewayProfileSuffix(t)}`,OPENCLAW_SERVICE_MARKER:NODE_SERVICE_MARKER,OPENCLAW_SERVICE_KIND:NODE_SERVICE_KIND}}export{resolveNodeWindowsTaskName as S,resolveGatewaySystemdServiceNameCandidates as _,GATEWAY_SERVICE_RUNTIME_PID_ENV as a,resolveNodeServiceIdentityEnvironment as b,NODE_SERVICE_KIND as c,normalizeWindowsTaskIdentity as d,resolveGatewayLaunchAgentLabel as f,resolveGatewaySystemdServiceName as g,resolveGatewayServiceDescription as h,GATEWAY_SERVICE_MARKER as i,isGatewayServiceEnv as l,resolveGatewayProfileSuffix as m,GATEWAY_LAUNCH_AGENT_LABEL as n,GATEWAY_SERVICE_SELECTOR_ENV_KEYS as o,resolveGatewayNativeServiceIdentityConflict as p,GATEWAY_SERVICE_KIND as r,LEGACY_GATEWAY_SYSTEMD_SERVICE_NAMES as s,DURABLE_PROCESS_LAUNCHD_LABEL_PREFIX as t,isNodeLaunchAgentLabel as u,resolveGatewayWindowsTaskName as v,resolveNodeSystemdServiceName as x,resolveNodeLaunchAgentLabel as y};