openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
22 lines (21 loc) • 925 B
JavaScript
import { l as searchClawHubPackages } from "./clawhub-packages-BkEmBO-h.mjs";
//#region src/plugins/catalog-search.ts
const INSTALLABLE_PLUGIN_FAMILIES = ["code-plugin", "bundle-plugin"];
const DEFAULT_PLUGIN_SEARCH_LIMIT = 20;
const MAX_PLUGIN_SEARCH_LIMIT = 100;
async function searchInstallablePluginPackages(e) {
const t = !Number.isFinite(e.limit) || !e.limit || e.limit <= 0 ? DEFAULT_PLUGIN_SEARCH_LIMIT : Math.min(Math.max(Math.trunc(e.limit), 1), MAX_PLUGIN_SEARCH_LIMIT);
const n = await Promise.all(INSTALLABLE_PLUGIN_FAMILIES.map((n) => searchClawHubPackages({
query: e.query,
family: n,
limit: t
})));
const r = /* @__PURE__ */ new Map();
for (const e of n.flat()) {
const t = r.get(e.package.name);
if (!t || e.score > t.score) r.set(e.package.name, e);
}
return [...r.values()].toSorted((e, t) => t.score - e.score).slice(0, t);
}
//#endregion
export { searchInstallablePluginPackages as t };