[] =
response && Array.isArray(response.sources) ? response.sources.filter(isRecord) : [];
let providerInfo = model && provider ? `${model} @ ${provider}` : (model ?? provider ?? "");
if (providerInfo && authMode) {
providerInfo += ` (${authMode === "oauth" ? "OAuth" : authMode === "api_key" ? "API" : authMode})`;
}
const usage = response && isRecord(response.usage) ? response.usage : null;
const usageParts: string[] = [];
if (usage) {
const inTok = num(usage.inputTokens);
const outTok = num(usage.outputTokens);
const totalTok = num(usage.totalTokens);
const searchReqs = num(usage.searchRequests);
if (inTok !== null) usageParts.push(`in ${inTok}`);
if (outTok !== null) usageParts.push(`out ${outTok}`);
if (totalTok !== null) usageParts.push(`total ${totalTok}`);
if (searchReqs !== null) usageParts.push(`search ${searchReqs}`);
}
return (
<>
{(query !== null || providerInfo || usageParts.length > 0) && (
{query !== null && {query}}
{providerInfo && {providerInfo}}
{usageParts.length > 0 && {usageParts.join(" · ")}}
)}
{errorMsg && !resultTextOf(result) && {errorMsg}}
{sources.length > 0 && (
{sources.map((source, i) => (
))}
)}
>
);
}
export const webSearchRenderer: ToolRenderer = { Summary, Body };