@gea-ai/chat-ui

中文文档
0.1.261111-alpha.1发布于 2026/11/12Apache-2.0TypeScriptES Module近 30 天下载 3803

Public chat message rendering and interaction components.

此软件包已被标记为弃用

This package is deprecated and will no longer receive updates.

原始使用文档
文档目录3 节
  1. Usage
  2. Styling
  3. yaml-render

@gea-ai/chat-ui

Public React renderers for GEA Agent chat messages. The package owns standard message-part behavior, streaming Markdown, request yaml-render, and safe fallbacks while leaving visual identity under the Extension's control.

Usage

import {
  type AgentChatMessage,
  GeaChatUIProvider,
  GeaMessages,
} from "@gea-ai/chat-ui";
import "@gea-ai/chat-ui/styles.css";

export function Chat({
  addToolOutput,
  messages,
  resolveAssetUrl,
}: {
  addToolOutput: (input: {
    messageId?: string;
    tool: "request";
    toolCallId: string;
    output: unknown;
  }) => Promise<void>;
  messages: AgentChatMessage[];
  resolveAssetUrl: (url: string) => string | null;
}) {
  return (
    <GeaChatUIProvider
      actions={{
        addToolOutput,
        resolveAssetUrl,
      }}
      locale="zh-CN"
      theme={{ accent: "#e46161", radius: "16px" }}
    >
      <GeaMessages messages={messages} status="streaming" />
    </GeaChatUIProvider>
  );
}

The host owns transport and authorization. The renderer never starts chats or requests protected resources by itself.

GEA's own Web/Desktop app-ui uses the same GeaRequestPart and GeaYamlRender runtime, injecting host actions, locale, and thin shadcn visual components through yamlComponents. Request state binding, streaming previews, skipped/submitted states, and submission semantics therefore have one implementation across first-party and Extension hosts.

Custom YAML components receive normalized bindings, canonical button actions, and field-validation metadata. A visual adapter applies the supplied ARIA/data attributes, calls onFieldBlur, and renders the supplied errors; it does not parse YAML, run validation rules, own form state, infer request lifecycle, or implement submission transport.

Styling

Import the default stylesheet and override semantic variables or stable data-slot selectors. GeaChatUIProvider also accepts visual component slots for message frames, avatars, and part renderers. yamlComponents replaces the visual implementation of catalog components without changing their schema, state binding, or action semantics.

<GeaChatUIProvider
  components={{ AssistantAvatar: BrandAvatar }}
  theme={{ accent: "#c64141" }}
  yamlComponents={{ Card: BrandRequestCard }}
>
  {children}
</GeaChatUIProvider>

yaml-render

Interactive request UI is rendered directly from a request tool part. New Agents call request({ yaml: "root: ..." }); yaml contains the complete source without a Markdown fence and puts initial values in top-level YAML state. Invalid specs and legacy request-key inputs fail closed. Text yaml-render fences remain display-only and are never joined to a request. While an AI SDK part is input-streaming, the renderer shows a semantic loading placeholder until the partial YAML has a valid root, then renders the last valid spec as a locked preview. It remounts the final state once when the part becomes input-available, performs strict request validation, and immediately unlocks the active form even if adjacent assistant text continues streaming. Submission calls the host-provided addToolOutput({ messageId, tool: "request", toolCallId, output }) action. The renderer includes the persisted assistant messageId when it renders from a message, but it does not own persistence or continuation transport. An Extension host should submit the result through app.gea.chats.submitToolOutput(...), then update its local chat state and resume the stream. Without the action, an active request fails closed. When a newer message makes an unanswered request inactive, the form remains visible with locked controls and a Skipped/已跳过 submit label; it does not submit form state as a user message.

Fields bind checks to the same state path as their value (or checked for Checkbox). The runtime supports required, requiredIf, email, url, numeric, length/range, pattern, and cross-field comparison checks. Submit always validates every field before calling addToolOutput; validateOn controls earlier change/blur feedback. Empty optional fields skip other checks, while required Checkbox and Rating fields require an affirmative selection. Requiredness must be declared with a required or requiredIf check; words such as "required" in a label have no validation meaning.

name:
  type: Input
  props:
    label: Name
    value: { $bindState: /name }
    checks:
      - type: required
        message: Name is required
    validateOn: blur
  children: []

Completed request YAML with unsupported rules, invalid rule arguments, or unsafe state references fails closed. Validation messages are generated UI copy and should use the same language as the conversation.

版本与发布记录

@gea-ai/chat-ui 共发布 93 个版本,首次发布于 2026/08/20;过去 12 个月发布了 93 个版本。

版本发布日期距今
0.1.261111-alpha.1latest2026/11/123 天前
0.1.261111-alpha.02026/11/124 天前
0.1.261106-alpha.02026/11/069 天前
0.1.261102-alpha.22026/11/0213 天前
0.1.261102-alpha.12026/11/0213 天前
0.1.261102-alpha.02026/11/0213 天前

关于 @gea-ai/chat-ui 的常见问题

@gea-ai/chat-ui 是什么?

Public chat message rendering and interaction components.注意:该包已被作者标记为弃用——This package is deprecated and will no longer receive updates.

如何安装 @gea-ai/chat-ui?

在项目目录运行 npm install @gea-ai/chat-ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.0.0)、react-dom(^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@gea-ai/chat-ui 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@gea-ai/chat-ui 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@gea-ai/chat-ui 可以商用吗?

@gea-ai/chat-ui 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@gea-ai/chat-ui 的下载量有多少?

根据 npm 官方下载统计,@gea-ai/chat-ui 在 2026/10/16 – 2026/11/14 这 30 天内被下载 3,803 次,日均约 127 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@gea-ai/chat-ui 还在维护吗?

最新版本 0.1.261111-alpha.1 发布于 2026/11/12(3 天前);至今共发布 93 个版本,其中过去 12 个月发布了 93 个;首次发布于 2026/08/20。作者已将其标记为弃用,新项目建议寻找替代方案。