MCPcopy Create free account
hub / github.com/anomalyco/opencode-bench / buildPayloads

Function buildPayloads

scripts/discord-sample.ts:463–540  ·  view source on GitHub ↗
(
  evalSummaries: EvalSummary[],
  analysisLinks: Map<string, string>,
)

Source from the content-addressed store, hash-verified

461}
462
463function buildPayloads(
464 evalSummaries: EvalSummary[],
465 analysisLinks: Map<string, string>,
466): DiscordPayload[] {
467 const contentLink = resolveContentLink();
468 const overallChartUrl = buildOverallChartUrl(evalSummaries);
469
470 const embeds = evalSummaries.map((summary) => {
471 const fields = summary.models.map((model) => {
472 const finalScore = model.final.toFixed(3);
473 const decoratedValue = `[${finalScore}](${model.jobUrl})`;
474
475 return {
476 name: model.id,
477 value: decoratedValue,
478 inline: false,
479 };
480 });
481
482 const averageChartUrl = buildAverageChartUrl(summary.label, summary.models);
483
484 const analysisLink = analysisLinks.get(summary.eval);
485 assert(
486 typeof analysisLink === "string" && analysisLink.length > 0,
487 `Missing analysis link for evaluation "${summary.label}" (key: ${summary.eval}). Ensure analysis links are provided for every eval.`,
488 );
489
490 fields.push({
491 name: "Analysis",
492 value: `[Analysis](${analysisLink})`,
493 inline: false,
494 });
495
496 return {
497 title: summary.title,
498 color: embedColor,
499 fields,
500 ...(averageChartUrl
501 ? {
502 image: { url: averageChartUrl },
503 }
504 : {}),
505 };
506 });
507
508 const contentLines: string[] = [];
509 if (contentLink) {
510 contentLines.push(contentLink);
511 }
512 if (overallChartUrl) {
513 contentLines.push(`[Scoreboard](${overallChartUrl})`);
514 }
515
516 const content = contentLines.length > 0 ? contentLines.join("\n") : undefined;
517
518 const basePayload: Pick<DiscordPayload, "username" | "avatar_url"> = {
519 username: "opencode",
520 avatar_url:

Callers 1

mainFunction · 0.85

Calls 3

resolveContentLinkFunction · 0.85
buildOverallChartUrlFunction · 0.85
buildAverageChartUrlFunction · 0.85

Tested by

no test coverage detected