openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 3.13 kB
JavaScript
import{n as isTruthyEnvValue}from"./env-fLMEolk5.mjs";import{r as resolveStateDir}from"./state-dir-BwIClCab.mjs";import{t as resolvePathViaExistingAncestorSync}from"./boundary-path-BeuXNL_4.mjs";import{m as resolveConfigPath}from"./paths-D_FOvGon.mjs";import{t as isContainerEnvironment}from"./container-environment-C0Hd9WfF.mjs";import{o as isGatewayExternallySupervised,s as resolveGatewayPlatformSupervisor}from"./gateway-supervision-TUZKxlq7.mjs";import{i as UPDATE_PARENT_ALLOWS_GATEWAY_ACTIVATION_ENV,r as UPDATE_IN_PROGRESS_ENV}from"./update-phase-CCaxuca0.mjs";
//!src/commands/doctor-service-repair-policy.ts
const GATEWAY_SERVICE_MANAGER_TIMEOUT_MS=5e3;const SERVICE_REPAIR_POLICY_ENV=`OPENCLAW_SERVICE_REPAIR_POLICY`;const EXTERNAL_SERVICE_REPAIR_NOTE=`Gateway service is managed externally; skipped service install/start repair. Start or repair the gateway through your supervisor.`;function assertDoctorServiceSelection(e,t){const selection=e=>{const t=resolveStateDir(e);return[t,resolveConfigPath(e,t)].map(e=>resolvePathViaExistingAncestorSync(e))};const n=selection(e);if(selection(t).some((e,t)=>e!==n[t]))throw new Error(`Doctor and the managed Gateway select different config or state directories. Run doctor with the Gateway's installation and profile; the service was left unchanged.`)}function resolveUpdateParentGatewayActivation(e){const t=e[UPDATE_PARENT_ALLOWS_GATEWAY_ACTIVATION_ENV];return t===void 0?void 0:isTruthyEnvValue(t)}async function shouldManageGatewayService(e=process.env){if(resolveGatewayPlatformSupervisor(e))return false;if(!isContainerEnvironment())return true;if(process.platform!==`linux`)return false;try{const{findInstalledSystemdGatewayScope:t}=await import(`./systemd-99DISckf.mjs`);if((await t(e))?.scope!==`user`)return false;const{resolveGatewayService:n}=await import(`./service-flxrucEo.mjs`);await n().isLoaded({env:e,timeoutMs:GATEWAY_SERVICE_MANAGER_TIMEOUT_MS});return true}catch{return false}}function resolveServiceRepairPolicy(e=process.env){if(e[`OPENCLAW_SERVICE_REPAIR_POLICY`]?.trim().toLowerCase()===`external`)return`external`;return isTruthyEnvValue(e[`OPENCLAW_UPDATE_IN_PROGRESS`])?`update`:`auto`}function isServiceRepairExternallyManaged(e,t=process.env){return(e??resolveServiceRepairPolicy(t))===`external`||isGatewayExternallySupervised(t)}function isServiceRepairDeferred(e=resolveServiceRepairPolicy()){return e===`update`||isServiceRepairExternallyManaged(e)}function formatServiceRepairDeferredNote(e=resolveServiceRepairPolicy()){return e===`update`?`Gateway service repair deferred to update finalization; Doctor left its definition and activation unchanged.`:EXTERNAL_SERVICE_REPAIR_NOTE}async function confirmDoctorServiceRepair(e,t,n=resolveServiceRepairPolicy()){return!isServiceRepairDeferred(n)&&await e.confirmRuntimeRepair(t)}export{isServiceRepairDeferred as a,resolveUpdateParentGatewayActivation as c,formatServiceRepairDeferredNote as i,shouldManageGatewayService as l,assertDoctorServiceSelection as n,isServiceRepairExternallyManaged as o,confirmDoctorServiceRepair as r,resolveServiceRepairPolicy as s,SERVICE_REPAIR_POLICY_ENV as t};