import { defineWrappedResponseHandler } from "#server/utils/handler"; import { R } from "#server/utils/response"; import { requireAdmin } from "#server/utils/admin-guard"; import { setGlobalConfigValue } from "#server/service/config"; export default defineWrappedResponseHandler(async (event) => { await requireAdmin(event); const body = await readBody(event); const { publicToolSlugs } = body as { publicToolSlugs?: string[] }; if (!Array.isArray(publicToolSlugs)) { return R.error("参数无效", null); } for (const slug of publicToolSlugs) { if (typeof slug !== "string" || slug.length === 0) { return R.error("工具slug无效", null); } } await setGlobalConfigValue("agentPublicToolSlugs", publicToolSlugs); return R.success({ publicToolSlugs }); });