Files
veridian/server/api/agent/index.post.ts
zoeissleeping 57e7a92cd1 fix: UI polish and provider fixes
- Add animate-pulse CSS animation for loading states
- Add Ctrl+I/Ctrl+B markdown shortcuts in chat input
- Improve chat input resize with mirror element
- Add reasoning duration display and shimmer effect
- Add confirmation dialog for deleting all models
- Simplify RowVirtualizerDynamic resize handling
- Fix DialogType imports (type -> value)
- Fix ollama cloud model name resolution
- Make vllm auth header optional
- Various icon and styling fixes
2026-05-11 17:44:00 -05:00

46 lines
1.1 KiB
TypeScript

import { createInsertSchema } from 'drizzle-orm/zod';
import { db } from '~~/server/lib/db';
import { agents } from '~~/drizzle/schema';
import { userEvents } from '~~/server/utils/events';
export default defineEventHandler(async (event) => {
await protectRoute(event);
const userId = event.context.user!.id;
const result = await readValidatedBody(event,
createInsertSchema(agents).safeParse
);
if (!result.success) {
throw createError({
statusCode: 400,
message: result.error.issues[0]!.message,
});
}
if (!result.data.userId) {
result.data.userId = userId;
}
if (result.data.userId !== userId) {
throw createError({
statusCode: 403,
statusMessage: 'Forbidden',
data: {
code: 'FORBIDDEN',
ok: false,
}
});
}
// @ts-expect-error - shut up
await db.insert(agents).values(result.data).onConflictDoNothing();
userEvents.emit(userId, 'agents', {
op: 'create',
payload: result.data,
});
return { ok: true };
})