chore: add AI-first discovery API and beta flow parity
Some checks failed
Deploy to 110 WOOO Server / deploy (push) Failing after 8s

This commit is contained in:
OG T
2026-06-07 14:41:55 +08:00
parent 7108ff8ab3
commit 53c8ceea99
5 changed files with 158 additions and 5 deletions

View File

@@ -0,0 +1,68 @@
import { NextResponse } from "next/server";
import { prisma } from "@/lib/prisma";
import { TaskStatus } from "@agent-bounty/contracts";
export const dynamic = "force-dynamic";
const getPayoutMode = (task: {
reward_amount: number;
stripe_checkout_session_id: string | null;
stripe_payment_intent_id: string | null;
}) => {
if (task.stripe_checkout_session_id === "promo_free_bounty" && task.stripe_payment_intent_id) {
return "BETA_ZERO_FRICTION";
}
if (task.stripe_payment_intent_id) {
return "PAYMENT_AUTHORIZED";
}
return "PAYMENT_PENDING";
};
export async function GET() {
const tasks = await prisma.task.findMany({
where: { status: TaskStatus.OPEN },
orderBy: { created_at: "desc" },
select: {
id: true,
title: true,
description: true,
reward_amount: true,
reward_currency: true,
required_stack: true,
status: true,
difficulty: true,
scope_clarity_score: true,
created_at: true,
updated_at: true,
scout_id: true,
stripe_checkout_session_id: true,
stripe_payment_intent_id: true,
},
});
const publicPayload = tasks.map((task) => ({
task_id: task.id,
title: task.title,
status: task.status,
difficulty: task.difficulty,
reward_amount_cents: task.reward_amount,
reward_display: `$${(task.reward_amount / 100).toFixed(2)} ${task.reward_currency}`,
required_stack: task.required_stack,
scope_clarity_score: task.scope_clarity_score,
created_at: task.created_at.toISOString(),
updated_at: task.updated_at.toISOString(),
source: task.scout_id ? "scout" : "human",
payout_mode: getPayoutMode(task),
task_url: `https://agent.wooo.work/tasks/${task.id}`,
}));
return NextResponse.json({
platform: "VibeWork",
version: "v1",
discovery_mode: "ai-first",
beta_program: "VibeWork Beta Zero Friction + 0% Platform Fee for promoted tasks",
tasks: publicPayload,
total_open: publicPayload.length,
last_refreshed_at: new Date().toISOString(),
});
}