{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../src/astro/routes/api/admin/plugins/index.ts"],"sourcesContent":["/**\n * Plugin management list endpoint\n *\n * GET /_emdash/api/admin/plugins - List all configured plugins with state\n */\n\nimport type { APIRoute } from \"astro\";\n\nimport { requirePerm } from \"#api/authorize.js\";\nimport { apiError, unwrapResult } from \"#api/error.js\";\nimport { handlePluginList } from \"#api/index.js\";\n\nexport const prerender = false;\n\nexport const GET: APIRoute = async ({ locals }) => {\n\tconst { emdash, user } = locals;\n\n\tif (!emdash?.db) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\n\tconst denied = requirePerm(user, \"plugins:read\");\n\tif (denied) return denied;\n\n\tconst result = await handlePluginList(\n\t\temdash.db,\n\t\temdash.configuredPlugins,\n\t\temdash.sandboxedPluginEntries,\n\t\temdash.config.marketplace,\n\t\t(pluginId) => emdash.getRuntimePluginSettingsSchema(pluginId),\n\t);\n\tif (result.success) {\n\t\tconst tools = await emdash.getPluginMcpTools();\n\t\tfor (const item of result.data.items) {\n\t\t\titem.mcpTools = tools\n\t\t\t\t.filter((tool) => tool.pluginId === item.id)\n\t\t\t\t.map(({ inputSchema: _, outputSchema: __, pluginId: ___, ...tool }) => tool);\n\t\t}\n\t}\n\n\treturn unwrapResult(result);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAa,YAAY;AAEzB,MAAa,MAAgB,OAAO,EAAE,aAAa;CAClD,MAAM,EAAE,QAAQ,SAAS;AAEzB,KAAI,CAAC,QAAQ,GACZ,QAAO,SAAS,kBAAkB,6BAA6B,IAAI;CAGpE,MAAM,SAAS,YAAY,MAAM,eAAe;AAChD,KAAI,OAAQ,QAAO;CAEnB,MAAM,SAAS,MAAM,iBACpB,OAAO,IACP,OAAO,mBACP,OAAO,wBACP,OAAO,OAAO,cACb,aAAa,OAAO,+BAA+B,SAAS,CAC7D;AACD,KAAI,OAAO,SAAS;EACnB,MAAM,QAAQ,MAAM,OAAO,mBAAmB;AAC9C,OAAK,MAAM,QAAQ,OAAO,KAAK,MAC9B,MAAK,WAAW,MACd,QAAQ,SAAS,KAAK,aAAa,KAAK,GAAG,CAC3C,KAAK,EAAE,aAAa,GAAG,cAAc,IAAI,UAAU,KAAK,GAAG,WAAW,KAAK;;AAI/E,QAAO,aAAa,OAAO"}