()
| 597 | } |
| 598 | |
| 599 | async function main(): Promise<void> { |
| 600 | const exportData = loadExport(); |
| 601 | const evalSummaries = toEvalSummaries(exportData); |
| 602 | const analysisLinks = loadAnalysisLinks(); |
| 603 | const payloads = buildPayloads(evalSummaries, analysisLinks); |
| 604 | |
| 605 | console.log("===== Plain-text preview =====\n"); |
| 606 | for (const summary of evalSummaries) { |
| 607 | console.log(`Eval: ${summary.label} (${summary.eval})`); |
| 608 | summary.models.forEach((model) => { |
| 609 | console.log(`Model: ${model.id}`); |
| 610 | console.log(` Score: ${model.final.toFixed(3)}`); |
| 611 | model.rows.forEach((row) => { |
| 612 | console.log(` - ${row.name}: ${row.average.toFixed(3)}`); |
| 613 | }); |
| 614 | }); |
| 615 | console.log(""); |
| 616 | } |
| 617 | |
| 618 | console.log("===== Webhook payload JSON =====\n"); |
| 619 | payloads.forEach((payload, index) => { |
| 620 | console.log(`--- Payload ${index + 1}/${payloads.length} ---`); |
| 621 | console.log(JSON.stringify(payload, null, 2)); |
| 622 | }); |
| 623 | |
| 624 | const webhookUrl = process.env.DISCORD_WEBHOOK_URL?.trim(); |
| 625 | if (!webhookUrl) { |
| 626 | console.log("DISCORD_WEBHOOK_URL not set; skipping Discord webhook send."); |
| 627 | return; |
| 628 | } |
| 629 | |
| 630 | try { |
| 631 | for (const [index, payload] of payloads.entries()) { |
| 632 | await sendWebhook(webhookUrl, payload, index + 1, payloads.length); |
| 633 | // Add delay between messages to ensure proper ordering in Discord |
| 634 | if (index < payloads.length - 1) { |
| 635 | await new Promise((resolve) => setTimeout(resolve, 1000)); |
| 636 | } |
| 637 | } |
| 638 | } catch (error) { |
| 639 | const message = error instanceof Error ? error.message : String(error); |
| 640 | console.error(`Failed to deliver Discord webhook: ${message}`); |
| 641 | process.exitCode = 1; |
| 642 | } |
| 643 | } |
| 644 | |
| 645 | await main(); |
no test coverage detected