openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
48 lines (47 loc) • 2.4 kB
JavaScript
import { l as normalizeOptionalString } from "./string-coerce-CIXf7egm.js";
import { i as getGatewayPluginMetadataSnapshot } from "./current-plugin-metadata-state-B1UoAr4G.js";
import { n as discoverOpenClawPlugins } from "./discovery-D_VDsZuY.js";
import { i as loadInstalledPluginIndexInstallRecordsSync } from "./installed-plugin-index-record-reader-SXWwf_BU.js";
//#region src/plugins/channel-catalog-registry.ts
function listChannelCatalogEntries(params = {}) {
if (params.discovery) resolveInstallRecords(params);
const snapshot = !params.discovery && !params.installRecords ? getGatewayPluginMetadataSnapshot() : void 0;
return (snapshot ? [...snapshot.plugins, ...(snapshot.bundledManifestRegistry?.plugins ?? []).filter((bundled) => snapshot.byPluginId.get(bundled.id)?.rootDir !== bundled.rootDir)] : (params.discovery ?? resolveChannelCatalogDiscovery(params)).candidates).flatMap((candidate) => {
if (params.origin && candidate.origin !== params.origin) return [];
const channel = candidate.packageManifest?.channel;
if (!channel?.id) return [];
const pluginId = "id" in candidate ? candidate.id : resolveChannelCatalogPluginId(candidate);
if (!pluginId) return [];
return [{
pluginId,
origin: candidate.origin,
packageName: candidate.packageName,
workspaceDir: candidate.workspaceDir,
rootDir: candidate.rootDir,
channel,
...candidate.packageManifest?.install ? { install: candidate.packageManifest.install } : {}
}];
});
}
function resolveChannelCatalogDiscovery(params) {
const installRecords = resolveInstallRecords(params);
return discoverOpenClawPlugins({
workspaceDir: params.workspaceDir,
env: params.env,
extraPaths: params.extraPaths,
...installRecords && Object.keys(installRecords).length > 0 ? { installRecords } : {}
});
}
function resolveChannelCatalogPluginId(candidate) {
return normalizeOptionalString(candidate.bundledManifest?.id) ?? normalizeOptionalString(candidate.bundledManifestId) ?? normalizeOptionalString(candidate.packageManifest?.plugin?.id) ?? normalizeOptionalString(candidate.idHint);
}
function resolveInstallRecords(params) {
if (params.installRecords || params.origin === "bundled") return params.installRecords;
try {
return loadInstalledPluginIndexInstallRecordsSync(params.env ? { env: params.env } : {});
} catch {
return;
}
}
//#endregion
export { listChannelCatalogEntries as t };