openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 3.1 kB
JavaScript
import{a as isExternallyDistributedPlugin,h as resolveOfficialExternalPluginLabel,i as getOfficialExternalPluginCatalogEntryForPackage,m as resolveOfficialExternalPluginInstallSources,r as getOfficialExternalPluginCatalogEntry}from"./official-external-plugin-catalog-BkSwu5lo.mjs";import{g as resolveOfficialExternalPluginId,o as getOfficialExternalPluginCatalogManifest}from"./official-external-plugin-catalog-source-WW0GK1Kk.mjs";import{p as resolveConfiguredChannelPresencePolicy}from"./channel-presence-policy-iYxMh2HT.mjs";import"./channel-plugin-ids--iuNYdtE.mjs";
//!src/plugins/official-external-plugin-repair-hints.ts
function tracksPluginDependencyStatus(e){return e.origin!==`bundled`||isExternallyDistributedPlugin(e)}function resolveExternalPluginRuntimeDependencyRepairHint(e){if(!tracksPluginDependencyStatus(e))return;const t=getOfficialExternalPluginCatalogEntryForPackage(e.packageName);const n=t&&resolveOfficialExternalPluginId(t)===e.pluginId?buildOfficialExternalPluginRepairHint(t,e.pluginId):null;return n?`runtime dependencies are missing for externally distributed plugin ${n.label}; ${n.repairHint}`:`runtime dependencies are missing for externally distributed plugin ${e.pluginId}; reinstall or update the plugin package, then restart the Gateway.`}function resolveOfficialExternalPluginRepairHint(e){const t=getOfficialExternalPluginCatalogEntry(e);return t?buildOfficialExternalPluginRepairHint(t,e):null}function buildOfficialExternalPluginRepairHint(e,t){const n=resolveOfficialExternalPluginInstallSources(e)[0];if(!n)return null;const r=n.spec;const i=getOfficialExternalPluginCatalogManifest(e);const a=resolveOfficialExternalPluginId(e)??t.trim();const o=i?.channel?.id?.trim();const s=resolveOfficialExternalPluginLabel(e);const c=`openclaw plugins install ${n.source===`npm`?`npm:${r}`:r}`;const l=`openclaw doctor --fix`;return{pluginId:a,...o?{channelId:o}:{},label:s,installSpec:r,installCommand:c,doctorFixCommand:l,repairHint:`Install the official external plugin with: ${c}, or run: ${l}.`}}function resolveMissingOfficialExternalChannelPluginRepairHints(e){if(e.channelIds.length===0)return[];const t=new Map(resolveConfiguredChannelPresencePolicy({config:e.config,activationSourceConfig:e.activationSourceConfig,workspaceDir:e.workspaceDir,env:e.env,includePersistedAuthState:false,manifestRecords:e.manifestRecords}).map(e=>[e.channelId,e]));return e.channelIds.flatMap(e=>{const n=resolveOfficialExternalPluginRepairHint(e);if(!n?.channelId||n.channelId!==e)return[];const r=t.get(n.channelId);return r&&!r.effective&&r.blockedReasons.length===1&&r.blockedReasons[0]===`no-channel-owner`?[{...n,channelId:n.channelId}]:[]})}function resolveMissingOfficialExternalChannelPluginRepairHint(e){return resolveMissingOfficialExternalChannelPluginRepairHints({...e,channelIds:[e.channelId]})[0]??null}export{tracksPluginDependencyStatus as a,resolveOfficialExternalPluginRepairHint as i,resolveMissingOfficialExternalChannelPluginRepairHint as n,resolveMissingOfficialExternalChannelPluginRepairHints as r,resolveExternalPluginRuntimeDependencyRepairHint as t};