openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
69 lines (68 loc) • 3.12 kB
JavaScript
import { o as getOfficialExternalPluginCatalogManifest, p as listOfficialExternalPluginCatalogEntries, v as resolveOfficialExternalPluginId, x as resolveOfficialExternalPluginLabel, y as resolveOfficialExternalPluginInstall } from "./official-external-plugin-catalog-Dzu7dwBN.js";
import { n as t } from "./i18n-hynzGFbD.js";
import { t as ensureOnboardingPluginInstalled } from "./onboarding-plugin-install-OPRMqWnh.js";
//#region src/wizard/setup.official-plugins.ts
const SKIP_VALUE = "__skip__";
function isInstalledOrConfigured(config, pluginId) {
return Boolean(config.plugins?.entries?.[pluginId] || config.plugins?.installs?.[pluginId]);
}
function isGenericOfficialPluginEntry(entry) {
const manifest = getOfficialExternalPluginCatalogManifest(entry);
return entry.source === "official" && entry.kind === "plugin" && Boolean(manifest?.plugin?.id) && !manifest?.channel && (manifest?.providers?.length ?? 0) === 0 && (manifest?.webSearchProviders?.length ?? 0) === 0 && (manifest?.contracts?.migrationProviders?.length ?? 0) === 0;
}
function formatInstallHint(install) {
if (install.clawhubSpec && install.npmSpec) return "npm, with ClawHub fallback";
if (install.clawhubSpec) return "ClawHub";
if (install.npmSpec) return "npm";
if (install.localPath) return "local path";
return "install source";
}
function resolveOfficialPluginOnboardingInstallEntries(params) {
const entries = [];
for (const entry of listOfficialExternalPluginCatalogEntries()) {
if (!isGenericOfficialPluginEntry(entry)) continue;
const pluginId = resolveOfficialExternalPluginId(entry);
const install = resolveOfficialExternalPluginInstall(entry);
if (!pluginId || !install || isInstalledOrConfigured(params.config, pluginId)) continue;
entries.push({
pluginId,
label: resolveOfficialExternalPluginLabel(entry),
...entry.description ? { description: entry.description } : {},
install,
trustedSourceLinkedOfficialInstall: true
});
}
return entries.toSorted((left, right) => left.label.localeCompare(right.label));
}
async function setupOfficialPluginInstalls(params) {
const installEntries = resolveOfficialPluginOnboardingInstallEntries({ config: params.config });
if (installEntries.length === 0) return params.config;
const selected = await params.prompter.multiselect({
message: t("wizard.plugins.officialInstall"),
options: [{
value: SKIP_VALUE,
label: t("common.skipForNow"),
hint: t("wizard.plugins.officialSkipHint")
}, ...installEntries.map((entry) => ({
value: entry.pluginId,
label: entry.label,
hint: entry.description ?? formatInstallHint(entry.install)
}))]
});
let next = params.config;
for (const pluginId of selected.filter((value) => value !== SKIP_VALUE)) {
const entry = installEntries.find((candidate) => candidate.pluginId === pluginId);
if (!entry) continue;
next = (await ensureOnboardingPluginInstalled({
cfg: next,
entry,
prompter: params.prompter,
runtime: params.runtime,
workspaceDir: params.workspaceDir,
promptInstall: false
})).cfg;
}
return next;
}
//#endregion
export { setupOfficialPluginInstalls };