openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
61 lines (60 loc) • 2.82 kB
JavaScript
import { u as buildBundledPluginLoadPathAliases } from "./discovery-DvJYrQFY.mjs";
import { p as resolveOfficialExternalPluginInstall, 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 { r as loadPluginManifestRegistryForInstalledIndex } from "./plugin-control-plane-context-BmY6xICT.mjs";
import { n as readPersistedInstalledPluginIndex } from "./installed-plugin-index-store-fgfm3NWB.mjs";
import path from "node:path";
//#region 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 } : {}
};
}
/** List install bridges inferred from the persisted plugin index before current discovery runs. */
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] : [];
});
}
/** List exact previous bundled paths that an explicit plugin reinstall may recover. */
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
}];
});
}
//#endregion
export { listPersistedBundledPluginRecoveryLocations as n, listPersistedBundledPluginLocationBridges as t };