import type { MessagePartRenderers } from '../../src/types'; // In a host app, import the type from '@mordn/chat-widget' instead. interface AccountLookupResult { name: string; accountId: string; plan: string; } function isAccountLookupResult(value: unknown): value is AccountLookupResult { if (!value || typeof value !== 'object') return false; const data = value as Record; return typeof data.name === 'string' && typeof data.accountId === 'string' && typeof data.plan === 'string'; } /** Display-only snapshot. This card does not grant access or execute actions. */ function AccountLookupCard({ account, streaming }: { account: AccountLookupResult; streaming: boolean }) { return (
{account.name}
Account
{account.accountId}
Plan
{account.plan}
); } // Stable module-level map: no new renderer identities on every streaming tick. export const accountLookupRenderers = { 'data-account-lookup': (part, context) => { // Role is presentation context, NOT proof of an authorized server result. if (context.role !== 'assistant' || !isAccountLookupResult(part.data)) return null; return ; }, } satisfies MessagePartRenderers;