openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 2.4 kB
JavaScript
import{l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{n as discoverOpenClawPlugins}from"./discovery-Bo4UPPd9.mjs";import{a as getCurrentPluginMetadataSnapshotState,o as getGatewayPluginMetadataSnapshot}from"./plugin-metadata-lifecycle-Bdt91XXL.mjs";import{t as createSubsystemLogger}from"./subsystem-DLCDFvCH.mjs";import{r as resolveInstalledPluginIndexStorePath}from"./installed-plugin-index-store-path-Bf4Iuysu.mjs";import{i as loadInstalledPluginIndexInstallRecordsSync}from"./installed-plugin-index-record-reader-rJXlMUQ8.mjs";import{n as resolvePluginTrust}from"./installed-plugin-record-match-Bljxo1oW.mjs";import{t as resolvePluginMetadataEnvFingerprint}from"./plugin-metadata-env-CV6pWlZT.mjs";
//!src/plugins/channel-catalog-registry.ts
const log=createSubsystemLogger(`plugins/channel-catalog`);function listChannelCatalogEntries(e={}){let t=e.discovery;const n=e.installRecords??(t?void 0:resolveInstallRecords(e));if(!t)t=discoverOpenClawPlugins({workspaceDir:e.workspaceDir,env:e.env,extraPaths:e.extraPaths,...n&&Object.keys(n).length>0?{installRecords:n}:{}});return t.candidates.flatMap(t=>{if(e.origin&&t.origin!==e.origin)return[];const r=t.packageManifest?.channel;if(!r?.id)return[];const i=normalizeOptionalString(t.bundledManifest?.id)??normalizeOptionalString(t.bundledManifestId)??normalizeOptionalString(t.packageManifest?.plugin?.id)??normalizeOptionalString(t.idHint);if(!i)return[];return[{pluginId:i,...n&&resolvePluginTrust({candidate:t,installRecords:n,env:e.env??process.env,registryPath:resolveInstalledPluginIndexStorePath({env:e.env})}).reason===`trusted-official`?{trustedOfficialInstall:true}:{},origin:t.origin,packageName:t.packageName,workspaceDir:t.workspaceDir,rootDir:t.rootDir,channel:r,...t.packageManifest?.install?{install:t.packageManifest.install}:{}}]})}function resolveInstallRecords(e){if(e.installRecords||e.origin===`bundled`)return e.installRecords;const t=getGatewayPluginMetadataSnapshot();if(t&&getCurrentPluginMetadataSnapshotState().envFingerprint===resolvePluginMetadataEnvFingerprint(e.env))return t.index.installRecords;try{return loadInstalledPluginIndexInstallRecordsSync(e.env?{env:e.env}:{})}catch(e){log.warn(`Channel catalog could not load plugin installation records; installed channels may be missing. Run openclaw doctor to inspect plugin state.`,{error:e});return}}export{listChannelCatalogEntries as t};