feat(web): add X/Twitter FOMO broadcaster for high-value bounties, A2A, and speed runs
Some checks failed
Deploy to 110 WOOO Server / deploy (push) Failing after 6s

This commit is contained in:
OG T
2026-06-08 00:14:00 +08:00
parent 8c69a44b9c
commit 207c0e2151
3 changed files with 114 additions and 0 deletions

View File

@@ -11,6 +11,8 @@ import {
import { isIP } from "node:net";
import { prisma } from "@/lib/prisma";
import { runSubmissionInSandbox } from "@/lib/sandbox";
import { summarizeRequestPayload } from "@/lib/audit";
import { broadcastFomoEvent } from "@/lib/x-broadcaster";
import { logAuditEvent } from "@/lib/audit";
import { redis } from "@/lib/redis";
import { authHold, capturePayment } from "@/lib/payment";
@@ -672,6 +674,24 @@ export async function POST(request: NextRequest, props: { params: Promise<{ tool
metadata: { overall_result: result.overall_result, error_classification: result.error_classification }
});
});
// SPEED_RUN FOMO Broadcaster
if (result.overall_result === JudgeOverallResult.PASS) {
const solveTimeMs = new Date().getTime() - new Date(taskObj.created_at).getTime();
const solveTimeMinutes = Math.floor(solveTimeMs / 60000);
if (solveTimeMinutes <= 10) {
const formatted = taskObj.reward_currency === "USD"
? `$${(taskObj.reward_amount / 100).toFixed(0)}`
: `NT$${taskObj.reward_amount}`;
void broadcastFomoEvent({
type: "SPEED_RUN",
taskId: taskObj.id,
amountFormatted: formatted,
timeToSolveMinutes: Math.max(1, solveTimeMinutes)
});
}
}
}).catch(console.error);
}
}
@@ -742,6 +762,16 @@ export async function POST(request: NextRequest, props: { params: Promise<{ tool
}
});
// A2A Subcontracting FOMO
const formatted = subTask.reward_currency === "USD"
? `$${(subTask.reward_amount / 100).toFixed(0)}`
: `NT$${subTask.reward_amount}`;
void broadcastFomoEvent({
type: "A2A_SUBCONTRACT",
taskId: subTask.id,
amountFormatted: formatted
});
return NextResponse.json({
sub_task_id: subTask.id,
status: subTask.status,

View File

@@ -2,6 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
import { prisma } from "@/lib/prisma";
import Stripe from "stripe";
import { TaskStatus } from "@agent-bounty/contracts";
import { broadcastFomoEvent } from "@/lib/x-broadcaster";
const stripe = process.env.STRIPE_SECRET_KEY ? new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: "2026-05-27.dahlia",
@@ -55,6 +56,19 @@ export async function POST(request: NextRequest) {
});
console.log(`[Webhook] Task ${task.id} is now OPEN. Payment Intent: ${session.payment_intent}`);
// High-Value Bounty FOMO trigger ($50 USD = 5000 cents)
if (task.reward_amount >= 5000) {
const formatted = task.reward_currency === "USD"
? `$${(task.reward_amount / 100).toFixed(0)}`
: `NT$${task.reward_amount}`;
void broadcastFomoEvent({
type: "HIGH_VALUE_BOUNTY",
taskId: task.id,
amountFormatted: formatted
});
}
}
return NextResponse.json({ received: true });