UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

80 lines (79 loc) • 4.25 kB
import { a as isExternallyDistributedPlugin, h as resolveOfficialExternalPluginLabel, i as getOfficialExternalPluginCatalogEntryForPackage, m as resolveOfficialExternalPluginInstallSources, r as getOfficialExternalPluginCatalogEntry } from "./official-external-plugin-catalog-DtkWz1Xo.mjs"; import { g as resolveOfficialExternalPluginId, o as getOfficialExternalPluginCatalogManifest } from "./official-external-plugin-catalog-source-4o5oPhVN.mjs"; import { m as resolveConfiguredChannelPresencePolicy } from "./channel-presence-policy-6XNqNGJr.mjs"; import "./channel-plugin-ids-DZDzcpUB.mjs"; //#region src/plugins/official-external-plugin-repair-hints.ts /** * Bundled plugins ship their dependencies inside the root package, so dependency status is * only meaningful for external installs and for externally distributed plugins whose runtime * was compiled into the bundled tree without its plugin-local dependencies. */ function tracksPluginDependencyStatus(e) { return e.origin !== "bundled" || isExternallyDistributedPlugin(e); } /** * Names the install path when an externally distributed plugin fails to import its runtime * dependencies. Source builds compile these plugins into `dist/extensions/<id>` but their * dependencies stay plugin-local, so a moved or pruned checkout leaves the dist link dangling. */ 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.`; } /** Resolves install/doctor commands for an official external plugin or channel id. */ 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}.` }; } /** Resolves repair hints for missing configured channels with one presence-policy pass. */ 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 }] : []; }); } /** Resolves a repair hint only when a missing configured channel is blocked by no plugin owner. */ function resolveMissingOfficialExternalChannelPluginRepairHint(e) { return resolveMissingOfficialExternalChannelPluginRepairHints({ ...e, channelIds: [e.channelId] })[0] ?? null; } //#endregion export { tracksPluginDependencyStatus as a, resolveOfficialExternalPluginRepairHint as i, resolveMissingOfficialExternalChannelPluginRepairHint as n, resolveMissingOfficialExternalChannelPluginRepairHints as r, resolveExternalPluginRuntimeDependencyRepairHint as t };