openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 6.11 kB
JavaScript
import{t as formatCliCommand}from"./command-format-D7KhNLP0.mjs";import{i as listAgentIds}from"./agent-roster-4XrgUgPK.mjs";import{f as resolveAgentWorkspaceDir}from"./agent-scope-config-CG9CFpGX.mjs";import{l as resolveOpenClawReleaseCohortVersion}from"./npm-registry-spec-D06XlvdA.mjs";import"./agent-scope-Dw5XRSEh.mjs";import{i as resolvePluginVersionDriftRegistryLag,o as resolvePluginVersionDriftUpdateCommand}from"./plugin-version-drift-DzQF-2yn.mjs";import{t as buildPluginRegistrySnapshotReport}from"./status-snapshot-DndbNSjm.mjs";import{i as buildPluginCompatibilityWarnings}from"./status-BHzK174N.mjs";
//!src/commands/doctor-workspace-status.ts
const WORKSPACE_STATUS_CHECK_ID=`core/doctor/workspace-status`;const PLUGIN_DIAGNOSTICS_DOCS=`https://docs.openclaw.ai/cli/plugins/inspect-and-diagnose#doctor`;function claimPluginDiagnostic(e,t){const n=[t.level,t.pluginId??``,t.code??``,t.errorCode??``,t.source??``,t.message].map(e=>`${e.length}:${e}`).join(``);if(e.has(n))return false;e.add(n);return true}function pluginVersionReadinessToHealthFindings(e){if(!e)return[];if(e.status===`unresolved`)return[{checkId:WORKSPACE_STATUS_CHECK_ID,severity:`warning`,category:`fix-now`,docsUrl:PLUGIN_DIAGNOSTICS_DOCS,message:`Could not check plugin restart readiness: ${e.reason}`,path:`plugins`,requirement:`plugin-version-restart-readiness`,fixHint:`Repair the Gateway service installation, then rerun openclaw doctor before restarting.`}];const{report:t,runningGatewayVersion:n}=e;if(t.drifts.length===0){if(!n||resolveOpenClawReleaseCohortVersion(n)===resolveOpenClawReleaseCohortVersion(t.gatewayVersion))return[];return[{checkId:WORKSPACE_STATUS_CHECK_ID,severity:`warning`,category:`fix-now`,docsUrl:PLUGIN_DIAGNOSTICS_DOCS,message:`Active official plugins match post-restart OpenClaw ${t.gatewayVersion}, but the running Gateway is ${n}.`,path:`plugins`,requirement:`plugin-version-gateway-restart`,fixHint:formatCliCommand(`openclaw gateway restart`)}]}return t.drifts.map(e=>{const r=resolvePluginVersionDriftRegistryLag(e);if(r)return{checkId:WORKSPACE_STATUS_CHECK_ID,severity:`info`,category:`recommended`,docsUrl:PLUGIN_DIAGNOSTICS_DOCS,message:`Plugin ${e.pluginId} is ${e.installedVersion} and its registry publishes no newer release (registry version ${r.registryVersion}), but a Gateway restart will load OpenClaw ${t.gatewayVersion}.${n?` The running Gateway is ${n}.`:``} No plugin update can reach ${r.expectedVersion}.`,path:`plugins.entries.${e.pluginId}`,target:e.pluginId,requirement:`plugin-version-drift`,fixHint:`No plugin repair is available. Keep the current plugin and check its official registry for a compatible release before changing versions.`};const i=resolvePluginVersionDriftUpdateCommand(e);const a=e.targetResolution;const o=e.targetResolution?.status===`unresolved`?e.targetResolution.error:`npm registry target was not resolved`;return{checkId:WORKSPACE_STATUS_CHECK_ID,severity:`warning`,category:`fix-now`,docsUrl:PLUGIN_DIAGNOSTICS_DOCS,message:`Plugin ${e.pluginId} is ${e.installedVersion}, but a Gateway restart will load OpenClaw ${t.gatewayVersion}.${a?.status===`resolved`?` The confirmed plugin target is ${a.version}.`:``}${n?` The running Gateway is ${n}.`:``}${i?``:` Repair target resolution failed: ${o}.`}`,path:`plugins.entries.${e.pluginId}`,target:e.pluginId,requirement:`plugin-version-drift`,fixHint:i?`${formatCliCommand(i)} && ${formatCliCommand(`openclaw gateway restart`)}`:`No install command generated; retry openclaw doctor after checking registry availability (${o}).`}})}function pluginDiagnosticToHealthFinding(e,t){return{checkId:WORKSPACE_STATUS_CHECK_ID,severity:e.level===`warn`?`warning`:e.level,category:e.level===`error`||e.code===`configured-plugin-path-unavailable`||e.code===`configured-plugin-path-inspection-failed`||e.code===`sdk-incompatible`?`fix-now`:`recommended`,docsUrl:PLUGIN_DIAGNOSTICS_DOCS,fixHint:e.fixHint??(e.level===`error`?`Run openclaw plugins inspect ${e.pluginId??`--all`} --runtime to inspect the failure. Restore the configured plugin path or update the plugin, then rerun openclaw doctor.`:`Run openclaw plugins inspect --all to review the named configuration or compatibility notice; update the affected plugin when a compatible release is available.`),message:t,...e.pluginId?{path:`plugins.entries.${e.pluginId}`,target:e.pluginId}:{},...e.source?{source:e.source}:{},...e.errorCode?{errorCode:e.errorCode}:{},requirement:e.code||`plugin-diagnostic`}}function collectPluginLoadHealthFindings(e){const t=/* @__PURE__ */ new Set;return e.filter(e=>claimPluginDiagnostic(t,e)).map(e=>pluginDiagnosticToHealthFinding(e,`Plugin ${e.pluginId}: ${e.message}${e.errorCode?` [${e.errorCode}]`:``} (${e.source})`))}function collectWorkspaceStatusHealthFindings(e,t={}){const n=[];const r=listAgentIds(e);const i=r.map(t=>({agentId:t,workspaceDir:resolveAgentWorkspaceDir(e,t)}));const a=/* @__PURE__ */ new Set;for(const{agentId:o,workspaceDir:s}of i){const inspect=()=>{const t=buildPluginRegistrySnapshotReport({config:e,workspaceDir:s});const i=buildPluginCompatibilityWarnings({config:e,workspaceDir:s,report:t});const c=r.length>1?`Agent "${o}":`:``;const l=[...t.diagnostics,...t.plugins.filter(e=>e.status===`error`&&!t.diagnostics.some(t=>t.pluginId===e.id&&t.level===`error`)).map(e=>({level:`error`,pluginId:e.id,source:e.source,message:e.error??`Plugin ${e.id} metadata inspection failed.`}))].filter(e=>claimPluginDiagnostic(a,e));const u=c?`${c} `:``;n.push(...i.map(e=>({checkId:WORKSPACE_STATUS_CHECK_ID,severity:`warning`,docsUrl:PLUGIN_DIAGNOSTICS_DOCS,message:`${u}${e}`,path:`plugins`,category:`recommended`,requirement:`plugin-compatibility`,fixHint:`Update or replace the plugin so it no longer depends on legacy compatibility paths.`})),...l.map(e=>pluginDiagnosticToHealthFinding(e,`${u}${e.message}`)))};if(t.runWithPluginMetadataSnapshot)t.runWithPluginMetadataSnapshot({config:e,workspaceDir:s},inspect);else inspect()}return[...pluginVersionReadinessToHealthFindings(t.pluginVersionReadiness),...n]}export{collectPluginLoadHealthFindings,collectWorkspaceStatusHealthFindings};