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

@webcontextinterface/bridge

v1.2.0

Published

WCI bridge — typed action dispatch and ActionResult protocol

Downloads

409

Readme

@webcontextinterface/bridge

Typed action dispatch from agent decisions to live DOM, with ActionResult feedback and optional PolicyEngine enforcement.

Part of the Web Context Interface (WCI).

Install

npm install @webcontextinterface/bridge

Dependencies: @webcontextinterface/spec, @webcontextinterface/context

Install @webcontextinterface/context only if you use policy enforcement (recommended for production agents).

Quick start

import { WciBridge } from '@webcontextinterface/bridge';
import { WciContextLoader } from '@webcontextinterface/context';

const ctx = await WciContextLoader.load(window.location.origin);
const bridge = new WciBridge(document.getElementById('form-scope')!);
bridge.setPolicy(ctx.policy);

const result = await bridge.fill('email-input', '[email protected]');
if (!result.success) {
  console.error(result.error?.code, result.error?.message);
}

WciBridge

Session-scoped bridge with interaction history and wci:state-change subscription.

Constructor

new WciBridge(root?: Element, options?: { policy?: PolicyEngine })

Default root is document.body.

Methods

| Method | Description | |--------|-------------| | setPolicy(policy?) | Attach site policy from WciContextLoader | | getPolicy() | Current PolicyEngine, if any | | dispatch(req) | Low-level dispatch | | fill(nodeId, value) | Fill input | | click(nodeId) | Click button/link | | check(nodeId, checked?) | Toggle checkbox | | select(nodeId, value) | Select dropdown option | | onStateChange(handler) | Subscribe to DOM state events; returns unsubscribe | | getHistory() | All ActionResults this session | | clearHistory() | Reset history |

Policy enforcement

When a PolicyEngine is attached, every dispatch validates scope rules before DOM mutation:

  1. Resolve scope from data-wci-scope or enclosing landmark.
  2. Check deny list / allow list (wci.txt).
  3. Block auth-required and human-confirmation scopes.

Violations return success: false with typed error codes — no throw.

| Code | Meaning | |------|---------| | SCOPE_DENIED | Scope blocked by site policy | | AUTH_REQUIRED | Complete auth flow first | | HUMAN_CONFIRMATION_REQUIRED | Get explicit user approval | | NODE_NOT_FOUND | No matching data-wci-id | | PRECONDITION_UNMET | Target disabled or guard failed |

PolicyEngine.assertScopeAllowed() remains available for pre-flight checks on planned scopes (e.g. from manifest metadata).

Stateless dispatcher

import { dispatchAction } from '@webcontextinterface/bridge';

const result = await dispatchAction(
  { nodeId: 'submit-btn', action: 'click' },
  document.body,
  ctx.policy
);

Policy helpers

import {
  resolveScopeId,
  enforcePolicyForDispatch,
  checkPolicyBeforeDispatch,
} from '@webcontextinterface/bridge';

Use when building custom dispatch pipelines outside WciBridge.

ActionResult

Every call returns a structured result:

interface ActionResult {
  success: boolean;
  nodeId: string;
  action: string;
  value?: unknown;
  stateChange?: { before: Record<string, unknown>; after: Record<string, unknown> };
  sideEffects?: { nodeId: string; change: Record<string, unknown> }[];
  error?: { code: string; message: string; hint?: string };
  timestamp: string;
}

Side effects — other annotated nodes whose data-wci-state changed (e.g. submit button enabled after fill).

React / Vue

fill uses the native value setter and dispatches bubbling input and change events so controlled components update.

Related packages

| Package | Role | |---------|------| | @webcontextinterface/distiller | Provide node ids for dispatch | | @webcontextinterface/context | Load policy and site narrative | | @webcontextinterface/core | All-in-one SDK |

Documentation

License

MIT