@wallavi/widget

中文文档
2.13.0发布于 2026/11/03TypeScriptESM + CJS

Chat copilot for Wallavi agents. Install it with a component or a script; your app passes only the session and what the user is viewing.

原始使用文档

@wallavi/widget

Chat copilot for Wallavi agents. Install it with a component or a script; your app passes only the session and what the user is viewing.

pnpm add @wallavi/widget
"use client";
import { WallaviCopilot } from "@wallavi/widget";
import "@wallavi/widget/styles.css";

<WallaviCopilot
  agentId="your-agent-id"
  session={{
    userId: currentUser.id,
    userName: currentUser.name,
    userEmail: currentUser.email,
    headers: async () => ({ Authorization: `Bearer ${await getToken()}` }),
    identityToken: currentUser.identityToken,
  }}
  viewing="Purchase order PO-2026-0142"
/>;

Without React, paste this before </body>:

<script>
  window.wallavi =
    window.wallavi ||
    function () {
      (window.wallavi.q = window.wallavi.q || []).push(arguments);
    };
  wallavi("identify", {
    userId: currentUser.id,
    userName: currentUser.name,
    userEmail: currentUser.email,
    identityToken: currentUser.identityToken,
  });
  wallavi("viewing", "Purchase order PO-2026-0142");
</script>
<script
  src="https://app.wallavi.com/embed.min.js"
  data-agent-id="your-agent-id"
  async
></script>

Presentation (layout, colors, texts, shortcut) is changed in the Wallavi panel; you don't need to redeploy your app.

Migrating to 2.0.0

Private mode no longer reads window.Clerk. Before 2.0.0, a widget with workspaceId looked up a Clerk session on the page and sent its token. The widget now knows no auth provider: it sends only the headers the host returns from userContext.headers.

If you use private mode, pass your token yourself. A function is called before every message, so short-lived tokens are never sent stale:

<WallaviWidget
  agentId="..."
  workspaceId="..."
  userContext={{
    headers: async () => {
      const token = await getToken(); // your auth provider
      return token ? { Authorization: `Bearer ${token}` } : {};
    },
  }}
/>

Without headers, private requests go out with no Authorization header.

版本与发布记录

@wallavi/widget 共发布 83 个版本,首次发布于 2026/04/14;过去 12 个月发布了 83 个版本。

版本发布日期距今
2.13.0latest2026/11/03今天
2.12.02026/11/03今天
2.11.42026/10/259 天前
2.11.32026/10/2212 天前
2.11.22026/10/2113 天前
2.11.12026/10/1915 天前

关于 @wallavi/widget 的常见问题

@wallavi/widget 是什么?

聊天副驾驶 Wallavi 代理。用组件或脚本安装它;你的应用程序只传递会话和用户正在查看的内容。

如何安装 @wallavi/widget?

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

@wallavi/widget 支持 TypeScript 吗?

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

@wallavi/widget 支持 ESM 还是 CommonJS?

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

@wallavi/widget 可以商用吗?

@wallavi/widget 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@wallavi/widget 还在维护吗?

最新版本 2.13.0 发布于 2026/11/03(今天);至今共发布 83 个版本,其中过去 12 个月发布了 83 个;首次发布于 2026/04/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。