UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

56 lines (55 loc) • 2.73 kB
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs"; import { n as discoverOpenClawPlugins } from "./discovery-DvJYrQFY.mjs"; import { i as getGatewayPluginMetadataSnapshot, r as getCurrentPluginMetadataSnapshotState } from "./current-plugin-metadata-state-BmYo9Q7A.mjs"; import { t as createSubsystemLogger } from "./subsystem-BHJiy01V.mjs"; import { r as resolveInstalledPluginIndexStorePath } from "./installed-plugin-index-store-path-VYnur1Rc.mjs"; import { i as loadInstalledPluginIndexInstallRecordsSync } from "./installed-plugin-index-record-reader-B-7uGQZ9.mjs"; import { n as resolvePluginTrust } from "./installed-plugin-record-match-CL-dKCYg.mjs"; import { t as resolvePluginMetadataEnvFingerprint } from "./plugin-metadata-env-DmZ06vdA.mjs"; //#region 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; } } //#endregion export { listChannelCatalogEntries as t };