merge: fix/ux-leaf-d-new-pages into integration/ux-28-gaps

This commit is contained in:
2026-07-29 20:31:22 +00:00
7 changed files with 1018 additions and 15 deletions
+24 -1
View File
@@ -4,8 +4,10 @@
// See AGENTS.md for full rules.
import { NextRequest, NextResponse } from 'next/server';
import { withAuth } from '@/lib/auth';
import { withAuth, createErrorResponse } from '@/lib/auth';
import { createPocketBaseClient } from '@/lib/pocketbase';
import { createAgentTaskSchema } from '@project-e/shared';
import { z } from 'zod';
// GET /api/agent-tasks — List agent tasks
export const GET = withAuth(async (request: NextRequest) => {
@@ -27,3 +29,24 @@ export const GET = withAuth(async (request: NextRequest) => {
perPage: result.perPage,
});
});
// POST /api/agent-tasks — Create a new agent task
export const POST = withAuth(async (request: NextRequest) => {
try {
const body = await request.json();
const data = createAgentTaskSchema.parse(body);
const pb = createPocketBaseClient();
const task = await pb.collection('agent_tasks').create({
...data,
status: 'pending',
});
return NextResponse.json(task, { status: 201 });
} catch (error) {
if (error instanceof z.ZodError) {
return createErrorResponse('VALIDATION_ERROR', 'Invalid input', 400, error.issues);
}
throw error;
}
});