Supyagent
SDK (Node.js)

React Components

UI components for rendering tool calls, results, provider icons, and context state from @supyagent/sdk/react.

React Components

The @supyagent/sdk/react sub-package provides React components and utilities for building chat UIs that display Supyagent tool calls and results with rich formatting.

import {
  ProviderIcon,
  ToolInput,
  ContextIndicator,
  SummaryMessage,
  isContextSummary,
  getSummary,
  humanizeToolName,
  getProviderFromToolName,
  getProviderLabel,
  getFormatterType,
  resolveToolName,
  PROVIDER_LABELS,
} from '@supyagent/sdk/react';

Peer Dependencies

The React components require react, react-dom, and lucide-react:

npm install react react-dom lucide-react

Components

ProviderIcon

Renders a Lucide icon for a tool based on its name. Maps tool name prefixes (e.g., gmail_, slack_, calendar_) to appropriate icons.

<ProviderIcon toolName="gmail_list_messages" className="h-4 w-4" />
// → Renders a Mail icon

<ProviderIcon toolName="slack_send_message" />
// → Renders a MessageSquare icon

<ProviderIcon toolName="unknown_tool" />
// → Renders a fallback Wrench icon
PropTypeDefaultDescription
toolNamestringThe tool name (e.g., gmail_list_messages)
classNamestring"h-4 w-4"CSS classes for the icon

ToolInput

Renders tool call arguments as a two-column grid (key → value).

<ToolInput args={{ to: "user@example.com", subject: "Hello", body: "..." }} />
// Renders:
// to       user@example.com
// subject  Hello
// body     ...
PropTypeDescription
argsRecord<string, unknown>Tool call arguments to display

ContextIndicator

A small progress bar showing context window usage. Reads token metadata from the most recent assistant message.

import { ContextIndicator } from '@supyagent/sdk/react';

<ContextIndicator messages={messages} maxTokens={200_000} />
// Renders: [████████░░░░░░░░] 52%

Color-coded by usage level:

  • Green (under 50%) — Plenty of room
  • Yellow (50–75%) — Getting warm
  • Orange (75–90%) — Approaching limit
  • Red (over 90%) — Near capacity
PropTypeDefaultDescription
messagesUIMessage[]Messages array from useChat()
maxTokensnumber128000Model's context window size
classNamestringCSS classes for the container

Returns null until the first assistant response is received (no metadata yet).

SummaryMessage

Renders a context-summary message as a collapsible card with a dashed border. Shows how many messages were summarized and lets users expand to read the summary.

import { SummaryMessage, isContextSummary } from '@supyagent/sdk/react';

{messages.map((message) =>
  isContextSummary(message) ? (
    <SummaryMessage key={message.id} message={message} />
  ) : (
    <RegularMessage key={message.id} message={message} />
  )
)}
PropTypeDescription
messageUIMessageA message with metadata.type === "context-summary"
classNamestringCSS classes for the container

isContextSummary(message)

Checks whether a UIMessage is a context summary:

if (isContextSummary(message)) {
  // Render differently
}

Utility Functions

getSummary(data, toolName)

Generate a human-readable summary of a tool result. Returns { text, badge? }.

const { text, badge } = getSummary(toolResult, 'gmail_list_messages');
// text: "Listed 12 emails"
// badge: { text: "12", variant: "default" }

const { text } = getSummary(toolResult, 'slack_send_message');
// text: "Sent message to #general"

humanizeToolName(toolName)

Convert a tool name to a human-readable label:

humanizeToolName('gmail_list_messages')  // → "List messages"
humanizeToolName('calendar_create_event') // → "Create event"

getProviderFromToolName(toolName)

Extract the provider prefix from a tool name:

getProviderFromToolName('gmail_list_messages') // → "gmail"
getProviderFromToolName('slack_send_message')  // → "slack"

getProviderLabel(provider)

Get a display-friendly label for a provider:

getProviderLabel('gmail')   // → "Gmail"
getProviderLabel('hubspot') // → "HubSpot"
getProviderLabel('github')  // → "GitHub"

getFormatterType(toolName)

Determine which formatter category a tool belongs to:

getFormatterType('gmail_list_messages')    // → "email"
getFormatterType('calendar_create_event')  // → "calendar"
getFormatterType('slack_send_message')     // → "slack"
getFormatterType('microsoft_mail_list')    // → "email" (Microsoft → Google formatter)

resolveToolName(rawToolName, args?)

Resolve a virtual tool name for rendering. For apiCall tools, derives the tool name from the API path:

resolveToolName('apiCall', { path: '/api/v1/gmail/messages' })
// → "gmail_messages"

resolveToolName('gmail_list_messages')
// → "gmail_list_messages" (unchanged)

PROVIDER_LABELS

A map of all known provider keys to display labels:

import { PROVIDER_LABELS } from '@supyagent/sdk/react';
// { gmail: "Gmail", calendar: "Calendar", slack: "Slack", ... }

Provider Formatters

The package also exports provider-specific formatter components for rich result rendering. These are intended for building custom tool result UIs:

FormatterProvider
EmailFormatterGmail, Outlook
CalendarEventFormatterGoogle Calendar, Microsoft Calendar
SlackMessageFormatterSlack
GithubFormatterGitHub
DriveFileFormatterGoogle Drive, OneDrive
DocsFormatterGoogle Docs
SheetsFormatterGoogle Sheets
SlidesFormatterGoogle Slides
SearchFormatterWeb Search
ComputeFormatterCode execution
HubspotFormatterHubSpot
LinearFormatterLinear
PipedriveFormatterPipedrive
ResendFormatterResend
InboxFormatterAI Inbox
DiscordFormatterDiscord
NotionFormatterNotion
TwitterFormatterTwitter/X
TelegramFormatterTelegram
WhatsAppFormatterWhatsApp
BrowserFormatterBrowser
ViewImageFormatterImage viewing
GenericFormatterFallback

What's Next