ui: render the coverage ledger, threat model, and calibration fields

The six state tools added with the coverage ledger and the threat model had
no renderer in either UI, so they fell through to the generic fallback: a raw
key/value dump of the arguments, which printed a whole threat-model document
inline as one value. The five calibration fields on a vulnerability report
were likewise reaching the markdown report and SARIF but not the screen, so
the agent's own confidence and the case against a finding were invisible to
anyone watching the scan.

Go TUI gets a coverage renderer (outcome-colored rows, state transitions, and
the ledger's history and author) and a threat-model renderer (staleness,
amendments, and a heading-level preview instead of the full document), both
registered in the dispatch switch. list_coverage and get_threat_model join the
output-heavy tools that collapse to a preview.

The React viewer gets the same two as tool families, so an unknown future
tool matching /coverage/ or /threat_model/ lands on the right renderer rather
than the fallback.

Both vulnerability renderers now show confidence, its rationale,
counterevidence, the conditions that would move severity, and how a fix was
verified.
This commit is contained in:
Ahmed Allam
2026-08-09 12:21:32 +00:00
parent b76e3a984c
commit e833278499
13 changed files with 1112 additions and 153 deletions
@@ -0,0 +1,194 @@
package render
import (
"strconv"
"strings"
"github.com/charmbracelet/lipgloss"
)
// ---------------------------------------------------------------------------
// Coverage ledger (record_coverage / update_coverage / list_coverage)
// ---------------------------------------------------------------------------
// coverageOutcomes maps a ledger outcome to its marker and color. A cleared
// surface and an unresolved one must not look alike at a glance: the whole
// point of the ledger is that a reader can see which surfaces are still open.
var coverageOutcomes = map[string]struct {
marker string
label string
color lipgloss.Color
}{
"reported": {"!", "reported", SevHigh},
"no_issue_found": {"✓", "no issue found", Green},
"ruled_out": {"✓", "ruled out", Mint},
"not_applicable": {"", "not applicable", Slate},
"needs_follow_up": {"?", "needs follow-up", AmberY},
}
func coverageOutcome(outcome string) (string, string, lipgloss.Color) {
if meta, ok := coverageOutcomes[strings.TrimSpace(strings.ToLower(outcome))]; ok {
return meta.marker, meta.label, meta.color
}
if outcome == "" {
return "·", "", Gray
}
return "·", strings.ReplaceAll(outcome, "_", " "), Gray
}
var coverageTitles = map[string]struct {
title string
loading string
errMsg string
}{
"record_coverage": {"Coverage Recorded", "Recording...", "Failed to record coverage"},
"update_coverage": {"Coverage Updated", "Updating...", "Failed to update coverage"},
"list_coverage": {"Coverage", "Loading...", "Unable to list coverage"},
}
func renderCoverage(name string, args map[string]any, result any) string {
meta := coverageTitles[name]
var b strings.Builder
b.WriteString("▣ " + Bold(Cyan).Render(meta.title))
if s, ok := result.(string); ok && strings.TrimSpace(s) != "" {
b.WriteString("\n " + Dim().Render(strings.TrimSpace(s)))
return b.String()
}
m, ok := result.(map[string]any)
if !ok {
coverageArgsPreview(&b, name, args)
b.WriteString("\n " + Dim().Render(meta.loading))
return b.String()
}
if !truthy(m["success"]) {
coverageArgsPreview(&b, name, args)
errMsg := StringValue(m["error"])
if errMsg == "" {
errMsg = meta.errMsg
}
b.WriteString("\n " + Col(Red).Render(errMsg))
return b.String()
}
switch name {
case "list_coverage":
coverageListBody(&b, m)
case "update_coverage":
marker, label, color := coverageOutcome(StringValue(m["outcome"]))
_, previous, previousColor := coverageOutcome(StringValue(m["previous_outcome"]))
b.WriteString("\n " + Col(color).Render(marker) + " " + coverageSubject(args, m))
if previous != "" {
b.WriteString("\n " + Col(previousColor).Render(previous) +
Dim().Render(" → ") + Col(color).Render(label))
} else {
b.WriteString("\n " + Col(color).Render(label))
}
coverageEvidence(&b, StringValue(args["evidence"]))
default:
marker, label, color := coverageOutcome(StringValue(m["outcome"]))
b.WriteString("\n " + Col(color).Render(marker) + " " + coverageSubject(args, m))
b.WriteString("\n " + Col(color).Render(label))
coverageEvidence(&b, StringValue(args["evidence"]))
}
return b.String()
}
// coverageSubject names the surface being recorded, falling back to the entry
// id when only the id is known (an update carries no surface in its args).
func coverageSubject(args map[string]any, result map[string]any) string {
surface := strings.TrimSpace(StringValue(args["surface"]))
risk := strings.TrimSpace(StringValue(args["risk_area"]))
switch {
case surface != "" && risk != "":
return surface + Dim().Render(" · "+risk)
case surface != "":
return surface
case risk != "":
return risk
}
if id := StringValue(result["entry_id"]); id != "" {
return Dim().Render("entry " + id)
}
return Dim().Render("(unnamed surface)")
}
func coverageEvidence(b *strings.Builder, evidence string) {
if strings.TrimSpace(evidence) != "" {
b.WriteString("\n " + Dim().Render(psanitize(strings.TrimSpace(evidence), 160)))
}
}
func coverageArgsPreview(b *strings.Builder, name string, args map[string]any) {
if name == "list_coverage" {
return
}
if subject := coverageSubject(args, map[string]any{}); subject != "" {
b.WriteString("\n " + subject)
}
}
func coverageListBody(b *strings.Builder, result map[string]any) {
entries, _ := result["entries"].([]any)
total, _ := NumericValue(result["total_count"])
if len(entries) == 0 {
if int(total) == 0 {
b.WriteString("\n " + Dim().Render("No surfaces recorded yet"))
} else {
b.WriteString("\n " + Dim().Render("No surfaces match this filter"))
}
return
}
if counts, ok := result["outcome_counts"].(map[string]any); ok && len(counts) > 0 {
var parts []string
for _, outcome := range []string{
"reported", "no_issue_found", "ruled_out", "not_applicable", "needs_follow_up",
} {
count, ok := NumericValue(counts[outcome])
if !ok || count == 0 {
continue
}
_, label, color := coverageOutcome(outcome)
parts = append(parts, Col(color).Render(label+": "+strconv.Itoa(int(count))))
}
if len(parts) > 0 {
b.WriteString("\n " + strings.Join(parts, Dim().Render(" ")))
}
}
for _, e := range entries {
entry, _ := e.(map[string]any)
marker, label, color := coverageOutcome(StringValue(entry["outcome"]))
surface := strings.TrimSpace(StringValue(entry["surface"]))
if surface == "" {
surface = "(unnamed surface)"
}
b.WriteString("\n " + Col(color).Render(marker) + " " + surface)
if risk := strings.TrimSpace(StringValue(entry["risk_area"])); risk != "" {
b.WriteString(Dim().Render(" · " + risk))
}
b.WriteString("\n " + Col(color).Render(label))
// A row that moved states carries its own history; showing it keeps a
// closed surface from reading as one that was never in question.
if previous, ok := entry["previous_outcomes"].([]any); ok && len(previous) > 0 {
var was []string
for _, p := range previous {
if _, label, _ := coverageOutcome(StringValue(p)); label != "" {
was = append(was, label)
}
}
if len(was) > 0 {
b.WriteString(Dim().Render(" (was " + strings.Join(was, " → ") + ")"))
}
}
// Whose row this is matters for reconciliation: an agent needs to see
// at a glance which surfaces it owns and which came from a sibling.
if truthy(entry["by_you"]) {
b.WriteString(Dim().Render(" · you"))
} else if who := strings.TrimSpace(StringValue(entry["agent_name"])); who != "" {
b.WriteString(Dim().Render(" · " + who))
}
coverageEvidence(b, StringValue(entry["evidence"]))
}
}
@@ -0,0 +1,204 @@
package render
import (
"strings"
"testing"
"github.com/charmbracelet/x/ansi"
)
func TestRecordCoverageRendersSurfaceAndOutcome(t *testing.T) {
out := ansi.Strip(Tool(tool("record_coverage",
map[string]any{
"surface": "POST /api/v1/invoices",
"risk_area": "object-level authorization",
"evidence": "tenant B token returns 403 on tenant A invoice ids",
},
map[string]any{"success": true, "entry_id": "a1b2c3", "outcome": "ruled_out"},
"completed")))
requireContains(t, out,
"Coverage Recorded",
"POST /api/v1/invoices",
"object-level authorization",
"ruled out",
"tenant B token returns 403",
)
}
func TestUpdateCoverageShowsStateTransition(t *testing.T) {
out := ansi.Strip(Tool(tool("update_coverage",
map[string]any{"entry_id": "a1b2c3", "evidence": "reproduced with a second tenant"},
map[string]any{
"success": true,
"entry_id": "a1b2c3",
"previous_outcome": "needs_follow_up",
"outcome": "reported",
},
"completed")))
requireContains(t, out, "Coverage Updated", "needs follow-up", "→", "reported")
}
func TestListCoverageRendersCountsHistoryAndAuthor(t *testing.T) {
out := ansi.Strip(Tool(tool("list_coverage", nil,
map[string]any{
"success": true,
"entries": []any{
map[string]any{
"entry_id": "a1b2c3",
"surface": "/admin/export",
"risk_area": "IDOR",
"outcome": "no_issue_found",
"agent_name": "AuthzAgent",
"previous_outcomes": []any{"needs_follow_up"},
"evidence": "org id is server-derived from the session",
},
map[string]any{
"entry_id": "d4e5f6",
"surface": "/graphql",
"risk_area": "injection",
"outcome": "needs_follow_up",
"by_you": true,
"evidence": "introspection disabled; needs an authenticated schema dump",
},
},
"total_count": 2,
"outcome_counts": map[string]any{"no_issue_found": 1, "needs_follow_up": 1},
},
"completed")))
requireContains(t, out,
"/admin/export", "IDOR", "no issue found",
"was needs follow-up", "AuthzAgent",
"/graphql", "needs follow-up", "you",
"no issue found: 1", "needs follow-up: 1",
)
}
func TestListCoverageEmptyLedgerReadsAsUnrecorded(t *testing.T) {
out := ansi.Strip(Tool(tool("list_coverage", nil,
map[string]any{"success": true, "entries": []any{}, "total_count": 0}, "completed")))
requireContains(t, out, "No surfaces recorded yet")
filtered := ansi.Strip(Tool(tool("list_coverage",
map[string]any{"outcome": "reported"},
map[string]any{"success": true, "entries": []any{}, "total_count": 4}, "completed")))
requireContains(t, filtered, "No surfaces match this filter")
}
func TestCoverageDuplicateRejectionSurfacesTheError(t *testing.T) {
out := ansi.Strip(Tool(tool("record_coverage",
map[string]any{"surface": "/login", "risk_area": "XSS"},
map[string]any{
"success": false,
"error": "'/login' (XSS) already has coverage entry a1b2c3",
"existing_entry_id": "a1b2c3",
},
"completed")))
requireContains(t, out, "/login", "already has coverage entry a1b2c3")
}
func TestGetThreatModelRendersStalenessAndAmendments(t *testing.T) {
out := ansi.Strip(Tool(tool("get_threat_model",
map[string]any{"target": "https://app.example.com"},
map[string]any{
"success": true,
"found": true,
"stale": true,
"cached_revision": "0123456789abcdef",
"content": "# Overview\nMulti-tenant billing app.\n\n" +
"## Trust Boundaries and Assumptions\n\n## Attack Surface\n",
"amendments": []any{
map[string]any{
"agent_name": "ReconAgent",
"content": "staging host shares the production database",
},
},
},
"completed")))
requireContains(t, out,
"Threat Model", "https://app.example.com",
"stale", "01234567",
"1 amendment(s)", "ReconAgent", "staging host shares the production database",
"Multi-tenant billing app.", "Overview", "Trust Boundaries and Assumptions",
)
}
func TestGetThreatModelMissingModelIsExplicit(t *testing.T) {
out := ansi.Strip(Tool(tool("get_threat_model",
map[string]any{"target": "10.0.0.5"},
map[string]any{"success": true, "found": false}, "completed")))
requireContains(t, out, "No model cached for this target yet")
}
func TestSaveThreatModelWarnsWhenAmendmentsAreCleared(t *testing.T) {
out := ansi.Strip(Tool(tool("save_threat_model",
map[string]any{"target": "app.example.com", "content": "# Overview\nA thing.\n"},
map[string]any{
"success": true,
"revision": "unversioned",
"amendments_cleared": 2,
},
"completed")))
requireContains(t, out, "Threat Model Saved", "saved", "cleared 2 amendment(s)")
// An unversioned target has no revision worth printing.
if strings.Contains(out, "unversioned") {
t.Fatalf("unversioned revision should not be rendered:\n%s", out)
}
}
func TestAmendThreatModelRendersAddendum(t *testing.T) {
out := ansi.Strip(Tool(tool("amend_threat_model",
map[string]any{
"target": "app.example.com",
"addendum": "The admin role is assignable by any org member via PATCH /members.",
},
map[string]any{"success": true, "amendment_count": 3}, "completed")))
requireContains(t, out, "Threat Model Amended", "amendment recorded", "(3 total)",
"admin role is assignable")
}
func TestCoverageAndThreatModelToolsAreNotGeneric(t *testing.T) {
// The generic fallback dumps raw arg keys; these tools must not reach it.
for _, name := range []string{
"record_coverage", "update_coverage", "list_coverage",
"get_threat_model", "save_threat_model", "amend_threat_model",
} {
out := ansi.Strip(Tool(tool(name, map[string]any{"target": "x", "surface": "y"}, nil, "running")))
if strings.Contains(out, "Using tool") {
t.Fatalf("%s fell through to the generic renderer:\n%s", name, out)
}
}
}
func TestOutputHeavyCoverageToolsCollapse(t *testing.T) {
for _, name := range []string{"list_coverage", "get_threat_model"} {
if ToolPreviewLines(name) == 0 {
t.Fatalf("%s should collapse; its output is unbounded", name)
}
}
for _, name := range []string{"record_coverage", "amend_threat_model"} {
if ToolPreviewLines(name) != 0 {
t.Fatalf("%s should not collapse", name)
}
}
}
func TestVulnerabilityReportRendersCalibrationFields(t *testing.T) {
out := ansi.Strip(Tool(tool("create_vulnerability_report",
map[string]any{
"title": "IDOR in invoice export",
"confidence": "medium",
"confidence_rationale": "traced statically; no authenticated instance to replay against",
"counterevidence": "the gateway may strip the id parameter before it reaches the handler",
"severity_change_conditions": "critical if the export includes other tenants' bank details",
"fix_verification": "unit tests executed; bypass review reasoned only",
"description": "The handler trusts a client-supplied invoice id.",
},
map[string]any{"success": true, "severity": "high", "cvss_score": 7.5},
"completed")))
requireContains(t, out,
"Confidence", "MEDIUM", "no authenticated instance to replay against",
"Counterevidence", "gateway may strip the id parameter",
"Severity Would Change If", "other tenants' bank details",
"Fix Verification", "bypass review reasoned only",
)
}
@@ -82,6 +82,10 @@ func Tool(data map[string]any) string {
return renderNote(name, args, result)
case "create_todo", "list_todos", "update_todo", "mark_todo_done", "mark_todo_pending", "delete_todo":
return renderTodo(name, result)
case "record_coverage", "update_coverage", "list_coverage":
return renderCoverage(name, args, result)
case "get_threat_model", "save_threat_model", "amend_threat_model":
return renderThreatModel(name, args, result)
case "view_agent_graph", "create_agent", "send_message_to_agent", "agent_finish", "wait_for_agents", "stop_agent":
return renderAgentGraphTool(name, args, result)
case "list_requests", "view_request", "repeat_request", "list_sitemap", "view_sitemap_entry", "scope_rules":
@@ -103,7 +107,8 @@ const outputPreviewLines = 10
func ToolPreviewLines(name string) int {
switch name {
case "exec_command", "write_stdin", "apply_patch",
"view_request", "repeat_request", "view_sitemap_entry":
"view_request", "repeat_request", "view_sitemap_entry",
"list_coverage", "get_threat_model":
return outputPreviewLines
}
return 0
@@ -50,15 +50,31 @@ func renderVulnerabilityReport(args map[string]any, result any) string {
b.WriteString("\n\n" + Bold(Field).Render(label) + "\n" + value)
}
}
if confidence := StringValue(args["confidence"]); confidence != "" {
b.WriteString("\n\n" + Bold(Field).Render("Confidence: ") +
lipgloss.NewStyle().Bold(true).Foreground(confidenceColor(confidence)).
Render(strings.ToUpper(confidence)))
if rationale := StringValue(args["confidence_rationale"]); rationale != "" {
b.WriteString("\n" + Dim().Render(rationale))
}
}
section("Description", StringValue(args["description"]))
section("Impact", StringValue(args["impact"]))
section("Technical Analysis", StringValue(args["technical_analysis"]))
// The case against the finding travels with the case for it: a reader
// triaging this needs both to judge whether to act.
section("Counterevidence", StringValue(args["counterevidence"]))
section("Severity Would Change If", StringValue(args["severity_change_conditions"]))
renderCodeLocations(&b, args["code_locations"])
section("PoC Description", StringValue(args["poc_description"]))
if poc := StringValue(args["poc_script_code"]); poc != "" {
b.WriteString("\n\n" + Bold(Field).Render("PoC Code") + "\n" + Col(Text).Render(poc))
}
section("Remediation", StringValue(args["remediation_steps"]))
// Any applyable fix above is one click from the user's codebase, so how it
// was verified belongs next to it rather than in the artifact alone.
section("Fix Verification", StringValue(args["fix_verification"]))
if title == "" {
b.WriteString("\n " + Dim().Render("Creating report..."))
@@ -66,6 +82,20 @@ func renderVulnerabilityReport(args map[string]any, result any) string {
return "\n\n" + b.String() + "\n\n"
}
// confidenceColor grades how firm the agent's own call is. Anything below
// high is a claim the reader has to check, and should not read as settled.
func confidenceColor(confidence string) lipgloss.Color {
switch strings.ToLower(strings.TrimSpace(confidence)) {
case "high":
return Green
case "medium":
return SevMed
case "low":
return SevHigh
}
return Gray
}
var cvssKeys = [][2]string{
{"attack_vector", "AV"}, {"attack_complexity", "AC"}, {"privileges_required", "PR"},
{"user_interaction", "UI"}, {"scope", "S"}, {"confidentiality", "C"},
@@ -0,0 +1,138 @@
package render
import (
"strconv"
"strings"
)
// ---------------------------------------------------------------------------
// Threat model (get_threat_model / save_threat_model / amend_threat_model)
// ---------------------------------------------------------------------------
var threatModelTitles = map[string]struct {
title string
loading string
errMsg string
}{
"get_threat_model": {"Threat Model", "Loading...", "Unable to read threat model"},
"save_threat_model": {"Threat Model Saved", "Saving...", "Failed to save threat model"},
"amend_threat_model": {"Threat Model Amended", "Amending...", "Failed to amend threat model"},
}
func renderThreatModel(name string, args map[string]any, result any) string {
meta := threatModelTitles[name]
var b strings.Builder
b.WriteString("⌖ " + Bold(InfoBlue).Render(meta.title))
if target := strings.TrimSpace(StringValue(args["target"])); target != "" {
b.WriteString(Dim().Render(" " + target))
}
if s, ok := result.(string); ok && strings.TrimSpace(s) != "" {
b.WriteString("\n " + Dim().Render(strings.TrimSpace(s)))
return b.String()
}
m, ok := result.(map[string]any)
if !ok {
b.WriteString("\n " + Dim().Render(meta.loading))
return b.String()
}
if !truthy(m["success"]) {
errMsg := StringValue(m["error"])
if errMsg == "" {
errMsg = meta.errMsg
}
b.WriteString("\n " + Col(Red).Render(errMsg))
return b.String()
}
switch name {
case "get_threat_model":
threatModelReadBody(&b, m)
case "amend_threat_model":
b.WriteString("\n " + Col(Green).Render("✓ amendment recorded"))
if count, ok := NumericValue(m["amendment_count"]); ok {
b.WriteString(Dim().Render(" (" + strconv.Itoa(int(count)) + " total)"))
}
threatModelBody(&b, StringValue(args["addendum"]))
default:
b.WriteString("\n " + Col(Green).Render("✓ saved"))
if revision := shortRevision(StringValue(m["revision"])); revision != "" {
b.WriteString(Dim().Render(" at " + revision))
}
// Saving folds amendments away, so the count that vanished is worth
// stating: it is the one destructive thing this tool does.
if cleared, ok := NumericValue(m["amendments_cleared"]); ok && cleared > 0 {
b.WriteString("\n " + Col(AmberY).Render("⚠ cleared "+
strconv.Itoa(int(cleared))+" amendment(s)"))
}
threatModelBody(&b, StringValue(args["content"]))
}
return b.String()
}
func threatModelReadBody(b *strings.Builder, result map[string]any) {
if !truthy(result["found"]) {
b.WriteString("\n " + Dim().Render("No model cached for this target yet"))
return
}
if truthy(result["stale"]) {
b.WriteString("\n " + Col(AmberY).Render("⚠ stale"))
if cached := shortRevision(StringValue(result["cached_revision"])); cached != "" {
b.WriteString(Dim().Render(" (written at " + cached + ")"))
}
}
if amendments, ok := result["amendments"].([]any); ok && len(amendments) > 0 {
b.WriteString("\n " + Col(Gold).Render("+ "+strconv.Itoa(len(amendments))+
" amendment(s)") + Dim().Render(" — later statements win"))
for _, a := range amendments {
amendment, _ := a.(map[string]any)
who := strings.TrimSpace(StringValue(amendment["agent_name"]))
if who == "" {
who = "unknown agent"
}
b.WriteString("\n - " + Dim().Render(who+": ") +
psanitize(strings.TrimSpace(StringValue(amendment["content"])), 120))
}
}
threatModelBody(b, StringValue(result["content"]))
}
// threatModelBody previews the document. The full text is a page or more, so
// only its section headings and opening line are shown here; the trace can be
// expanded for the rest.
func threatModelBody(b *strings.Builder, content string) {
content = strings.TrimSpace(content)
if content == "" {
return
}
var headings []string
summary := ""
for _, line := range strings.Split(content, "\n") {
line = strings.TrimSpace(line)
switch {
case strings.HasPrefix(line, "#"):
headings = append(headings, strings.TrimSpace(strings.TrimLeft(line, "# ")))
case summary == "" && line != "":
summary = line
}
}
if summary != "" {
b.WriteString("\n " + Dim().Render(psanitize(summary, 160)))
}
if len(headings) > 0 {
if len(headings) > 8 {
headings = headings[:8]
}
b.WriteString("\n " + Dim().Render(strings.Join(headings, " · ")))
}
}
// shortRevision abbreviates a git sha; "unversioned" targets have no revision
// worth showing.
func shortRevision(revision string) string {
revision = strings.TrimSpace(revision)
if revision == "" || revision == "unversioned" {
return ""
}
return firstN(revision, 8)
}
@@ -0,0 +1,184 @@
"use client";
import type { ToolRendererProps } from "@/types/events";
import { CheckCircle2, CircleSlash, HelpCircle, AlertTriangle, Circle, ClipboardList } from "lucide-react";
interface CoverageEntry {
entry_id?: string;
surface?: string;
risk_area?: string;
outcome?: string;
evidence?: string;
agent_name?: string;
by_you?: boolean;
previous_outcomes?: string[];
}
/**
* A cleared surface and an unresolved one must never read alike — the ledger
* exists so that the negative space of a scan is legible, so each outcome gets
* its own icon and color rather than a shared neutral row.
*/
const OUTCOMES: Record<string, { label: string; color: string; Icon: typeof Circle }> = {
reported: { label: "reported", color: "text-orange-400", Icon: AlertTriangle },
no_issue_found: { label: "no issue found", color: "text-emerald-400", Icon: CheckCircle2 },
ruled_out: { label: "ruled out", color: "text-emerald-400/70", Icon: CheckCircle2 },
not_applicable: { label: "not applicable", color: "text-[#777]", Icon: CircleSlash },
needs_follow_up: { label: "needs follow-up", color: "text-yellow-400", Icon: HelpCircle },
};
const OUTCOME_ORDER = [
"reported", "needs_follow_up", "no_issue_found", "ruled_out", "not_applicable",
] as const;
function outcomeMeta(outcome: string | undefined) {
const key = (outcome ?? "").trim().toLowerCase();
return OUTCOMES[key] ?? {
label: key ? key.replace(/_/g, " ") : "unrecorded",
color: "text-[#777]",
Icon: Circle,
};
}
const ACTION_LABELS: Record<string, string> = {
record_coverage: "Coverage recorded",
update_coverage: "Coverage updated",
list_coverage: "Coverage",
};
function Header({ toolName }: { toolName: string }) {
return (
<div className="flex items-center gap-2">
<ClipboardList className="w-3.5 h-3.5 text-cyan-400/60" />
<span className="text-cyan-400/80 font-semibold text-sm">
{ACTION_LABELS[toolName] ?? "Coverage"}
</span>
</div>
);
}
function Row({ entry }: { entry: CoverageEntry }) {
const { label, color, Icon } = outcomeMeta(entry.outcome);
const previous = (entry.previous_outcomes ?? [])
.map((o) => outcomeMeta(o).label)
.filter(Boolean);
return (
<div className="flex items-start gap-2.5 py-1.5">
<Icon className={`w-3.5 h-3.5 shrink-0 mt-[2px] ${color}`} />
<div className="min-w-0">
<div className="text-[13px] leading-snug">
<span className="text-[#bbb]">{entry.surface ?? "(unnamed surface)"}</span>
{entry.risk_area && <span className="text-[#666]"> · {entry.risk_area}</span>}
</div>
<div className="text-xs mt-0.5">
<span className={color}>{label}</span>
{previous.length > 0 && (
<span className="text-[#555]"> (was {previous.join(" → ")})</span>
)}
{(entry.by_you || entry.agent_name) && (
<span className="text-[#555]"> · {entry.by_you ? "you" : entry.agent_name}</span>
)}
</div>
{entry.evidence && (
<div className="text-[#777] text-xs mt-1 leading-snug">{entry.evidence}</div>
)}
</div>
</div>
);
}
export default function CoverageRenderer({ toolName, args, result }: ToolRendererProps) {
const res = result as Record<string, unknown> | string | null;
if (typeof res === "string" && res.trim()) {
return (
<div>
<Header toolName={toolName} />
<div className="mt-1.5 text-[#888] text-[13px]">{res.trim()}</div>
</div>
);
}
const structured = res && typeof res === "object" ? res : null;
const surface = (args.surface as string) ?? "";
const riskArea = (args.risk_area as string) ?? "";
const evidence = (args.evidence as string) ?? "";
if (structured && !structured.success) {
return (
<div>
<Header toolName={toolName} />
{(surface || riskArea) && (
<div className="mt-1.5 text-[13px] text-[#bbb]">
{surface}
{riskArea && <span className="text-[#666]"> · {riskArea}</span>}
</div>
)}
<div className="mt-1 text-red-400/70 text-[13px]">
{(structured.error as string) ?? "Coverage call failed"}
</div>
</div>
);
}
if (toolName === "list_coverage") {
const rawEntries = structured?.entries;
const entries: CoverageEntry[] = Array.isArray(rawEntries) ? (rawEntries as CoverageEntry[]) : [];
const counts = (structured?.outcome_counts as Record<string, number> | undefined) ?? {};
const total = (structured?.total_count as number) ?? 0;
return (
<div>
<Header toolName={toolName} />
{Object.keys(counts).length > 0 && (
<div className="mt-2 flex items-center gap-3 flex-wrap">
{OUTCOME_ORDER.filter((o) => counts[o]).map((o) => {
const { label, color } = outcomeMeta(o);
return (
<span key={o} className={`text-xs ${color}`}>
{label}: {counts[o]}
</span>
);
})}
</div>
)}
{entries.length > 0 ? (
<div className="mt-2 rounded-lg border border-white/[0.06] bg-white/[0.015] px-3 py-1 divide-y divide-white/[0.04]">
{entries.map((entry, i) => <Row key={entry.entry_id ?? i} entry={entry} />)}
</div>
) : (
<div className="mt-1.5 text-[#555] text-xs">
{total === 0 ? "No surfaces recorded yet" : "No surfaces match this filter"}
</div>
)}
</div>
);
}
const outcome = (structured?.outcome as string) ?? "";
const previousOutcome = (structured?.previous_outcome as string) ?? "";
const { label, color, Icon } = outcomeMeta(outcome);
return (
<div>
<Header toolName={toolName} />
<div className="mt-2 flex items-start gap-2.5">
<Icon className={`w-3.5 h-3.5 shrink-0 mt-[2px] ${color}`} />
<div className="min-w-0">
<div className="text-[13px] leading-snug text-[#bbb]">
{surface || (structured?.entry_id ? `entry ${structured.entry_id as string}` : "(unnamed surface)")}
{riskArea && <span className="text-[#666]"> · {riskArea}</span>}
</div>
<div className="text-xs mt-0.5">
{previousOutcome && (
<span className="text-[#666]">{outcomeMeta(previousOutcome).label} </span>
)}
<span className={color}>{label}</span>
</div>
{evidence && (
<div className="text-[#777] text-xs mt-1 leading-snug">{evidence}</div>
)}
</div>
</div>
</div>
);
}
@@ -0,0 +1,134 @@
"use client";
import type { ToolRendererProps } from "@/types/events";
import { Crosshair, AlertTriangle, Plus, Save } from "lucide-react";
import { TruncatedText } from "./ToolCard";
interface Amendment {
agent_name?: string;
content?: string;
recorded_at?: string;
}
const ACTION_LABELS: Record<string, { label: string; Icon: typeof Crosshair }> = {
get_threat_model: { label: "Threat model", Icon: Crosshair },
save_threat_model: { label: "Threat model saved", Icon: Save },
amend_threat_model: { label: "Threat model amended", Icon: Plus },
};
/** A git sha is noise past its first bytes, and "unversioned" is not a revision. */
function shortRevision(revision: unknown): string {
const value = typeof revision === "string" ? revision.trim() : "";
if (!value || value === "unversioned") return "";
return value.slice(0, 8);
}
export default function ThreatModelRenderer({ toolName, args, result }: ToolRendererProps) {
const action = ACTION_LABELS[toolName] ?? { label: "Threat model", Icon: Crosshair };
const ActionIcon = action.Icon;
const target = (args.target as string) ?? "";
const res = result as Record<string, unknown> | string | null;
const header = (
<div className="flex items-center gap-2 flex-wrap">
<ActionIcon className="w-3.5 h-3.5 text-blue-400/60" />
<span className="text-blue-400/80 font-semibold text-sm">{action.label}</span>
{target && <span className="text-[#666] font-mono text-xs">{target}</span>}
</div>
);
if (typeof res === "string" && res.trim()) {
return <div>{header}<div className="mt-1.5 text-[#888] text-[13px]">{res.trim()}</div></div>;
}
const structured = res && typeof res === "object" ? res : null;
if (structured && !structured.success) {
return (
<div>
{header}
<div className="mt-1.5 text-red-400/70 text-[13px]">
{(structured.error as string) ?? "Threat model call failed"}
</div>
</div>
);
}
if (toolName === "get_threat_model") {
if (structured && !structured.found) {
return (
<div>
{header}
<div className="mt-1.5 text-[#555] text-xs">No model cached for this target yet</div>
</div>
);
}
const rawAmendments = structured?.amendments;
const amendments: Amendment[] = Array.isArray(rawAmendments) ? (rawAmendments as Amendment[]) : [];
const cachedRevision = shortRevision(structured?.cached_revision);
return (
<div>
{header}
{structured?.stale === true && (
<div className="mt-1.5 flex items-center gap-1.5 text-yellow-400/80 text-xs">
<AlertTriangle className="w-3 h-3 shrink-0" />
<span>stale{cachedRevision ? ` — written at ${cachedRevision}` : ""}</span>
</div>
)}
{amendments.length > 0 && (
<div className="mt-2">
<span className="text-amber-400/70 text-xs font-semibold">
{amendments.length} amendment{amendments.length === 1 ? "" : "s"}
</span>
<span className="text-[#555] text-xs"> later statements win</span>
<div className="mt-1 space-y-1">
{amendments.map((amendment, i) => (
<div key={i} className="text-xs leading-snug">
<span className="text-[#666]">{amendment.agent_name ?? "unknown agent"}: </span>
<span className="text-[#999]">{amendment.content ?? ""}</span>
</div>
))}
</div>
</div>
)}
{typeof structured?.content === "string" && structured.content.trim() && (
<div className="mt-2">
<TruncatedText text={structured.content} maxLines={14} />
</div>
)}
</div>
);
}
if (toolName === "amend_threat_model") {
const addendum = (args.addendum as string) ?? "";
const count = structured?.amendment_count as number | undefined;
return (
<div>
{header}
{count != null && (
<div className="mt-1.5 text-[#666] text-xs">{count} amendment{count === 1 ? "" : "s"} on this model</div>
)}
{addendum && <div className="mt-1.5"><TruncatedText text={addendum} maxLines={10} /></div>}
</div>
);
}
const cleared = (structured?.amendments_cleared as number | undefined) ?? 0;
const revision = shortRevision(structured?.revision);
const content = (args.content as string) ?? "";
return (
<div>
{header}
{revision && <div className="mt-1.5 text-[#666] font-mono text-xs">at {revision}</div>}
{/* Saving folds amendments away — the one destructive thing this tool does. */}
{cleared > 0 && (
<div className="mt-1.5 flex items-center gap-1.5 text-yellow-400/80 text-xs">
<AlertTriangle className="w-3 h-3 shrink-0" />
<span>cleared {cleared} amendment{cleared === 1 ? "" : "s"}</span>
</div>
)}
{content && <div className="mt-2"><TruncatedText text={content} maxLines={14} /></div>}
</div>
);
}
@@ -11,6 +11,11 @@ const SEVERITY_COLORS: Record<string, string> = {
low: "text-blue-400", info: "text-cyan-400",
};
/** Anything below high is a claim the reader still has to check. */
const CONFIDENCE_COLORS: Record<string, string> = {
high: "text-emerald-400", medium: "text-yellow-400", low: "text-orange-400",
};
export default function VulnReportRenderer({ args, result }: ToolRendererProps) {
const title = (args.title as string) ?? "";
const description = (args.description as string) ?? "";
@@ -24,6 +29,11 @@ export default function VulnReportRenderer({ args, result }: ToolRendererProps)
const remediation = (args.remediation_steps as string) ?? "";
const cve = (args.cve as string) ?? "";
const cwe = (args.cwe as string) ?? "";
const counterevidence = (args.counterevidence as string) ?? "";
const confidence = ((args.confidence as string) ?? "").toLowerCase();
const confidenceRationale = (args.confidence_rationale as string) ?? "";
const severityChangeConditions = (args.severity_change_conditions as string) ?? "";
const fixVerification = (args.fix_verification as string) ?? "";
const res = result as Record<string, unknown> | null;
const rawSev = (res && typeof res === "object" ? res.severity : null) ?? args.severity ?? "medium";
@@ -38,6 +48,11 @@ export default function VulnReportRenderer({ args, result }: ToolRendererProps)
{cvss != null && <span className="text-[#888] text-[13px]">CVSS {cvss}</span>}
{cve && <span className="text-[#888] font-mono text-[13px]">{cve}</span>}
{cwe && <span className="text-[#888] font-mono text-[13px]">{cwe}</span>}
{confidence && (
<span className={`text-[13px] ${CONFIDENCE_COLORS[confidence] ?? "text-[#888]"}`}>
{confidence} confidence
</span>
)}
</div>
{title && <div className="text-[15px] text-white/80 font-semibold">{title}</div>}
{(target || endpoint) && (
@@ -56,6 +71,23 @@ export default function VulnReportRenderer({ args, result }: ToolRendererProps)
<div className="mt-1"><TruncatedText text={technicalAnalysis} maxLines={20} /></div>
</div>
)}
{confidenceRationale && (
<div className="text-[#777] text-xs leading-snug">{confidenceRationale}</div>
)}
{/* The case against the finding sits beside the case for it: whoever
triages this needs both to decide whether to act. */}
{counterevidence && (
<div>
<span className="text-emerald-400/60 text-sm font-semibold">Counterevidence</span>
<div className="mt-1"><TruncatedText text={counterevidence} maxLines={12} /></div>
</div>
)}
{severityChangeConditions && (
<div>
<span className="text-emerald-400/60 text-sm font-semibold">Severity would change if</span>
<div className="mt-1"><TruncatedText text={severityChangeConditions} maxLines={10} /></div>
</div>
)}
{(pocDescription || pocCode) && (
<div>
<span className="text-emerald-400/60 text-sm font-semibold">Proof of Concept</span>
@@ -69,6 +101,14 @@ export default function VulnReportRenderer({ args, result }: ToolRendererProps)
<div className="mt-1"><TruncatedText text={remediation} maxLines={15} /></div>
</div>
)}
{/* An applyable fix is one click from the user's codebase, so how it was
verified belongs next to it. */}
{fixVerification && (
<div>
<span className="text-emerald-400/60 text-sm font-semibold">Fix verification</span>
<div className="mt-1"><TruncatedText text={fixVerification} maxLines={12} /></div>
</div>
)}
</div>
);
}
@@ -3,7 +3,7 @@ import type { ToolRendererProps } from "@/types/events";
import {
Terminal, Globe, FileText, ShieldAlert, ArrowUpRight, Brain,
Bot, MessageCircle, Flag, Eye, Search, Code, StickyNote,
ListTodo, Crosshair, Wrench, Ban, Image,
ListTodo, Crosshair, Wrench, Ban, Image, ClipboardList,
} from "lucide-react";
import TerminalRenderer from "./TerminalRenderer";
@@ -25,6 +25,8 @@ import TodoRenderer from "./TodoRenderer";
import FallbackRenderer from "./FallbackRenderer";
import LoadSkillRenderer from "./LoadSkillRenderer";
import RespondRenderer from "./RespondRenderer";
import CoverageRenderer from "./CoverageRenderer";
import ThreatModelRenderer from "./ThreatModelRenderer";
/**
* Tool-renderer mapping — data-driven, keyed by the engine's tool *family*.
@@ -53,6 +55,8 @@ export type ToolCategory =
| "notes"
| "skills"
| "todos"
| "coverage"
| "threatModel"
| "telemetry";
export interface ToolIconMeta {
@@ -83,6 +87,8 @@ const CATEGORY_META: Record<ToolCategory, CategoryMeta> = {
notes: { renderer: NotesRenderer, icon: StickyNote, color: "text-amber-400", match: /note/ },
skills: { renderer: LoadSkillRenderer, icon: Wrench, color: "text-emerald-400" },
todos: { renderer: TodoRenderer, icon: ListTodo, color: "text-purple-400", match: /todo/ },
coverage: { renderer: CoverageRenderer, icon: ClipboardList, color: "text-cyan-400", match: /coverage/ },
threatModel: { renderer: ThreatModelRenderer, icon: Crosshair, color: "text-blue-400", match: /threat_model/ },
telemetry: { renderer: FallbackRenderer, icon: Wrench, color: "text-[#555]" },
};
@@ -112,6 +118,10 @@ const CATEGORY_TOOLS: Record<ToolCategory, readonly string[]> = {
notes: ["create_note", "delete_note", "update_note", "list_notes", "get_note"],
skills: ["load_skill"],
todos: ["create_todo", "list_todos", "update_todo", "mark_todo_done", "mark_todo_pending", "delete_todo"],
// Shared coverage ledger — one row per surface × risk area for the whole run
coverage: ["record_coverage", "update_coverage", "list_coverage"],
// Per-target threat model, shared across the agent tree
threatModel: ["get_threat_model", "save_threat_model", "amend_threat_model"],
telemetry: ["sandbox_error_details", "llm_error_details"],
};
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -6,8 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="color-scheme" content="dark" />
<title>Strix Results</title>
<script type="module" crossorigin src="./assets/index-DBJ-RJqo.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-DKbLYAbP.css">
<script type="module" crossorigin src="./assets/index-CMo1eUt4.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-g-_6CcwH.css">
</head>
<body>
<div id="root"></div>