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) => {