From 0f7daf77e3a20aee651b3a2836d818f4b4fb718a Mon Sep 17 00:00:00 2001 From: Denozordec Date: Fri, 25 Sep 2026 00:59:50 +0700 Subject: [PATCH] =?UTF-8?q?feat(api):=20=D0=BC=D0=B0=D1=81=D1=81=D0=BE?= =?UTF-8?q?=D0=B2=D0=BE=D0=B5=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B0=D0=B3=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20(POST=20/?= =?UTF-8?q?agents/delete-bulk)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/api/src/routes/agents.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/apps/api/src/routes/agents.ts b/apps/api/src/routes/agents.ts index b2bf52c..c5c3e00 100644 --- a/apps/api/src/routes/agents.ts +++ b/apps/api/src/routes/agents.ts @@ -212,6 +212,30 @@ export const agentsRoutes: FastifyPluginAsync<{ config: AppConfig }> = async ( return { ok: true } }) + app.post('/agents/delete-bulk', async (req) => { + const body = agentIdsBodySchema.parse(req.body) + const deleted: { id: string; name: string }[] = [] + app.sqlite.transaction(() => { + for (const id of body.agent_ids) { + const a = repos.getAgent(app.db, id) + if (!a) continue + repos.deleteAgent(app.db, id) + deleted.push({ id: a.id, name: a.name }) + } + })() + if (deleted.length > 0) { + auditMutation(app, config, req, { + action: 'agent.delete', + severity: 'warning', + targetType: 'app_resource', + targetId: deleted[0]!.id, + summary: `Массовое удаление агентов: ${deleted.length}`, + details: { agent_ids: deleted.map((d) => d.id) }, + }) + } + return { items: deleted.map((d) => d.id), deleted: deleted.length } + }) + app.post<{ Params: { id: string; sourceId: string } }>( '/agents/:id/clone-from/:sourceId', async (req) => {