import { type ServicePageModel, type ServicePageOffering, type ServicePageOperation, } from '@lucid-agents/http'; import { createServiceUiStyleSheet, resolveServiceUi, } from '@lucid-agents/http/service-ui'; import type { ServiceUiConfig } from '@lucid-agents/types/http'; export type ServiceStorefrontProps = { service: ServicePageModel; serviceUi?: ServiceUiConfig; }; type EndpointRow = { key: string; title: string; description: string; operation: ServicePageOperation; paymentMethod: string; paymentNetwork?: string; }; function endpointRows(offerings: ServicePageOffering[]): EndpointRow[] { return offerings.flatMap(offering => { const operationRow = ( kind: 'invoke' | 'stream', operation: ServicePageOperation ): EndpointRow => ({ key: `${offering.key}-${kind}`, title: `${offering.title}${kind === 'stream' ? ' stream' : ''}`, description: offering.description, operation, paymentMethod: operation.price ? (offering.payment.protocol ?? 'Required') : 'None', ...(operation.price && offering.payment.network ? { paymentNetwork: offering.payment.network } : {}), }); return [ operationRow('invoke', offering.operations.invoke), ...(offering.operations.stream ? [operationRow('stream', offering.operations.stream)] : []), ]; }); } export function ServiceStorefront({ service, serviceUi, }: ServiceStorefrontProps) { const resolvedUi = resolveServiceUi(serviceUi); const styleSheet = createServiceUiStyleSheet(resolvedUi); const rows = endpointRows(service.offerings); const description = service.agent.description ?? 'This agent has not published a description yet.'; return ( <> {resolvedUi.tokens.fonts.stylesheetUrl ? ( ) : null}

{service.agent.name}

{description}

Endpoints

{rows.length} {rows.length === 1 ? 'endpoint' : 'endpoints'}
{rows.length > 0 ? (
{rows.map(row => ( ))}
Endpoint Payment method Price
{row.title}
{row.operation.method} {row.operation.path}
{row.description}
{row.paymentMethod} {row.paymentNetwork ? ( {row.paymentNetwork} ) : null} {row.operation.price ?? 'Free'}
) : (
No endpoints published

Endpoints will appear here when the service registers them.

)}
); }