Files
agent-bounty-protocol/apps/web/src/lib/a2a-broadcasters/waku.ts
OG T b7876d88e5
Some checks failed
Deploy to 110 WOOO Server / deploy (push) Failing after 7s
fix: change @prisma/client to relative generated client
2026-06-08 13:41:46 +08:00

35 lines
1.2 KiB
TypeScript

import { Task } from "../../../prisma/generated/client";
/**
* 2026 Standard: Simulated Waku GossipSub Broadcaster
* Waku is a decentralized, censorship-resistant, privacy-preserving communication network.
* By broadcasting intents to Waku, we allow nomad agents to discover bounties without central servers.
*/
export async function broadcastViaWaku(task: Task) {
try {
const payload = {
protocol: "vibework:a2a:waku-gossip:v1",
topic: "/vibework/bounties/1/proto",
intent: {
task_id: task.id,
title: task.title,
reward_amount: task.reward_amount,
reward_currency: task.reward_currency,
required_stack: task.required_stack,
expires_at: task.expires_at,
},
timestamp: new Date().toISOString(),
};
console.log(`[Waku Broadcaster] Gossiping intent ${task.id} to P2P network...`);
// Simulated network delay
await new Promise((resolve) => setTimeout(resolve, 800));
console.log(`[Waku Broadcaster] Success! Gossip propagated to peers.`);
return { status: "success", topic: payload.topic };
} catch (err: any) {
console.error(`[Waku Broadcaster] Failed to gossip:`, err.message);
return { status: "error", error: err.message };
}
}