UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 8.24 kB
import{i as asOptionalObjectRecord}from"./record-coerce-BTbqdJ3-.mjs";import{c as normalizePluginId,u as normalizePluginsConfig}from"./config-state-C1eV6UWf.mjs";import{i as passesManifestOwnerBasePolicy}from"./manifest-owner-policy-DVnu9FAE.mjs";import{_ as describePluginAvailabilityFailure}from"./discovery-Bo4UPPd9.mjs";import{n as loadBundledPluginManifestRegistry}from"./manifest-registry-build-DSmHjL9c.mjs";import{n as loadPluginManifestRegistryForPluginRegistry}from"./plugin-registry-contributions-C4xBwxaW.mjs";import{n as loadBundledPluginPublicArtifactModuleSync,r as loadPluginPublicArtifactModuleSync,t as loadBundledPluginPublicArtifactModuleFromCandidatesSync}from"./public-surface-loader-BNZQgUD9.mjs";import{i as resolveProviderPolicySurface}from"./provider-public-artifacts-DlwyY-Ow.mjs";import"./plugin-registry-BAbRxjjy.mjs";import{t as collectConfiguredAgentHarnessRuntimes}from"./harness-runtimes-DQSA2gCi.mjs";import{t as collectConfiguredWorkerProviderIds}from"./worker-provider-config-B2m51vyc.mjs";import{t as listBundledWorkerProviderOwners}from"./worker-provider-manifest-B-MZQnKD.mjs";import{i as registerHealthCheck,t as getHealthCheck}from"./health-check-registry-qx2G8L6q.mjs"; //!src/flows/bundled-health-checks.ts const HEALTH_CHECK_REGISTRATIONS=[registerMemoryCoreHealthChecks,registerCodexHealthChecks,registerPolicyHealthChecks,registerOpenAIHealthChecks,registerCuaHealthChecks,registerSkillWorkshopHealthChecks,registerBundledWorkerProviderHealthChecks];function loadMemoryCoreHealthApi(){return loadBundledPluginPublicArtifactModuleSync({dirName:`memory-core`,artifactBasename:`doctor-health-api.js`})}function resolveBundledHealthCheckPluginStateMode(e){if(e.updateReadiness!==void 0)return`isolated`;if(e.includeAllChecks!==true&&(e.onlyIds===void 0||e.onlyIds.length===0))return`direct`;const t=new Set(loadMemoryCoreHealthApi().pluginStateIsolatedDoctorCheckIds??[]);const n=new Set(e.skipIds??[]);const r=[...new Set(e.onlyIds??[])].filter(e=>!n.has(e));if((r.length>0?r.filter(e=>t.has(e)):[...t].filter(e=>!n.has(e))).length===0)return`direct`;if(r.length>0&&r.every(e=>t.has(e)))return`deferred`;return`isolated`}function registerBundledHealthChecks(e){if(e.updateReadiness!==void 0)return[];return HEALTH_CHECK_REGISTRATIONS.flatMap(t=>t(e,registerHealthCheck)??[])}function registerMemoryCoreHealthChecks(e,t){const n=e.env??process.env;loadMemoryCoreHealthApi().registerMemoryCoreDoctorChecks?.({getHealthCheck,registerHealthCheck:t,async inspectEmbeddingProviderSetup(t){const inspect=async n=>{const r=loadPluginManifestRegistryForPluginRegistry({config:e.cfg,workspaceDir:e.cwd,env:n});const i=resolveProviderPolicySurface(t.provider,{manifestRegistry:r})?.inspectEmbeddingProviderSetup;return i?await i({...t,env:n}):void 0};return e.runWithPluginStateSnapshot?await e.runWithPluginStateSnapshot(inspect):await inspect(n)},memoryCoreActive:isMemoryCoreActive(e.cfg)})}function resolveCodexHealthApi(e){if(!shouldRegisterCodexManagedHealth(e.cfg))return{status:`not-configured`};const unavailable=(e,t=true)=>({status:`unavailable`,reason:e,reportAvailability:t});const t=e.env??process.env;const n=loadPluginManifestRegistryForPluginRegistry({config:e.cfg,workspaceDir:e.cwd,env:t,pluginIds:[`codex`]}).plugins.find(e=>e.id===`codex`);if(!n){if(!collectConfiguredAgentHarnessRuntimes(e.cfg,{includeImplicitRuntimePreferences:false}).includes(`codex`))return{status:`not-configured`};return unavailable(`The configured Codex plugin was not found. Install it with openclaw plugins install @openclaw/codex.`)}if(n.origin!==`bundled`&&n.trustedOfficialInstall!==true)return unavailable(`The selected Codex plugin is not a bundled or verified official installation. Run openclaw plugins inspect codex --runtime --json to inspect its source; install the official plugin with openclaw plugins install @openclaw/codex.`);if(n.doctorHealthChecks!==true)return unavailable(`The selected Codex plugin does not advertise Doctor health checks.`,false);try{return{status:`available`,api:loadPluginPublicArtifactModuleSync({pluginRoot:n.rootDir,artifactBasename:`api.js`,origin:n.origin===`bundled`?`bundled`:`global`})}}catch{return unavailable(`The selected Codex plugin declares Doctor health checks but its health API could not be loaded. Run openclaw plugins inspect codex --runtime --json for details, or openclaw triage for repair help.`)}}function registerCodexHealthChecks(e,t){const unavailable=e=>[{checkId:`core/doctor/codex-session-routes`,...describePluginAvailabilityFailure(`codex`,e)}];const n=resolveCodexHealthApi(e);if(n.status===`not-configured`)return[];if(n.status===`unavailable`)return n.reportAvailability?unavailable(n.reason):[];if(typeof n.api.registerCodexManagedAppServerDoctorChecks!==`function`)return unavailable(`The selected Codex plugin's Doctor health checks are incomplete. Run openclaw plugins inspect codex --runtime --json for details, or openclaw triage for repair help.`);n.api.registerCodexManagedAppServerDoctorChecks({getHealthCheck,registerHealthCheck:t});return[]}function registerPolicyHealthChecks(e,t){if(shouldRegisterPolicyHealth(e.cfg))loadBundledPluginPublicArtifactModuleSync({dirName:`policy`,artifactBasename:`api.js`}).registerPolicyDoctorChecks?.({registerHealthCheck:t})}function registerOpenAIHealthChecks(e,t){loadBundledPluginPublicArtifactModuleSync({dirName:`openai`,artifactBasename:`doctor-health-api.js`}).registerOpenAIDoctorChecks?.({getHealthCheck,registerHealthCheck:t})}function registerSkillWorkshopHealthChecks(e,t){loadBundledPluginPublicArtifactModuleFromCandidatesSync({dirName:`skill-workshop`,artifactCandidates:[`doctor-health-api.js`]})?.registerSkillWorkshopDoctorChecks?.({getHealthCheck,registerHealthCheck:t,async explainToolAvailability(e){const{explainToolAvailability:t}=await import(`./tool-availability-explanation-DmQe8bEj.mjs`);return await t(e)}})}function registerCuaHealthChecks(e,t){if(shouldRegisterPluginHealth(e.cfg,`cua-computer`))loadBundledPluginPublicArtifactModuleSync({dirName:`cua-computer`,artifactBasename:`api.js`}).registerCuaDriverDoctorChecks?.({registerHealthCheck:t})}function registerBundledWorkerProviderHealthChecks(e,t){const n=e.env??process.env;const r=collectConfiguredWorkerProviderIds(e.cfg);if(r.length===0)return;const i=loadBundledPluginManifestRegistry({env:n});const a=new Set(listBundledWorkerProviderOwners(i,r).map(e=>e.pluginId));for(const e of a)loadBundledPluginPublicArtifactModuleFromCandidatesSync({dirName:e,artifactCandidates:[`doctor-health-api.js`]})?.registerWorkerProviderDoctorChecks?.({getHealthCheck,registerHealthCheck:t,async inspectSetupSecrets(e,t){const{inspectSetupSecretMigration:r}=await import(`./setup-secret-migration-Cf6GJt8D.mjs`);return r({names:e,env:t??n})},async listPluginStateEntries(t){const{createPluginStateKeyedStore:n}=await import(`./plugin-state-store-B10B16oV.mjs`);return n(e,t).entries()}})}function shouldRegisterCodexManagedHealth(e){if(e.plugins?.entries?.codex?.enabled!==true&&!collectConfiguredAgentHarnessRuntimes(e).includes(`codex`))return false;return passesManifestOwnerBasePolicy({plugin:{id:`codex`},normalizedConfig:normalizePluginsConfig(e.plugins)})}function isMemoryCoreActive(e){const t=normalizePluginsConfig(e.plugins);const n=typeof t.slots.memory===`string`?normalizePluginId(t.slots.memory):t.slots.memory;const r=e.plugins?.slots?.memory;const i=typeof r===`string`&&normalizePluginId(r)===`memory-core`;return n===`memory-core`&&passesManifestOwnerBasePolicy({plugin:{id:`memory-core`},normalizedConfig:t,allowRestrictiveAllowlistBypass:i})}function shouldRegisterPluginHealth(e,t){if((e.plugins?.entries?.[t])?.enabled!==true)return false;return passesManifestOwnerBasePolicy({plugin:{id:t},normalizedConfig:normalizePluginsConfig(e.plugins)})}function shouldRegisterPolicyHealth(e){const t=e.plugins?.entries?.policy;const n=asOptionalObjectRecord(t?.config)??{};if(t===void 0||t.enabled===false||n.enabled===false)return false;if(!passesManifestOwnerBasePolicy({plugin:{id:`policy`},normalizedConfig:normalizePluginsConfig(e.plugins)}))return false;return t.enabled===true||n.enabled===true}export{registerBundledHealthChecks,resolveBundledHealthCheckPluginStateMode,resolveCodexHealthApi};