openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 3.34 kB
JavaScript
import{p as resolveGatewayNativeServiceIdentityConflict}from"./constants-tH5Q8GoI.mjs";import{o as isDefaultInstallIdentity,w as resolveNativeServiceProfileConflict}from"./paths-D_FOvGon.mjs";
//!src/infra/gateway-supervision.ts
const GATEWAY_SUPERVISOR_MODE_ENV=`OPENCLAW_SUPERVISOR_MODE`;const EXTERNAL_SUPERVISOR_UPDATE_REQUIRED_REASON=`external-supervisor-update-required`;const NON_DEFAULT_INSTALL_SERVICE_SKIP_REASON=`service management skipped: non-default state dir or config path`;function isGatewayExternallySupervised(e=process.env){return e[GATEWAY_SUPERVISOR_MODE_ENV]?.trim().toLowerCase()===`external`}function resolveGatewayPlatformSupervisor(e=process.env){if(isGatewayExternallySupervised(e))return`external`;return e.KUBERNETES_SERVICE_HOST?.trim()&&e.KUBERNETES_SERVICE_PORT?.trim()?`kubernetes`:void 0}function formatExternalSupervisorActionRequired(e){return[`OpenClaw gateway lifecycle is managed by an external supervisor (${GATEWAY_SUPERVISOR_MODE_ENV}=external).`,`Use that supervisor to ${e}.`].join(` `)}function formatExternalSupervisorUpdateRequired(){return[`OpenClaw self-update is disabled while gateway lifecycle is managed by an external supervisor (${GATEWAY_SUPERVISOR_MODE_ENV}=external).`,`Use the external supervisor's update workflow so it can stop the gateway, update and finalize the runtime, then restart it safely.`].join(` `)}function assertGatewayServiceMutationAllowed(e,t=process.env){if(isGatewayExternallySupervised(t))throw new Error(formatExternalSupervisorActionRequired(e));const n=resolveNativeServiceProfileConflict(t);if(n){if(n!==n.toLowerCase()){const t=process.platform===`win32`?`Windows`:`macOS`;throw new Error(`service management skipped: ${t} profile "${n}" is not lowercase-safe for case-insensitive state and native-service paths. Use a lowercase profile name to ${e}, or keep this profile runtime-only without a native service.`)}throw new Error(`service management skipped: macOS profile "${n}" conflicts with a reserved LaunchAgent identity. Choose a different profile name to ${e}.`)}const r=resolveGatewayNativeServiceIdentityConflict(t);if(r){const t=process.platform===`darwin`?`macOS`:process.platform===`win32`?`Windows`:`Linux`;throw new Error(`service management skipped: named profiles cannot override ${r.envKey} for ${t} service management. Unset ${r.envKey} so OpenClaw derives the native service identity from OPENCLAW_PROFILE to ${e}, or keep this profile runtime-only without a native service.`)}if(!isDefaultInstallIdentity(t))throw new Error(`${NON_DEFAULT_INSTALL_SERVICE_SKIP_REASON}. Rerun with HOME set to the OS account home, OPENCLAW_HOME either unset or pointing at that same home, and OPENCLAW_STATE_DIR and OPENCLAW_CONFIG_PATH either unset or pointing at the canonical paths for that account home and profile to ${e}.`)}function resolveGatewayServiceMutationError(e,t=process.env){try{assertGatewayServiceMutationAllowed(e,t);return null}catch(e){return e instanceof Error?e:new Error(String(e))}}export{formatExternalSupervisorUpdateRequired as a,resolveGatewayServiceMutationError as c,formatExternalSupervisorActionRequired as i,NON_DEFAULT_INSTALL_SERVICE_SKIP_REASON as n,isGatewayExternallySupervised as o,assertGatewayServiceMutationAllowed as r,resolveGatewayPlatformSupervisor as s,EXTERNAL_SUPERVISOR_UPDATE_REQUIRED_REASON as t};