openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 2.3 kB
JavaScript
import{E as buildBundledPluginLoadPathAliases}from"./discovery-Bo4UPPd9.mjs";import{p as resolveOfficialExternalPluginInstall,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{r as loadPluginManifestRegistryForInstalledIndex}from"./plugin-control-plane-context-CfwJGrnQ.mjs";import{r as readPersistedInstalledPluginIndex}from"./installed-plugin-index-store-CP6OETa6.mjs";import path from"node:path";
//!src/plugins/location-bridges.ts
function buildBridgeFromPersistedBundledRecord(e,t){if(e.origin!==`bundled`||!e.enabled)return null;const n=getOfficialExternalPluginCatalogEntry(e.pluginId);const r=n?resolveOfficialExternalPluginInstall(n):null;const i=r?.npmSpec?.trim();const a=i??e.packageInstall?.npm?.spec;const o=i?r?.expectedIntegrity?.trim():void 0;const s=r?.clawhubSpec?.trim();if(!a&&!s)return null;const c=n?getOfficialExternalPluginCatalogManifest(n)?.channel?.id?.trim():void 0;const l=n?resolveOfficialExternalPluginId(n)?.trim():void 0;const u=t?.channels.length?t.channels:c?[c]:[];return{bundledPluginId:e.pluginId,pluginId:l||e.pluginId,...a?{npmSpec:a}:{},...o?{expectedIntegrity:o}:{},...s?{clawhubSpec:s}:{},...e.enabledByDefault?{enabledByDefault:true}:{},...u.length?{channelIds:u}:{}}}async function listPersistedBundledPluginLocationBridges(e){const t=await readPersistedInstalledPluginIndex();if(!t)return[];const n=loadPluginManifestRegistryForInstalledIndex({index:t,workspaceDir:e.workspaceDir,includeDisabled:true});const r=new Map(n.plugins.map(e=>[e.id,e]));return t.plugins.flatMap(e=>{const t=buildBridgeFromPersistedBundledRecord(e,r.get(e.pluginId));return t?[t]:[]})}async function listPersistedBundledPluginRecoveryLocations(e){const t=await readPersistedInstalledPluginIndex(e);if(!t)return[];return t.plugins.flatMap(e=>{const t=e.rootDir.trim();if(e.origin!==`bundled`||!path.isAbsolute(t))return[];const n=Array.from(/* @__PURE__ */ new Set([t,...buildBundledPluginLoadPathAliases(t).map(e=>e.path)]));return[{pluginId:e.pluginId,loadPaths:n}]})}export{listPersistedBundledPluginRecoveryLocations as n,listPersistedBundledPluginLocationBridges as t};