import { renderFirstTaskTranscript } from "./first-task-transcript.js"; import type { RunnerE2EResult } from "./types.js"; const html = (value: unknown) => String(value ?? "").replace( /[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[ c ]!, ); export function renderFirstTaskDetails(result?: RunnerE2EResult) { const e = result?.firstTask; if (!e) return ""; const prefix = `first-task-${encodeURIComponent(result!.executionId)}`; const q = result?.firstTaskQuality; const ref = (id: string) => `${prefix}-${encodeURIComponent(id)}`; const last = e.checkpoints.at(-1); return `
Read full conversation${renderFirstTaskTranscript(e, (id) => `#${ref(id)}`)}
Onboarding instructions, approval timeline, and quality

Source: ${html(e.source?.sha ?? result?.source?.sha ?? "Unknown")} · ${html(e.source?.ref ?? result?.source?.ref ?? "Unknown")} ${e.source?.dirty ? "(working tree modified; compare instruction hashes)" : ""}

${e.runtimeSettings?.onboardingRuntime ? `

Setup: ${html((e.runtimeSettings.onboardingRuntime as { mode: string }).mode)}.

` : ""}

Configured model: ${html(e.configuredModel ?? "Provider default")}. Observed: ${html(e.observedModels.join(", ") || "Not reported")}.

Runtime settings and permissions
${html(JSON.stringify(e.runtimeSettings ?? {}, null, 2))}
Full instruction snapshots (${e.instructions.length})${e.instructions.map((i) => `
${html(i.path)}

Source SHA-256: ${html(i.sha256)}

${i.redacted ? `

Credential redaction applied to this display copy. Display SHA-256: ${html(i.contentSha256)}

` : ""}
${html(i.content)}
`).join("")}

Quality scores are informational and never change behavioral pass/fail.

${ q ? `

Judge: ${html(q.config.model)} · ${html(q.status)} · estimated cost: ${html(q.estimatedCostUsd === null ? "unknown" : `$${q.estimatedCostUsd.toFixed(6)}`)} · reservation: $${q.reservedCostUsd.toFixed(6)} · ${html(q.inputTokens ?? "?")} input / ${html(q.outputTokens ?? "?")} output tokens.

${q.scores.map((s) => ``).join("")}
DimensionScore / 5Reason and evidence
${html(s.dimension)}${s.score}${html(s.rationale)} ${s.evidence.map((id) => `${html(id)}`).join(" ")}
Judge configuration and accounting
${html(JSON.stringify(q, null, 2))}
` : `

Not judged. Run the explicit judge command to add scores.

` }

Approval timeline

    ${e.checkpoints.map((c) => `
  1. ${html(c.phase)} · ${html(c.at)} · ${c.tasks.length} tasks · ${c.runs.length} runs
  2. `).join("")}

Resulting tasks and documents

${(last?.tasks ?? []) .map( (t) => `
${html(t.title)} · ${html(t.status)}
${html(JSON.stringify(t, null, 2))}
${( last?.documents ?? [] ) .filter((d) => d.issueId === t.id) .map( (d) => `
${html(d.key)} · ${html(d.title)}
${html(d.body)}
`, ) .join("")}
`, ) .join("")} ${e.checkpoints.map((c) => `
${html(c.id)} · ${html(c.at)}
${html(JSON.stringify(c, null, 2))}
`).join("")}
`; }