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

@render-policy/a2ui

v0.1.8

Published

Render-policy checks for A2UI (v0.9) surfaces: image, media, icon and openUrl values checked after data binding, and the catalog's Text contract (no HTML, images or links) enforced.

Readme

@render-policy/a2ui

The render policy for A2UI surfaces (specification v0.9 and v0.9.1). An A2UI agent sends no HTML: it describes components from a catalog, and your client renders them with its own widgets. Sanitization is no longer the question. Where the agent's data may flow still is.

In the basic catalog these places matter:

| Place | What happens without a policy | | --- | --- | | Image.url, Video.url, AudioPlayer.url, theme.iconUrl | the browser requests the URL as soon as it renders, without a click: whatever the agent put in the URL leaves | | openUrl (button actions) | navigation; the catalog requires http and https only and noopener,noreferrer | | Text.text | Markdown; the catalog says "without HTML, images, or links", but that is guidance to the agent, not a guarantee |

Nearly every property is dynamic: a literal, a { "path": "/…" } binding into the data model, or a function call such as formatString ("https://cdn.example/${/user/token}.png"). The value that matters exists only after binding and changes with every updateDataModel. Checking the message JSON is not enough: the check has to run on the resolved value, when the renderer uses it.

import { createA2uiGuard } from '@render-policy/a2ui';

const guard = createA2uiGuard({
  policy: { images: { hosts: ['cdn.example.com'] } },
  onDecision: (d) => audit.push(d),
});

// In your Image component, after the binding resolved:
const result = guard.url('image', resolvedUrl, { surfaceId, componentId });
if (result.allowed) img.src = result.value; // use result.value: the query string may be stripped, a proxy applied
else showPlaceholder(result.decision.reason);

// The basic catalog's openUrl function:
guard.openUrl(resolvedArgs.url); // opens with noopener,noreferrer only when allowed

// Text: inert fragment, no HTML, images or links
guard.renderText(element, resolvedText, { componentId });

What the guard does:

  • url(kind, value) for image, video, audio, icon and openUrl runs the URL policy of @render-policy/core on the resolved value: scheme allowlist, sink denylist, urls.decide, and for everything fetched without a click the image policy (host allowlist, query string handling, length and entropy heuristics, images.rewriteUrl). Video and audio players request on their own, so they follow the image rules. A value that is not a non-empty string (an unresolved binding, a number, an object) is refused with a2ui-not-a-url.
  • openUrl(value) allows only http and https (the catalog's requirement, on top of the policy), resolves relative targets against the page and opens with noopener,noreferrer. Pass open to route it through your own navigation.
  • text(value) / renderText(target, value) hold Text to the catalog contract: raw HTML is shown as text (a2ui-text-html), an image becomes its alt text (a2ui-text-image), a link its text (a2ui-text-link). Nothing the agent wrote disappears silently, and nothing is fetched or opened. The result is sanitized and inserted with replaceChildren(). text: 'policy' renders Text as ordinary Markdown under the policy instead, for a catalog of your own that allows more.
  • Every decision is a journal entry with the core's codes plus the A2UI place (a2ui.kind, surfaceId, componentId). Application hooks that throw become entries; the guard never throws.

The A2UI renderers' Markdown plug-in

The A2UI web renderers (React, Lit, Angular) take Markdown through a plug-in, (markdown, options) => Promise<string>, and insert the returned string themselves. createA2uiMarkdownRenderer() fits that contract with the strict Text mode, tagClassMap and renderMode: 'inline':

import { createA2uiMarkdownRenderer } from '@render-policy/a2ui';

const markdown = createA2uiMarkdownRenderer({ guard }); // share the guard with the rest of the surface
// React: <MarkdownContext.Provider value={markdown}>; Angular: provideMarkdownRenderer(markdown)

This is the compatibility path, and it is weaker than a fragment: the HTML is serialized here and parsed again by the renderer. Where you render Text yourself, use guard.renderText(), or the Text and Image components of @render-policy/react/a2ui and @render-policy/angular/a2ui, which are built on the guard.

Proofs

test/ checks the guard in jsdom. e2e/run.mjs runs an A2UI v0.9 surface in Chromium: image, video and icon URLs arrive literally, through updateDataModel and through formatString; Text carries Markdown images, raw HTML and links; a button calls openUrl('javascript:…'). With the guard, no request reaches a host outside the allowlist, the token assembled by formatString never leaves, and nothing opens. The same messages without the guard are the control: they make those requests.

For CI, mcp-app-lint --a2ui scans recorded A2UI message streams for the same hazards before anything renders. The evil-Markdown corpus has 24 A2UI cases (corpus/evil-a2ui.json) that any A2UI renderer can run through a corpus adapter. A2UI v1.0 follows when that version is stable.