feat(api): массовое удаление агентов (POST /agents/delete-bulk)
This commit is contained in:
@@ -212,6 +212,30 @@ export const agentsRoutes: FastifyPluginAsync<{ config: AppConfig }> = async (
|
|||||||
return { ok: true }
|
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 } }>(
|
app.post<{ Params: { id: string; sourceId: string } }>(
|
||||||
'/agents/:id/clone-from/:sourceId',
|
'/agents/:id/clone-from/:sourceId',
|
||||||
async (req) => {
|
async (req) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user