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

@ahip/react

v0.2.0-preview

Published

Host-controlled React renderer for the Agent-Human Interaction Protocol.

Readme

@ahip/react

Agent-Human Interaction Protocol 的宿主可控 React 渲染器。

当 React 宿主需要渲染 AHIP item,同时让 action、artifact、widget 与本地 applet 解析继续受宿主控制时,可以使用本包。

English | 仓库首页 | 文档入口

安装

npm install @ahip/core @ahip/react react react-dom

reactreact-dom 是 peer dependencies。

基础渲染

import { AHIPItemRenderer } from "@ahip/react";
import type { AHIPItem } from "@ahip/core";

export function Message({ item }: { item: AHIPItem }) {
  return <AHIPItemRenderer item={item} />;
}

宿主应先使用 @ahip/core 校验不可信数据,再进入渲染。

宿主控制行为

import { AHIPItemRenderer } from "@ahip/react";

const actionDispatcher = {
  dispatchAction(action, context) {
    // 路由到你的宿主 runtime、审批流程或工具层。
  }
};

const artifactOpener = {
  openArtifact(artifact, context) {
    // 通过宿主策略解析和打开 artifact。
  }
};

export function Message({ item }) {
  return (
    <AHIPItemRenderer
      item={item}
      actionDispatcher={actionDispatcher}
      artifactOpener={artifactOpener}
    />
  );
}

自定义 Block、Widget 与 Applet

import { AHIPItemRenderer, createBlockRegistry, createWidgetRegistry } from "@ahip/react";

const blockRendererRegistry = createBlockRegistry({
  customBlockRenderers: {
    "org.example/profile.card": ({ block, fallback }) => {
      return <section>{block.title ?? fallback}</section>;
    }
  }
});

const widgetRegistry = createWidgetRegistry({
  widgetRenderers: {
    "org.example/counter.widget": ({ widget }) => {
      return <button>{String(widget.props.count ?? 0)}</button>;
    }
  }
});

export function Message({ item, appletRegistry }) {
  return (
    <AHIPItemRenderer
      item={item}
      appletRegistry={appletRegistry}
      blockRendererRegistry={blockRendererRegistry}
      widgetRegistry={widgetRegistry}
    />
  );
}

AHIP item 可以引用 applet,但 applet 是由宿主本地注册、校验和解析的运行单元。本渲染器不会下载或执行远程 applet 代码。

重要导出

  • AHIPItemRenderer
  • AHIPContentRenderer
  • AHIPActionBar
  • AHIPApprovalList
  • AHIPArtifactList
  • AHIPStatePatchList
  • AHIPToolIntentList
  • AHIPFallbackRenderer
  • WidgetHost
  • createBlockRegistry
  • createWidgetRegistry
  • defaultBlockRendererRegistry
  • defaultWidgetRegistry
  • defaultBlockRenderers
  • AHIPActionDispatcherAHIPArtifactOpenerAHIPAppletRegistryAHIPBlockRendererAHIPWidgetRenderer 等宿主集成类型

Fallback 行为

  • 不支持的 block 和 widget 会通过 fallback UI 渲染。
  • 单个 renderer 失败会被隔离,不应破坏整个 AHIP item。
  • 宿主可以提供 fallbackRendereronRenderError,接入自己的恢复与日志策略。

更多文档