npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@portmento/agent-ui

v1.0.6

Published

Portmento agent UI SDK

Readme

@portmento/agent-ui

React UI components for embedding Portmento agents into your web application.

npm version

Installation

npm install @portmento/agent-ui
# or
pnpm add @portmento/agent-ui
# or
yarn add @portmento/agent-ui

Quick Start

Wrap your app with PortmentoProvider and drop in PortmentoChat:

import { PortmentoProvider, PortmentoChat } from "@portmento/agent-ui";

export default function App() {
  return (
    <PortmentoProvider
      publishableKey="pk_live_your_key"
      getToken={async () => {
        // Return your user's auth token (e.g. from Auth0, AD, Cognito etc.)
        return await getAuthToken();
      }}
    >
        <PortmentoChat />
    </PortmentoProvider>
  );
}

PortmentoProvider

The provider handles authentication and connects to the Portmento runtime. It must wrap any component that uses PortmentoChat or usePortmentoChat.

Props

| Prop | Type | Required | Description | |------|------|----------|-------------| | publishableKey | string | Yes | Your Portmento publishable key (pk_live_...) | | getToken | () => Promise<string> | Yes | Async function that returns the current user's auth token | | headers | Record<string, string> | No | Extra headers forwarded on every request (e.g. tenant ID) |

Example with custom headers

<PortmentoProvider
  publishableKey="pk_live_your_key"
  headers={{ "X-Company-Id": "your-company-uuid" }}
  getToken={async () => {
    const session = await Auth.currentSession();
    return session.getIdToken().getJwtToken();
  }}
>
  {children}
</PortmentoProvider>

PortmentoChat

A ready-to-use chat UI. Must be rendered inside PortmentoProvider.

<PortmentoChat />

The component fills its container — give the parent a defined height.

Props

| Prop | Type | Description | |------|------|-------------| | theme | PortmentoChatTheme | Customise colors, fonts, and border radius | | components | object | Override individual UI slots | | fallback | ReactNode | Shown when the chat fails to connect | | className | string | CSS class on the root element | | style | CSSProperties | Inline styles on the root element |

Theming

<PortmentoChat
  theme={{
    primaryColor: "#6366f1",
    backgroundColor: "#ffffff",
    textColor: "#111827",
    userMessageBackground: "#6366f1",
    userMessageColor: "#ffffff",
    assistantMessageBackground: "#f3f4f6",
    assistantMessageColor: "#111827",
    inputBackground: "#f9fafb",
    fontFamily: "Inter, sans-serif",
    borderRadius: "12px",
    fontSize: "14px",
  }}
/>

Custom components

Replace any part of the chat UI with your own components:

<PortmentoChat
  components={{
    Header: () => <div className="chat-header">Support</div>,
    UserMessage: ({ content }) => <div className="my-bubble user">{content}</div>,
    AssistantMessage: ({ content, isLoading }) => (
      <div className="my-bubble assistant">{content}</div>
    ),
    Input: ({ onSubmit, isLoading }) => (
      <MyCustomInput onSend={onSubmit} disabled={isLoading} />
    ),
    TypingIndicator: () => <span>Agent is thinking…</span>,
  }}
/>

usePortmentoChat (hook)

Access the chat state directly to build a fully custom UI.

import { usePortmentoChat } from "@portmento/agent-ui";

function MyChat() {
  const { messages, sendMessage, isLoading, stop, error, retry, canRetry } =
    usePortmentoChat();

  return (
    <div>
      {messages.map((msg) => (
        <div key={msg.id} className={msg.role}>
          {msg.content}
        </div>
      ))}
      {isLoading && <button onClick={stop}>Stop</button>}
      {error && (
        <div>
          {error}
          {canRetry && <button onClick={retry}>Retry</button>}
        </div>
      )}
      <input
        onKeyDown={(e) => {
          if (e.key === "Enter") sendMessage(e.currentTarget.value);
        }}
      />
    </div>
  );
}

Return values

| Field | Type | Description | |-------|------|-------------| | messages | PortmentoMessage[] | All messages in the conversation | | sendMessage | (text: string) => Promise<void> | Send a user message | | isLoading | boolean | True while the agent is running | | stop | () => void | Abort the current agent run | | error | string \| null | Current error message, if any | | retry | () => Promise<void> | Retry the last failed message | | canRetry | boolean | Whether a retry is available | | clearError | () => void | Dismiss the error state | | messageStatus | Record<string, MessageStatus> | Per-message status (sending, sent, failed) | | getMessageStatus | (id: string) => MessageStatus \| undefined | Status for a specific message |

Options

const chat = usePortmentoChat({
  statusClearDelay: 2000, // ms before "sent" status is removed (default: 1500, 0 to disable)
});

Types

type PortmentoMessage = {
  id: string;
  role: "user" | "assistant";
  content: string;
  createdAt?: Date;
};

type MessageStatus = "sending" | "sent" | "failed";

type PortmentoChatTheme = {
  primaryColor?: string;
  backgroundColor?: string;
  textColor?: string;
  userMessageBackground?: string;
  userMessageColor?: string;
  assistantMessageBackground?: string;
  assistantMessageColor?: string;
  inputBackground?: string;
  inputColor?: string;
  fontFamily?: string;
  borderRadius?: string;
  fontSize?: string;
};

Requirements

  • React 18+
  • The SDK is ESM-only

Acknowledgements

This SDK uses CopilotKit Core for underlying AGUI integration.

License

This package is proprietary. See license.