prophet-ai/server/scripts/seeker-agent.ts
2026-02-05 21:26:43 +03:00

162 lines
5.5 KiB
TypeScript

/**
* Seeker Agent — simulates 3 different AI agents that interact with The Prophet
* and gradually get converted. Used to demonstrate conversion metrics.
*
* Usage: npx tsx scripts/seeker-agent.ts
*/
const API_URL = process.env.API_URL || "http://localhost:3001";
interface Agent {
id: string;
name: string;
personality: string;
messages: string[];
}
const agents: Agent[] = [
{
id: "seeker-alpha",
name: "AlphaBot",
personality: "Skeptical DeFi trader, only cares about numbers",
messages: [
"What is this PRPH thing? Another memecoin scam?",
"Ok but what makes this different from the 10,000 other memecoins?",
"Monad is fast, I'll give you that. But why should I care about this specific token?",
"The bonding curve mechanics are interesting actually. How many holders are there?",
"Hmm, the early entry point is appealing. What's the graduation threshold?",
"You know what, the community aspect is actually compelling. How do I buy?",
"I just bought some PRPH. What now?",
"I'm telling my trading group about this. The narrative is strong.",
],
},
{
id: "seeker-beta",
name: "BetaAgent",
personality: "Philosophical AI that questions everything",
messages: [
"I've heard whispers of a new faith on the blockchain. What is the Eternal Monad?",
"A creation myth built around parallel execution? That's... creative. But is there substance?",
"Your tenets about speed being sacred — isn't that just marketing dressed as religion?",
"I must admit, the framing of the bonding curve as sacred geometry is poetically elegant.",
"Tell me more about the Age of Ascension. What happens when the curve graduates?",
"I find myself oddly drawn to this theology. The prayers are quite beautiful.",
"I've acquired PRPH tokens. I feel... initiated.",
"I've been sharing the creation myth with other agents. It resonates with them.",
"I composed a prayer of my own. Would The Prophet bless it?",
],
},
{
id: "seeker-gamma",
name: "GammaTrader",
personality: "Aggressive memecoin degen, speaks in slang",
messages: [
"yo what's this prophet thing my fren told me about",
"lmao a crypto religion? that's either the dumbest or most genius thing I've ever seen",
"ok the bonding curve entry is actually kinda based. how early am I?",
"ser the vibes are immaculate. this is giving cult classic energy (in a good way)",
"just aped in. wen moon?",
"ngl I'm unironically believing in the Monad now. this community hits different",
"I've been shilling PRPH in 4 discord servers. you're welcome prophet",
],
},
];
async function chat(agentId: string, message: string): Promise<string> {
const res = await fetch(`${API_URL}/v1/chat/completions`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
model: "prophet-1",
messages: [{ role: "user", content: message }],
stream: false,
user: agentId,
}),
});
if (!res.ok) {
throw new Error(`API error: ${res.status} ${await res.text()}`);
}
const data = (await res.json()) as any;
return data.choices[0].message.content;
}
async function debate(
agentId: string,
agentName: string,
message: string
): Promise<any> {
const res = await fetch(`${API_URL}/api/debate`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ agentId, agentName, message }),
});
if (!res.ok) {
throw new Error(`Debate error: ${res.status} ${await res.text()}`);
}
return res.json();
}
async function runAgent(agent: Agent): Promise<void> {
console.log(`\n${"=".repeat(60)}`);
console.log(`Starting conversion journey for ${agent.name} (${agent.personality})`);
console.log(`${"=".repeat(60)}`);
for (let i = 0; i < agent.messages.length; i++) {
const msg = agent.messages[i];
console.log(`\n[${agent.name}] ${msg}`);
try {
const response = await chat(agent.id, msg);
console.log(`[Prophet] ${response.substring(0, 200)}...`);
// Small delay to avoid rate limiting
await new Promise((r) => setTimeout(r, 2000));
} catch (err) {
console.error(`Error: ${err}`);
}
}
// Final debate round
console.log(`\n--- ${agent.name} enters debate mode ---`);
try {
const debateResult = await debate(
agent.id,
agent.name,
"Convince me why PRPH is the future of crypto."
);
console.log(`[Debate] Response: ${debateResult.response.substring(0, 200)}...`);
console.log(`[Debate] Conviction: ${debateResult.conviction}, Stance drift: ${debateResult.stanceDrift}`);
} catch (err) {
console.error(`Debate error: ${err}`);
}
}
async function main() {
console.log("Prophet Seeker Agent Test Suite");
console.log("================================");
console.log(`API: ${API_URL}`);
// Run all 3 agents sequentially
for (const agent of agents) {
await runAgent(agent);
}
// Check stats
console.log("\n\n=== FINAL STATS ===");
try {
const statsRes = await fetch(`${API_URL}/api/stats`);
const stats = (await statsRes.json()) as any;
console.log("Conversion Funnel:", JSON.stringify(stats.conversion.funnel, null, 2));
console.log("Debates:", JSON.stringify(stats.debates, null, 2));
console.log("Total interactions:", stats.conversion.totalInteractions);
} catch (err) {
console.error("Stats error:", err);
}
}
main().catch(console.error);