"use client"; 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 central jobs poll; 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 central jobs poll); 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 result = output as PdfResult | undefined; if (!result || typeof result.brief !== "string") { return (
PDF reading completed, but the result could not be displayed.
); } const failed = result.brief.startsWith("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 (
PDF brief {failed && failed}
{result.brief}
{!failed && readList.length > 0 && (
Pages read: {readList.join(", ")}
)} {!failed && consultedList.length > readList.length && (
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 result = output as ResearchResult | undefined; if (!result || typeof result.brief !== "string") { return (
Research completed, but the result could not be displayed.
); } const failed = result.brief.startsWith("Research failed"); return (
Research brief {failed && failed}
{result.brief}
{result.sources.length > 0 && (
Sources
)}
); }