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

@rongcloud/embed-agent-studio-sdk

v0.1.0

Published

ChatAgentStudio 嵌入集成 SDK

Readme

@rongcloud/embed-agent-studio-sdk

一个用于嵌入融云 ChatAgentStudio 的 JavaScript SDK,支持在网页中动态加载和管理融云 ChatAgentStudio 的 iframe 组件。

安装

npm install @rongcloud/embed-agent-studio-sdk

环境要求

  • 现代浏览器,支持 URLURLSearchParamsfetchpostMessage
  • SDK 仅支持浏览器环境,不应在 SSR 服务端直接执行 init()open()
  • iframe 容器必须具有明确高度,否则嵌入页面可能不可见

快速开始

<div id="agent-studio" style="width: 100%; height: 720px"></div>
import AgentStudioSDK from "@rongcloud/embed-agent-studio-sdk";

AgentStudioSDK.on("ready", () => {
  console.log("Agent Studio 已就绪");
});

AgentStudioSDK.on("authFailed", () => {
  console.log("鉴权失效,请获取新 Token");
});

AgentStudioSDK.on("error", ({ type, message }) => {
  console.error(type, message);
});

AgentStudioSDK.init({
  // 填写 Agent Studio 的实际访问地址;如部署在 /embed 下,应包含该前缀。
  baseUrl: "https://example.com/embed",
  container: "#agent-studio",
  token: "your-token",
  RCAppkey: "your-app-key",
  RCRegion: "domestic",
  appId: "your-app-id",
  authUrl: "https://example.com/auth",
});

AgentStudioSDK.open({
  path: "/agent/agents",
});

初始化参数

init(options) 接收以下参数:

| 参数 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | baseUrl | string | 是 | Agent Studio 的访问地址,需要包含实际部署前缀 | | container | HTMLElement \| string | 是 | iframe 容器元素或可被 document.querySelector 识别的选择器 | | token | string | 是 | Embed 鉴权 Token | | RCAppkey | string | 是 | 融云 AppKey | | RCRegion | string | 否 | 服务区域,例如 domesticoverseasqa | | appId | string | 否 | AppInfo ID | | authUrl | string | 否 | 自定义鉴权服务地址 |

baseUrlopen({ path }) 会直接拼接。建议 baseUrl 不以 / 结尾,并始终让 path/ 开头。

API

init(options): void

初始化 SDK 并绑定容器。重复初始化会先销毁当前 iframe、通信监听和事件监听器。

当字符串选择器无法匹配容器时,init() 会抛出异常。

open(params?): void

创建并打开 iframe。

AgentStudioSDK.open();
AgentStudioSDK.open({ path: "/resources/workflows" });

iframe 已打开且传入新 path 时,SDK 会通过 postMessage 通知子应用进行站内导航,不会重新创建 iframe。iframe 已打开但未传入 path 时,会重新创建 iframe。

updateToken(token): void

更新 SDK 内保存的 Token,并通知已打开的子应用:

AgentStudioSDK.updateToken("new-token");

调用前必须已执行 open()

switchApp(params): void

切换当前应用信息。子应用收到消息后可能刷新页面:

AgentStudioSDK.switchApp({
  RCAppkey: "new-app-key",
  RCRegion: "domestic",
});

调用前必须已执行 open()

on(event, handler): void

订阅事件:

const handleReady = () => console.log("ready");

AgentStudioSDK.on("ready", handleReady);
AgentStudioSDK.off("ready", handleReady);

destroy(): void

移除 iframe 和跨窗口消息监听,清空初始化参数及全部事件监听器:

AgentStudioSDK.destroy();

状态属性

| 属性 | 类型 | 说明 | | --- | --- | --- | | isInitialized | boolean | 是否已执行初始化 | | isOpened | boolean | iframe 是否已打开 |

事件

| 事件 | 参数 | 说明 | | --- | --- | --- | | ready | 无 | 子应用初始化完成 | | authFailed | 无 | 子应用请求出现 401/403 鉴权失败 | | error | { type: string; message: string } | SDK 调用或菜单请求失败 | | destroyed | 无 | SDK 已销毁;触发后全部监听器会被清空 |

当前错误类型包括:

| 类型 | 说明 | | --- | --- | | not_initialized | 调用方法前未完成初始化 | | not_opened | 调用方法前 iframe 未打开 |

License

MIT