"use client"; import { useI18n } from "@/components/i18n"; import { DispatchCard } from "@/components/artifacts/dispatch-card"; import { MessageResponse } from "@/components/ai-elements/message"; import type { ArtifactPartProps, PdfResult, ResearchResult } from "@/src/core"; /** * The research tool-call box (contracts.ts "THE ASYNC PROTOCOL" §4). * * The part's output is the fire-and-forget dispatch ACK — the box itself is * the DispatchCard (live status via the chat view's jobs feed; quiet one-liner * once delivered). The research brief itself no longer renders from the * tool part at all: it rides the steer message (the user-role delivery * injected after the wake turn) and renders there via ResearchBriefCard. */ export function JobCard({ part }: ArtifactPartProps) { if (part.state !== "output-available") return null; return ; } /** * The pdf dispatch box (sources v0) — the same async-protocol idiom as * JobCard: the ack output drives a DispatchCard (live "PDF reader" status * via the chat view's jobs feed); the brief itself rides the steer message * and renders under the PDF-complete badge in the transcript. */ export function PdfJobCard({ part }: ArtifactPartProps) { if (part.state !== "output-available") return null; return ; } /** * The PDF reading brief (sources v0) — markdown body + the consulted-pages * line. Exported: the steer card renders it under the PDF-complete badge, * the same expand-on-demand idiom as research. */ export function PdfBriefCard({ output }: { output: unknown }) { const { t } = useI18n(); const result = output as PdfResult | undefined; if (!result || typeof result.brief !== "string") { return (
{t("PDF reading completed, but the result could not be displayed.")}
); } const failed = result.brief.startsWith(t("PDF failed")); // Read = extract/render output entered the loop; consulted = every page // incl. search hits (the full audit set — the brief's citations may point // there). The ?? fallbacks tolerate pre-split persisted records. const readList = result.pagesRead ?? result.pagesConsulted ?? []; const consultedList = result.pagesConsulted ?? []; return (
{t("PDF brief")}{failed && {t("failed")}}
{result.brief}
{!failed && readList.length > 0 && (
{t("Pages read:")}{" "}{readList.join(", ")}
)} {!failed && consultedList.length > readList.length && (
{t("Pages consulted:")}{" "}{consultedList.join(", ")}
)}
); } /** * The research brief — markdown body + a small source link list. Exported: * the steer card (sub-agent result delivery) renders the same artifact. */ export function ResearchBriefCard({ output }: { output: unknown }) { const { t } = useI18n(); const result = output as ResearchResult | undefined; if (!result || typeof result.brief !== "string") { return (
{t("Research completed, but the result could not be displayed.")}
); } const failed = result.brief.startsWith(t("Research failed")); return (
{t("Research brief")}{failed && {t("failed")}}
{result.brief}
{result.sources.length > 0 && (
{t("Sources")}
)}
); }