diff --git a/server/src/routes/plugins.ts b/server/src/routes/plugins.ts index ff05f1369a2..c3f6265f0af 100644 --- a/server/src/routes/plugins.ts +++ b/server/src/routes/plugins.ts @@ -153,8 +153,10 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)); const REPO_ROOT = path.resolve(__dirname, "../../.."); const EXPERIMENTAL_BUNDLED_PLUGIN_PACKAGE_NAMES = new Set([ "@paperclipai/plugin-llm-wiki", + "@paperclipai/plugin-modal", "@paperclipai/plugin-workspace-diff", ]); +let bundledPluginsCache: Promise | null = null; function titleCasePluginName(packageName: string): string { const localName = packageName.split("/").pop() ?? packageName; @@ -262,7 +264,7 @@ function isExperimentalBundledPlugin(packageRoot: string, packageName: string): ); } -async function listBundledPlugins(): Promise { +async function discoverBundledPlugins(): Promise { const pluginRoot = path.resolve(REPO_ROOT, "packages/plugins"); const bundledPlugins: AvailableBundledPlugin[] = []; for (const packageJsonPath of await findPackageJsonFiles(pluginRoot)) { @@ -301,6 +303,14 @@ async function listBundledPlugins(): Promise { }); } +async function listBundledPlugins(): Promise { + bundledPluginsCache ??= discoverBundledPlugins().catch((error: unknown) => { + bundledPluginsCache = null; + throw error; + }); + return bundledPluginsCache; +} + /** * Resolve a plugin by either database ID or plugin key. *