# @copilotkit/react-textarea 中文文档

规范地址：https://npmcn.com/package/%40copilotkit/react-textarea/

版本：1\.85\.0
npm 元数据更新时间：2026-11-06T15:48:55.853Z
中文译文更新时间：2026-11-10T18:25:45.011Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40copilotkit/react-textarea
原文对照：https://npmcn.com/package/%40copilotkit/react-textarea/?lang=original
项目主页：https://github.com/CopilotKit/CopilotKit
源码仓库：https://github.com/CopilotKit/CopilotKit

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：888 kB，87 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：21 个
- peer 依赖：react ^18 \|\| ^19 \|\| ^19\.0\.0-rc，react-dom ^18 \|\| ^19 \|\| ^19\.0\.0-rc
- 首次发布：2023-08-23T06:21:30.100Z
- 最新版本发布：2026-11-06T15:48:55.396Z
- 近 30 天下载量：98596（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：1174（近 12 个月 415 个）

## 中文简介

![banner](https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084)

## 安装

```sh
npm install @copilotkit/react-textarea
```

也可以使用：`pnpm add @copilotkit/react-textarea`、`yarn add @copilotkit/react-textarea`、`bun add @copilotkit/react-textarea`

## README

# 副驾驶 Kit - 重现文本区域

![banner](https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084)  

 [![NPM](https://img.shields.io/npm/v/%40copilotkit%2Freact-textarea?logo=npm&logoColor=%23FFFFFF&label=Version&color=%236963ff)](https://www.npmjs.com/package/@copilotkit/react-core)[![MIT](https://img.shields.io/github/license/copilotkit/copilotkit?color=%236963ff&label=License) ](https://github.com/copilotkit/copilotkit/blob/main/LICENSE)[![Discord](https://img.shields.io/discord/1122926057641742418?logo=discord&logoColor=%23FFFFFF&label=Discord&color=%236963ff)](https://discord.gg/6dffbvGU3D)

  

[![](https://api.producthunt.com/widgets/embed-image/v1/top-post-badge.svg?post_id=428778&theme=light&period=daily)](https://www.producthunt.com/posts/copilotkit)

## 为什么是副驾驶Kit?

-   整合分钟 - 快速启动我们的CLI
-   框架不可知性 -- -- 与反应、Next.js、AGUI及更多
-   生产准备的UI - 使用自定义组件或用无头的UI来构建
-   内设安保-即时注射防护
-   公开源码----充分透明和由社区驱动

![class-support-ecosystem](https://github.com/user-attachments/assets/6cb425f8-ffcb-49d2-9bbb-87cab5995b78)

## 实际使用案例

部署深入集成的 AI 助手和代理, 与您的用户一起在您的应用程序中工作 .

![headless-ui](https://github.com/user-attachments/assets/3b810240-e9f8-43ae-acec-31a58095e223)

## 密码样本

掉入这些构件 适应你的需要.

### 以无头 API 和预建组件构建

```ts
// Headless UI with full control
const { visibleMessages, appendMessage, setMessages, ... } = useCopilotChat();

// Pre-built components with deep customization options (CSS + pass custom sub-components)
<CopilotPopup
  instructions={"You are assisting the user as best as you can. Answer in the best way possible given the data you have."}
  labels={{ title: "Popup Assistant", initial: "Need any help?" }}
/>
```

```ts
// Frontend actions + generative UI, with full streaming support
useCopilotAction({
  name: "appendToSpreadsheet",
  description: "Append rows to the current spreadsheet",
  parameters: [
    { name: "rows", type: "object[]", attributes: [{ name: "cells", type: "object[]", attributes: [{ name: "value", type: "string" }] }] }
  ],
  render: ({ status, args }) => <Spreadsheet data={canonicalSpreadsheetData(args.rows)} />,
  handler: ({ rows }) => setSpreadsheet({ ...spreadsheet, rows: [...spreadsheet.rows, ...canonicalSpreadsheetData(rows)] }),
});
```

### 将 App 代理代理与 LangGraph 合并

```ts
// Share state between app and agent
const { agentState } = useCoAgent({
  name: "basic_agent",
  initialState: { input: "NYC" }
});

// agentic generative UI
useCoAgentStateRender({
  name: "basic_agent",
  render: ({ state }) => <WeatherDisplay {...state.final_response} />,
});

// Human in the Loop (Approval)
useCopilotAction({
  name: "email_tool",
  parameters: [
    {
      name: "email_draft",
      type: "string",
      description: "The email content",
      required: true,
    },
  ],
  renderAndWaitForResponse: ({ args, status, respond }) => {
    return (
      <EmailConfirmation
        emailContent={args.email_draft || ""}
        isExecuting={status === "executing"}
        onCancel={() => respond?.({ approved: false })}
        onSend={() =>
          respond?.({
            approved: true,
            metadata: { sentAt: new Date().toISOString() },
          })
        }
      />
    );
  },
});
```

```ts
// intermediate agent state streaming (supports both LangGraph.js + LangGraph python)
const modifiedConfig = copilotKitCustomizeConfig(config, {
  emitIntermediateState: [
    {
      stateKey: "outline",
      tool: "set_outline",
      toolArgument: "outline",
    },
  ],
});
const response = await ChatOpenAI({ model: "gpt-6-luna" }).invoke(
  messages,
  modifiedConfig,
);
```

## QQ 有特色的例子

 [![](https://github.com/user-attachments/assets/874da84a-67ff-47fa-a6b4-cbc3c65eb704)](https://www.copilotkit.ai/examples/form-filling-copilot)[![](https://github.com/user-attachments/assets/0b5e45b3-2704-4678-82dc-2f3e1c58e2dd) ](https://www.copilotkit.ai/examples/state-machine-copilot)[![](https://github.com/user-attachments/assets/0fed66be-a4c2-4093-8eab-75c0b27a62f6)](https://www.copilotkit.ai/examples/chat-with-your-data)

## 文档

要从副驾驶Kit开始 请检查一下 [文档](https://docs.copilotkit.ai/)。 。 。 .

## 常见问题

### 如何安装 @copilotkit/react-textarea？

在项目目录运行 npm install @copilotkit/react-textarea，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（^18 \|\| ^19 \|\| ^19\.0\.0-rc）、react-dom（^18 \|\| ^19 \|\| ^19\.0\.0-rc）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @copilotkit/react-textarea 支持 TypeScript 吗？

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

### @copilotkit/react-textarea 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @copilotkit/react-textarea 可以商用吗？

@copilotkit/react-textarea 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @copilotkit/react-textarea 的下载量有多少？

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

### @copilotkit/react-textarea 还在维护吗？

最新版本 1\.85\.0 发布于 2026/11/06（4 天前）；至今共发布 1174 个版本，其中过去 12 个月发布了 415 个；首次发布于 2023/08/23。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

