| 432 | } |
| 433 | |
| 434 | function loadAnalysisLinks(): Map<string, string> { |
| 435 | const filePath = process.env.ANALYSIS_LINKS_FILE?.trim(); |
| 436 | if (!filePath) { |
| 437 | return new Map(); |
| 438 | } |
| 439 | |
| 440 | try { |
| 441 | const raw = readFileSync(filePath, "utf-8"); |
| 442 | const entries = JSON.parse(raw) as AnalysisLinkEntry[]; |
| 443 | return new Map( |
| 444 | entries |
| 445 | .filter( |
| 446 | (entry) => |
| 447 | typeof entry?.eval === "string" && |
| 448 | entry.eval.length > 0 && |
| 449 | typeof entry?.url === "string" && |
| 450 | entry.url.length > 0, |
| 451 | ) |
| 452 | .map((entry) => [entry.eval, entry.url]), |
| 453 | ); |
| 454 | } catch (error) { |
| 455 | console.error( |
| 456 | `[discord] Failed to load analysis links from ${filePath}:`, |
| 457 | error, |
| 458 | ); |
| 459 | return new Map(); |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | function buildPayloads( |
| 464 | evalSummaries: EvalSummary[], |