import { ChevronRight, ExternalLink } from "lucide-react"; import type { InspectorDetailProjection, RetrievalActivity, RetrievalOutcome, RetrievalResultItem, } from "@/lib/types"; import { RichText } from "@/components/ui/RichText"; import { ValueView } from "@/components/ui/ValueView"; const STATE_LABELS: Record = { hit: "查询命中", empty: "查询成功 · 无匹配", failure: "查询失败", running: "查询中", interrupted: "构建中断", unknown: "状态未知", success: "已完成", }; export function RetrievalDetailRenderer({ projection, onNavigate, }: { projection: InspectorDetailProjection; onNavigate?: (activity: RetrievalActivity) => void; }) { if (projection.detailKind === "retrieval-event") { return ; } return ; } function RetrievalActivityGroup({ projection, onNavigate, }: { projection: InspectorDetailProjection; onNavigate?: (activity: RetrievalActivity) => void; }) { const activities = projection.activities || []; return
{(projection.businessSections || []).map((section) =>

{section.title}

{section.content ? : null}
)}

{projection.retrievalKind === "direct-tools" ? "每次工具调用" : "查询记录"}

{activities.length} 次
{activities.length ?
    {activities.map((activity, index) =>
  1. )}
:

{projection.missingActivityNotice || "本次运行没有保存可下钻的结构化查询记录。"}

}
; } function RetrievalEvent({ projection }: { projection: InspectorDetailProjection }) { const outcome = projection.outcome || { state: "unknown", message: "现有记录不足以可靠判断查询结果。" }; const conditions = projection.queryConditions || []; const items = projection.items || []; const completeness = projection.completeness; return

{projection.sourceKind === "direct-tool" ? "调用输入" : "查询条件"}

{conditions.length ?
{conditions.map((condition) =>
{condition.label}
)}
:

本次调用没有保存额外输入条件。

}
{items.length ?

{projection.sourceKind === "direct-tool" ? "读取结果" : "返回结果"}

{items.length} 项
{items.map((item, index) => )}
: null} {!completeness?.bodyAvailable ?

仅保存了摘要,完整返回不可用。

: null} {completeness?.truncated ?

返回内容超过安全展示上限,已省略 {completeness.omittedCharacters || "部分"} 个字符。

: null}
; } function OutcomePanel({ outcome }: { outcome: RetrievalOutcome }) { return
{STATE_LABELS[outcome.state] || "查询状态"} {outcome.message}
; } function ResultDisclosure({ item, defaultOpen }: { item: RetrievalResultItem; defaultOpen: boolean }) { const safeHref = typeof item.href === "string" && /^https?:\/\//i.test(item.href) ? item.href : undefined; return
{item.title}{item.subtitle ? {item.subtitle} : null} {item.meta?.length ? {item.meta.map((entry) => {entry.label}:{scalarText(entry.value)})} : null}
{safeHref ? 查看原始内容 : null} {item.sections.map((section, index) =>

{section.title}

)}
; } function StructuredValue({ value }: { value: unknown }) { if (typeof value === "string") return ; if (value == null) return 未记录; return ; } function scalarText(value: unknown) { if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return String(value); return "已记录"; }