openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 904 B
JavaScript
import{c as normalizeOptionalLowercaseString}from"./string-coerce-CpTFcSwY.mjs";import path from"node:path";import fs from"node:fs/promises";
//!src/security/installed-plugin-dirs.ts
const IGNORED_INSTALLED_PLUGIN_DIR_NAMES=/* @__PURE__ */ new Set([`node_modules`,`.openclaw-install-backups`]);function shouldIgnoreInstalledPluginDirName(e){const t=normalizeOptionalLowercaseString(e);return!t||IGNORED_INSTALLED_PLUGIN_DIR_NAMES.has(t)||t.startsWith(`.`)||t.endsWith(`.bak`)||t.includes(`.backup-`)||t.includes(`.disabled`)}async function listInstalledPluginDirs(e){const t=path.join(e.stateDir,`extensions`);return{extensionsDir:t,pluginDirs:(await fs.readdir(t,{withFileTypes:true}).catch(t=>{const n=t?.code;if(n!==`ENOENT`&&n!==`ENOTDIR`)e.onReadError?.(t);return[]})).filter(e=>e.isDirectory()).map(e=>e.name).filter(e=>!shouldIgnoreInstalledPluginDirName(e))}}export{listInstalledPluginDirs as t};